getfield

Fetch field from object

Bytecode

Type Description
u1 getfield opcode = 0xB4 (180)
u2 index

Stack ..., objectref => ..., value OR ..., objectref => ..., value.word1, value.word2

Description

The objectref, which must be of type reference, is popped from the operand stack. The index points to a position into the constant pool of the field entry, a reference to a class name and a field name. If the field is protected, then it must be either a member of the current class or a member of a superclass of the current class, and the class of objectref must be either the current class or a subclass of the current class.

The item is resolved, determining both the field width and the field offset. The value at that offset into the class instance referenced by objectref is fetched and pushed onto the operand stack.

Exceptions

NullPointerException - objectref is null