- A Concurrent Affair - https://www.concurrentaffair.org -

Constants Not Configurable

I’ve tried to implement what I described below: I had an interface with a bunch of public static final fields with the constants. Then I referenced these fields from elsewhere in the code and planned to just append a different version of the same interface to the beginning of the classpath.

The problem is that javac performs constant propagation. It recognizes that these constants are final and therefore inserts the literal value instead of using a reference to the constant field. When I remove the final modifier and turn the interface into a class, then the VM initialization craps out.

Looks like I have to come up with a different idea. Unfortunately these constants are used in many places, so patching them directly isn’t really an option.

[1] [2]Share [3]