2

It seems that java's reflaction need the symbol table to be compiled to the class file. but for performance considration, in run time we usually remove it out. ( i don't know java, in c++ ,we really move it out in production executives).

my quesion is if I remove the symbol table, will this means that some library, such as spring will not function right ?

ps:

from Professional Eclipse 3 for Java™Developers by Berthold Daum

Classfiles and JDK Compliance On the Compliance & Classfiles page you can specify which symbolic information, such as variable names and line numbers, is to be included in the generated classfiles. This information is required for debugging, and therefore you may want to leave the proposed settings unchanged. However, for a welltested program it may make sense to remove this information from the classfiles; generated files are much smaller without the symbol tables.

lovespring
  • 19,051
  • 42
  • 103
  • 153
  • 2
    What do you mean by _symbol table_ in Java? That's not a commonly used term in Java. – Sotirios Delimanolis Mar 31 '14 at 23:34
  • Can you explain why you're trying to do this? – Mark Peters Mar 31 '14 at 23:38
  • I'd be shocked if you could do anything like this at all and have _anything_ work, and would be still more shocked if it actually yielded any "performance considerations." – Louis Wasserman Mar 31 '14 at 23:40
  • Which "symbols" are you trying to remove? Java has some that are required even for normal (non-Reflection) linking (e.g. the method table), but others, like line number mappings, are optional. – Mark Peters Mar 31 '14 at 23:41
  • Maybe they're trying to do something like [this](http://stackoverflow.com/questions/5257987/any-java-counterpart-for-usr-bin-strip) ... – ajb Mar 31 '14 at 23:43
  • Also, I understand English might not be your first language but please check your spelling mistakes and grammar. You're writing `symbol` two different ways. – Sotirios Delimanolis Mar 31 '14 at 23:47
  • hi, all I have edit my post, symbols is just like var name etc. I'm not sure java's reflecting is base on those symbols. – lovespring Mar 31 '14 at 23:49

1 Answers1

3

In general, it's difficult to know what reflective code might use and not use. It is possible that frameworks like Spring may use the debug information available at runtime.

As an example, take Spring's @PreAuthorize and related annotations. In the documentation, we see the following:

You can access any of the method arguments by name as expression variables, provided your code has debug information compiled in.

Therefore, any step you take to remove debug information after compilation must be thoroughly tested or your code must be known to not include patterns like the above.

Note however that this reflection is not provided by the standard Java Reflection library. For more information on how this is done in Java, see this answer.

Community
  • 1
  • 1
Mark Peters
  • 80,126
  • 17
  • 159
  • 190