As far as I am aware there is no (Java-standard-compliant) way to change the value of static final fields (excepting of course the previously noted System.in, out and err). And as far as the JVM is concerned the same holds true for non-static final fields. Just recently Cliff Click wrote two blog posts about that[1,2].
With kind regards Ben [1]: http://www.azulsystems.com/blog/cliff/2011-10-17-writing-to-final-fields-via-reflection [2]: http://www.azulsystems.com/blog/cliff/2011-10-27-final-fields-part-2 On 27 Nov., 13:23, "Fabrizio Giudici" <[email protected]> wrote: > On Fri, 25 Nov 2011 21:31:37 +0100, Ben Schulz <[email protected]> wrote: > > Well, that's not quite true. Static final fields actually are > > final[1]. > > I didn't check the specs... but are you sure? Because people tend to > consider them unmodifiable "also by reflection" just because they are > inlined by the compiler (a thing that can be worked around, BTW). I could > be wrong, but I'd say they are just fields as others, and final (other > than a compiler syntax) is a bit in the VM that could be possibly > dynamically modified? > > -- > Fabrizio Giudici - Java Architect, Project Manager > Tidalwave s.a.s. - "We make Java work. Everywhere." > [email protected]http://tidalwave.it-http://fabriziogiudici.it -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
