-
Sub-task
-
Resolution: Delivered
-
P4
-
7u171, 8u152, 9
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8177903 | 8u152 | Clifford Wayne | P4 | Closed | Delivered | |
JDK-8186388 | 7u171 | Clifford Wayne | P4 | Closed | Delivered |
According to the Java VM Specification, final fields can be modified by the `putfield` byte code instruction only if the instruction appears in the instance initializer method `<init>` of the field's declaring class. Similar, static final fields can be modified by a `putstatic` instruction only if the instruction appears in the class initializer method `<clinit>` of the field's declaring class. With the JDK 9 release, the HotSpot VM fully enforces the previously mentioned restrictions, but only for class files with version number >= 53. For class files with version numbers < 53, restrictions are only partially enforced (as it is done by releases preceding JDK 9). That is, for class files with version number < 53, final fields can be modified in any method of the class declaring the field (not only class/instance initializers).
- backported by
-
JDK-8177903 Release Note: Compilers accept modification of final fields outside initializer methods
-
- Closed
-
-
JDK-8186388 Release Note: Compilers accept modification of final fields outside initializer methods
-
- Closed
-