Contents | Prev | Next | IndexThe JavaTM Virtual Machine Specification


getfield

Operation Fetch field from object

getfield
indexbyte1
indexbyte2


Forms getfield = 180 (0xb4)

Stack ..., objectref ..., value

OR

Stack ..., objectref ..., value.word1, value.word2

Description The objectref, which must be of type reference, is popped from the operand stack. The unsigned indexbyte1 and indexbyte2 are used to construct an index into the constant pool of the current class (§3.6), where the index is (indexbyte1 << 8) | indexbyte2. The constant pool item at the index must be a CONSTANT_Fieldref (§4.4.2), a reference to a class name and a field name. If the field is protected (§4.6), 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 (§5.2), 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.

Linking Exceptions During resolution of the CONSTANT_Fieldref constant pool item, any of the errors documented in §5.2 can be thrown.

Otherwise, if the specified field exists but is a static field, getfield throws an IncompatibleClassChangeError.

Runtime Exception Otherwise, if objectref is null, the getfield instruction throws a NullPointerException.

Notes The getfield instruction operates on both one- and two-word wide fields.


getstatic

Operation Get static field from class

getstatic
indexbyte1
indexbyte2


Forms getstatic = 178 (0xb2)

Stack ..., ..., value

OR

Stack ..., ..., value.word1, value.word2

Description The unsigned indexbyte1 and indexbyte2 are used to construct an index into the constant pool of the current class (§3.6), where the index is (indexbyte1 << 8) | indexbyte2. The constant pool item at the index must be a CONSTANT_Fieldref (§4.4.2), a reference to a class name and a field name. If the field is protected (§4.6), then it must be either a member of the current class or a member of a superclass of the current class.

The item is resolved (§5.2), determining both the class field and its width. The value of the class field is fetched and pushed onto the operand stack.

Linking Exceptions During resolution of the CONSTANT_Fieldref constant pool item, any of the exceptions documented in §5.2 can be thrown.

Otherwise, if the specified field exists but is not a static (class) field, getstatic throws an IncompatibleClassChangeError.

Notes The getstatic instruction operates on both one- and two-word wide fields.


goto

Operation Branch

goto
branchbyte1
branchbyte2


always

Forms goto = 167 (0xa7)

Stack No change

Description The unsigned bytes branchbyte1 and branchbyte2 are used to construct a signed 16-bit branchoffset, where branchoffset is (branchbyte1 << 8) | branchbyte2. Execution proceeds at that offset from the address of the opcode of this goto instruction. The target address must be that of an opcode of an instruction within the method that contains this goto instruction.


goto_w

Operation Branch always (wide index)

goto_w
branchbyte1
branchbyte2
branchbyte3
branchbyte4


Forms goto_w = 200 (0xc8)

Stack No change

Description The unsigned bytes branchbyte1, branchbyte2, branchbyte3, and branchbyte4 are used to construct a signed 32-bit branchoffset, where branchoffset is (branchbyte1 << 24) | (branchbyte2 << 16) | (branchbyte3 << 8) | branchbyte4. Execution proceeds at that offset from the address of the opcode of this goto_w instruction. The target address must be that of an opcode of an instruction within the method that contains this goto_w instruction.

Notes Although the goto_w instruction has a 4-byte branch offset, other factors limit the size of a Java method to 65535 bytes (§4.10). This limit may be raised in a future release of the Java Virtual Machine.


Contents | Prev | Next | Index

Java Virtual Machine Specification

Copyright © 1996, 1997 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to jvm@java.sun.com