Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8160212

verifier specification missing for putfield on uninitializedThis


    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: specification
    • Labels:
    • Subcomponent:


      JVMS8 4.9.2 Structural Constraints says local fields may be written before the super call:

      "Each instance initialization method, except for the instance initialization method derived from the constructor of class Object, must call either another instance initialization method of this or an instance initialization method of its direct superclass super before its instance members are accessed. *****However, instance fields of this that are declared in the current class may be assigned before calling any instance initialization method.*****"

      In addition, the Linking Exceptions section of putfield instruction section (in 6.5) says:

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

      However, the Prolog code for the verifier (JVMS 4.10) simply requires that a putfield instruction is always able to pop an instance of the relevant class. The special logic for processing putfield on an "uninitializedThis" token is omitted. It should be specified. Suggested fix: Add another clause for putfield that invokes "rewrittenUninitializedType" in order to ensure that the popped reference is an "uninitializedThis" of the correct class.

      The historical reason for specifying the edge case for putfield is to allow initialization of sub-class fields before the super-class initializer is called. In this way, fields which are necessary to the correct operation of the class can be initialized before any method on the object is called, even if that method is called indirectly from the super-class initializer. In particular, even though users are not allowed to write Java code (currently) that can perform field initializations before the super-init call, javac emits such initializations for synthetic fields that link an inner class to its outer scope.


          Issue Links



              • Assignee:
                abuckley Alex Buckley
                jrose John Rose
              • Votes:
                0 Vote for this issue
                1 Start watching this issue


                • Created: