RFR: JDK-8216558: Lookup.unreflectSetter(Field) fails to throw IllegalAccessException for final fields

Adam Farley8 adam.farley at uk.ibm.com
Fri Jan 11 12:46:01 UTC 2019

Hi All,

I posit that you shouldn't be able to change the contents of a a final 

However, if you use Field.setAccessible(true) before calling 
Lookup.unreflectSetter(Field), then you can get a MethodHandle that allows 
you to set the (reflected) value of a static final field.

This seems wrong to me, so here's a change to fix it.

webrev: http://cr.openjdk.java.net/~afarley/8216558/webrev/
bug: https://bugs.openjdk.java.net/browse/JDK-8216558

Opinions invited. 

Best Regards

Adam Farley 
IBM Runtimes

Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

More information about the core-libs-dev mailing list