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

Mandy Chung mandy.chung at oracle.com
Fri Jan 11 18:07:33 UTC 2019

Hi Adam,

This is indeed a bug.    I suggest to do the check in the checkAccess 
method closes to where it performs the instance final field check.  
Please also add a test case.


On 1/11/19 6:38 AM, Adam Farley8 wrote:
> Hi All,
> First; thanks for responding so quickly. :)
> Second, it sounds like changing the contents of a final field is
> acceptable under the spec, but *not* changing the contents of a static
> final field.
> The test case uploaded to the bug uses a static final field for the test,
> so I think we can agree that the ability to create a setter for a static
> final field is still a bug.
> It sounds like the same fix could work if we check for "static" when we
> check for "final", with a modified message.
> As Field.set (post-setAccessible) fails to set the value of a static final
> field, I think we can agree that unreflectSetter should fail to create a
> setter MethodHandle for this same field.
> Best Regards
> Adam Farley
> IBM Runtimes

More information about the core-libs-dev mailing list