side note on static array constants and final fields
John.Rose at Sun.COM
Sat Jan 17 18:58:06 PST 2009
A side note on the unsigned-byte conversation:
Static finals are treated by the JIT as constants, and a few of their
built-in immutable fields are (recursively) compile time constants.
The oop _klass and array _length fields are both compile-time
constants, whenever the enclosing object reference is constant. This
is why you get benefit from making static arrays final; their range
checks fold up.
Some day we'll extend this treatment to user-written final instance
fields, so whole nests of objects can be folded more aggressively in
the JIT. It's tricky, though, since user-written finals are not
truly immutable: According to the verifier, they can be written and
even rewritten in their own constructors.
On Jan 17, 2009, at 1:35 PM, Ulf Zibis wrote:
> + the map should be defined final.
More information about the hotspot-dev