Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8157181 Compilers accept modification of final fields outside initializer methods
  3. JDK-8177116

Release Note: Compilers accept modification of final fields outside initializer methods

    Details

    • Subcomponent:
    • Verification:
      Verified

      Backports

        Description

        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).

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  zmajo Zoltan Majo (Inactive)
                  Reporter:
                  thartmann Tobias Hartmann
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: