0

I am using the YourKit Java profiler to find CPU hogging spots in some Java code. I do not have the original source code for the Java classes, so I have been decompiling it to see what needs to be fixed.

The line numbers on decompiled code (using JD-GUI, I have not tested with anything else yet) do not line up with those shown in the YourKit profiler CPU sampling window.

Is there a decompiler available that will match up original source file line numbers with the decompiled code?

As you can see below, the output line number for EnergyNetwork.getAcceptors() is line 86. Yet, in JD-GUI it shows line 86 to be a list.

YourKit output Decompiler Output

Sameer Puri
  • 987
  • 8
  • 20

1 Answers1

0

I had great results for the (foreign) code I use with JD-GUI, as long as the code was not obfuscated. Did you try the latest version of JD-GUI ? And just an idea: is the code you get so fit that it could be compiled again ? This way you might have better control about code to source mapping and in the end this would be necessary anyway because you want to fix the performance problem.

Marged
  • 10,577
  • 10
  • 57
  • 99
  • I will test that and get back to you – Sameer Puri Jan 18 '15 at 15:33
  • Deobfuscating it had no visible effect on line numbers – Sameer Puri Jan 18 '15 at 15:40
  • It looks like the code is not obfuscated. The names of methods and variables are quite "pretty". Just a wild guess: perhaps the Arrays.asList() together with whatever getAcceptors() does is what causes the problem ? Then the line mentioned would be correct and the profiler just shows the name of the surrounding method because he is not able to show specific code lines ? – Marged Jan 18 '15 at 16:25
  • Perhaps you should check what is in lines 167 and 149. Do they contain a method name or a statement ? – Marged Jan 18 '15 at 16:29
  • I have checked those, line 149 is an if statement and line 167 is not visible (I'm guessing because the decompiler was not able to identify which line number it was) – Sameer Puri Jan 18 '15 at 16:49