-
Bug
-
Resolution: Fixed
-
P4
-
8
JVMS2 4.8.2 (== JVMS7 4.9.2) had a narrative rule that allows early assignment of instance fields of 'this' within an instance initialization method. This rule was not formalized in the Prolog type checking rules by JSR 202, despite HotSpot allowing such assignment in its implementation of the type checking verifier. The Prolog rule for putfield should be augmented to allow such assignment.
The code below says that if the assignment is to a field in class FieldClassName, and the putfield occurs in an <init> method of the same class FieldClassName, then it's OK if the incoming type state has uninitializedThis for the receiver (which indicates the putfield occurs before another <init> method has been called). Since the field being assigned is so close by, there's no need for passesProtectedCheck.
instructionIsTypeSafe(putfield(CP), Environment, _Offset, StackFrame, NextStackFrame, ExceptionStackFrame) :-
CP = field(FieldClassName, _FieldName, FieldDescriptor),
parseFieldDescriptor(FieldDescriptor, FieldType),
Environment = environment(CurrentClass, CurrentMethod, _, _, _, _),
CurrentClass = class(FieldClassName, _),
isInit(CurrentMethod),
canPop(StackFrame, [FieldType, uninitializedThis], NextStackFrame),
exceptionStackFrame(StackFrame, ExceptionStackFrame).
The code below says that if the assignment is to a field in class FieldClassName, and the putfield occurs in an <init> method of the same class FieldClassName, then it's OK if the incoming type state has uninitializedThis for the receiver (which indicates the putfield occurs before another <init> method has been called). Since the field being assigned is so close by, there's no need for passesProtectedCheck.
instructionIsTypeSafe(putfield(CP), Environment, _Offset, StackFrame, NextStackFrame, ExceptionStackFrame) :-
CP = field(FieldClassName, _FieldName, FieldDescriptor),
parseFieldDescriptor(FieldDescriptor, FieldType),
Environment = environment(CurrentClass, CurrentMethod, _, _, _, _),
CurrentClass = class(FieldClassName, _),
isInit(CurrentMethod),
canPop(StackFrame, [FieldType, uninitializedThis], NextStackFrame),
exceptionStackFrame(StackFrame, ExceptionStackFrame).
- duplicates
-
JDK-8160212 verifier specification missing for putfield on uninitializedThis
-
- Closed
-
- relates to
-
JDK-4093999 Relax constraint on placement of super() call in constructors
-
- Closed
-
-
JDK-8300585 4.10.1.9.putfield: verification rules allow early write to superclass field
-
- Resolved
-