1

In the JavaDoc of LocalVariableTableParameterNameDiscoverer http://static.springsource.org/spring/docs/2.0.x/api/org/springframework/core/LocalVariableTableParameterNameDiscoverer.html

The below line is mentioned:

Implementation of ParameterNameDiscover that uses the LocalVariableTable information in the method attributes to discover parameter names. Returns null if the class file was compiled without debug information.

I didn't get the meaning of compiled without debug information.

Please explain if anybody having any idea regarding this.

Sunny Gupta
  • 6,929
  • 15
  • 52
  • 80
  • 2
    Look at the javac -g [options](http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html#options). The default is to have some debugging info, but local variable names can be have too. – Joop Eggen Jun 14 '12 at 13:08

2 Answers2

1

In order to allow debugging, most compilers have a debugger friendly flag. When the flag is set, optimizations that re-order code are not done and the generated executable has information to link the machine code back to the source line that it was generated from. On the other hand, the compiler can be made to create a debug unfriendly executable where all this is removed in order to speed up the program a tiny bit.

The class that you mentioned cannot get parameter names out of a class file in the names were removed by the compiler to save space.

0

To save on space, java compiler avoids writing out method parameter names and more, see this. But for ParameterNameDiscover to work it needs the method parameter information printed out to the .class file and this can be accomplished by compiling the code with the -debug option prior to java 8 or -parameter option in java 8. For more information on method parameter in .class files see this stackover question.

Community
  • 1
  • 1
Geoffrey
  • 93
  • 3
  • 7