10 September 2004
Mr Brunning found the inlining issue with static finals recently. I saw the exact same issue, and went through many of the same steps. Our application is exploded in the filesystem, so we hoped to be able to change one class and not have to redploy the whole thing. This interesting side effect caused us the same headaches of having to redeploy anything that may have used our Constants class.
final" off keeps it from happening, but also doesn't protect it from accidental changes.
new String("principal")would have avoided the actual value being inlined, since it's more dynamic.
This is an odd case where the compiler inlines the actual value instead of the normal reference to the object. I'm not sure ant should have been expected to recognize that to know to recompile -- Everything else is dynamically linked at runtime, so it normally wouldn't have required a recompile.
Filed Under: Java