Tighten checks for final field updates

XMLWordPrintable

    • Type: Bug
    • Resolution: Won't Fix
    • Priority: P3
    • 9
    • Affects Version/s: 9
    • Component/s: hotspot
    • None

      In Java SE 5.0, the JVM Specification tightened up checks for putfield and putstatic bytecodes targeting final fields. For example, putfield changed in the following way:

      - JVMS Second Edition (1999, prior to Java SE 5.0) [1]: "Otherwise, if the field is final, it must be declared in the current class. Otherwise, an IllegalAccessError is thrown."

      - JVMS updates for Java SE 5.0 (2004) [2]: "Otherwise, if the field is final, it must be declared in the current class, and the instruction must occur in an instance initialization method (<init>) of the current class. Otherwise, an IllegalAccessError is thrown."

      The HotSpot VM did not implement the new checks until JDK-8157181. However, the changes by JDK-8157181 have introduced the checks only for class files with version 9 and onwards.

      The goal of the current bug is to investigate if the new checks should be tightened up to Java 7 and/or 8.

      [1] JVMS Second Edition, section 6.4: https://docs.oracle.com/javase/specs/jvms/se6/html/Instructions2.doc11.html
      [2] JVMS updates for Java SE 5.0: https://jcp.org/aboutJava/communityprocess/maintenance/jsr924/index.html -> open "The Java Virtual Machine Instruction Set" -> jump to putfield.

            Assignee:
            Zoltan Majo (Inactive)
            Reporter:
            Zoltan Majo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: