JVM Knowledge

getfield

Raw .md Oracle

A getfield instruction with operand CP is type safe iff CP refers to a constant pool entry denoting a field whose declared type is FieldType that is a member of a type FieldClassType, and one can validly replace FieldClassType with FieldType on the incoming operand stack yielding the outgoing type state. protected fields are subject to additional checks (§4.10.1.8).

instructionIsTypeSafe(getfield(CP), Environment, _Offset, StackFrame,
                      NextStackFrame, ExceptionStackFrame) :-
    CP = field(FieldClassType, FieldName, FieldDescriptor),
    parseFieldDescriptor(FieldDescriptor, FieldType),
    passesProtectedCheck(Environment, FieldClassType, FieldName,
                         FieldDescriptor, StackFrame),
    validTypeTransition(Environment, [FieldClassType], FieldType,
                        StackFrame, NextStackFrame),
    exceptionStackFrame(StackFrame, ExceptionStackFrame).