6

I've encountered this problem several times. Whenever I decompile something and save all the sources using JD-GUI, it prefixes each line with a block comment and inserts line numbers for code in the body of methods. Here is an example from a jar I just decompiled:

/*    */   public void onEnable()
/*    */   {
/* 25 */     List DropList = new ArrayList();
/* 26 */     DropList.add(Integer.valueOf(264));
/* 27 */     DropList.add(Integer.valueOf(57));
/* 28 */     DropList.add(Integer.valueOf(278));
/*    */ 
/* 30 */     this.config = getConfig();
/*    */ 
/* 32 */     this.config.addDefault("GiftDrops", DropList);
/* 33 */     this.config.addDefault("DropRate", Integer.valueOf(0));
/* 34 */     this.config.addDefault("GiftBoxPlayerSkin", "lol768");
/* 35 */     this.config.addDefault("CraftingRecipe.LineOne", "339,339,339");
/* 36 */     this.config.addDefault("CraftingRecipe.LineTwo", "339,264,339");
/* 37 */     this.config.addDefault("CraftingRecipe.LineThree", "339,339,339");
/*    */ 
/* 39 */     this.config.options().copyDefaults(true);
/* 40 */     saveConfig();
/*    */ 
/* 43 */     SkullMeta giftboxskull = (SkullMeta)this.giftbox.getItemMeta();
/*    */ 
/* 45 */     giftboxskull.setOwner(this.config.getString("GiftBoxPlayerSkin"));
/* 46 */     giftboxskull.setDisplayName(ChatColor.GREEN + "Gift Box");
/* 47 */     this.giftbox.setItemMeta(giftboxskull);
/*    */ 
/* 49 */     this.giftboxrecipe = new ShapedRecipe(this.giftbox);
/* 50 */     this.giftboxrecipe.shape(new String[] { "123", "456", "789" });
/*    */ 
/* 52 */     String[] LineOne = getConfig().getString("CraftingRecipe.LineOne").split(",");
/* 53 */     String[] LineTwo = getConfig().getString("CraftingRecipe.LineTwo").split(",");
/* 54 */     String[] LineThree = getConfig().getString("CraftingRecipe.LineThree").split(",");
/*    */ 
/* 56 */     this.giftboxrecipe.setIngredient('1', new ItemStack(Integer.parseInt(LineOne[0])).getData());
/* 57 */     this.giftboxrecipe.setIngredient('2', new ItemStack(Integer.parseInt(LineOne[1])).getData());
/* 58 */     this.giftboxrecipe.setIngredient('3', new ItemStack(Integer.parseInt(LineOne[2])).getData());
/* 59 */     this.giftboxrecipe.setIngredient('4', new ItemStack(Integer.parseInt(LineTwo[0])).getData());
/* 60 */     this.giftboxrecipe.setIngredient('5', new ItemStack(Integer.parseInt(LineTwo[1])).getData());
/* 61 */     this.giftboxrecipe.setIngredient('6', new ItemStack(Integer.parseInt(LineTwo[2])).getData());
/* 62 */     this.giftboxrecipe.setIngredient('7', new ItemStack(Integer.parseInt(LineThree[0])).getData());
/* 63 */     this.giftboxrecipe.setIngredient('8', new ItemStack(Integer.parseInt(LineThree[1])).getData());
/* 64 */     this.giftboxrecipe.setIngredient('9', new ItemStack(Integer.parseInt(LineThree[2])).getData());
/*    */ 
/* 66 */     getServer().addRecipe(this.giftboxrecipe);
/*    */ 
/* 68 */     getServer().getPluginManager().registerEvents(new GiftBoxEventListener(this), this);
/*    */   }

This seems to be a feature JD-GUI has to stop people from using the source files they obtain by compiling. I can fairly easily remove all of these comments using a bash command, but it's still an annoyance. Is there a way to disable this functionality?

Rabbyte
  • 343
  • 1
  • 3
  • 7
  • 3
    I'm curious: why do you call it a "problem" and jump to such an uncharitable conclusion? First of all: it *doesn't* stop you from compiling the files; they compile fine even with the comments there. And why would JD-GUI even care whether you compile the sources it creates? They aren't *their* sources. It's pretty obvious to me why it does it: because it's convenient, especially for debugging. Stack traces and debug info contain line numbers, and it can be extremely useful to know on *which* line of third party code an exception occurred or the program pointer is located during debugging... – Pepijn Schmitz Apr 21 '15 at 08:40
  • I agree it is annoying some times. For instance if you want to decompile 2 versions of the same jar and compare them using a merge tool. A single extra line in one class file will cause every line in the files to show as different. Zufuliu's answer really helps me! – George Nov 07 '18 at 20:45

1 Answers1

14

In "Help" -> "Preferences", under "Sources saving" group, uncheck "Display line numbers"

zufuliu
  • 372
  • 4
  • 5
  • Thanks, this worked. I saw this option earlier but thought it was for the line numbers displayed next to the code in the GUI and not the line numbers in the saved sources. – Rabbyte Aug 06 '14 at 02:13
  • who thought that preferences would be in help menu !!!!!!! thanks for the tip – Ahmed Osama Jul 15 '22 at 20:45