-
Bug
-
Resolution: Fixed
-
P4
-
11
-
All platforms tested have seen this, including Windows, Linux, and MacOS.
-
b14
A setter MethodHandle for a final field seems counter intuitive, as final fields should not be able to be changed (whether they are accessible or not).
However, this operation is currently allowed if you call f.setAccessible(true) before calling Lookup.unreflectSetter(Field), resulting in a valid MethodHandle being returned. Also, the MethodHandle can be utilized to set the value of the reflected final field.
A testcase will be attached to this bug in short order, as well as the proposed fix.
This issue is seen on jdk11 and jdk12, so the fix should be merged into jdk11u, jdk12u, and head stream (jdk/jdk).
http://cr.openjdk.java.net/~afarley/8216558/webrev/
However, this operation is currently allowed if you call f.setAccessible(true) before calling Lookup.unreflectSetter(Field), resulting in a valid MethodHandle being returned. Also, the MethodHandle can be utilized to set the value of the reflected final field.
A testcase will be attached to this bug in short order, as well as the proposed fix.
This issue is seen on jdk11 and jdk12, so the fix should be merged into jdk11u, jdk12u, and head stream (jdk/jdk).
http://cr.openjdk.java.net/~afarley/8216558/webrev/
- csr for
-
JDK-8218061 Lookup.unreflectSetter(Field) fails to throw IllegalAccessException for static final field
- Closed
- relates to
-
JDK-8220282 Add MethodHandle tests on accessing final fields
- Resolved