It is well known that the Java compiler pulls constant field values โโfrom other classes at compile time . The resulting class file does not contain a constant pool entry (of any type) for such constants.
Q: can the compiler do this? (Oracle JDK 7 will be nice)
As an illustration, consider a piece of code
out.println(some.other.class.FOO)that reads FOO (say, public static final int FOO = 1234) and displays it. I can find links to printlnwithout problems, but the constant turns into anonymous sipush 1234.
For class level dependency analysis, it would be great to have transparency here! Note. I am not asking for any changed value to appear somehow in the dependent code (see many other SO questions on this) ...
I am thinking of a Java Compiler API plugin API to javac, but does this sound a bit far-fetched? Any ideas?
source
share