On constant folding of final field loads

Paul Sandoz paul.sandoz at oracle.com
Mon Jun 29 08:34:37 UTC 2015


Hi Vladimir,

Looks like there is some really good investigatory work here.


On Jun 27, 2015, at 3:27 AM, Vladimir Ivanov <vladimir.x.ivanov at oracle.com> wrote:
> There are 4 ways to circumvent runtime limitations and change a final field value:
>  - Reflection API (Field.setAccessible())
>  - Unsafe
>  - JNI
>  - java.lang.invoke (MethodHandles)
> 

For MHs it's not possible to lookup a MH (via MH.L.findSetter/unreflectSetter) to a final field.

http://hg.openjdk.java.net/jdk9/dev/jdk/file/93ced310c728/src/java.base/share/classes/java/lang/invoke/MethodHandles.java#l1516

Although i cannot find any such explicit mention in JavaDoc, so i guess it can be considered under the umbrella of "access checks".

Paul.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20150629/b99c705f/signature.asc>


More information about the hotspot-compiler-dev mailing list