Contents | Prev | Next | IndexThe JavaTM Virtual Machine Specification


A B C D F G I J L M N P R S T W

pop

Operation

Pop the top operand stack value

Format

pop

Forms

pop = 87 (0x57)

Operand Stack

..., value ...

Description

Pop the top value from the operand stack.

The pop instruction must not be used unless value is a value of a category 1 computational type (§3.11.1).


pop2

Operation

Pop the top one or two operand stack values

Format

pop2

Forms

pop2 = 88 (0x58)

Operand Stack

Form 1:

..., value2, value1 ...

where each of value1 and value2 is a value of a category 1 computational type (§3.11.1).

Form 2:

..., value ...

where value is a value of a category 2 computational type (§3.11.1).

Description

Pop the top one or two values from the operand stack.


putfield

Operation

Set field in object

Format

putfield
indexbyte1
indexbyte2

Forms

putfield = 181 (0xb5)

Operand Stack

..., objectref, value ...

Description

The unsigned indexbyte1 and indexbyte2 are used to construct an index into the runtime constant pool of the current class (§3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The runtime constant pool item at that index must be a symbolic reference to a field (§5.1), which gives the name and descriptor of the field as well as a symbolic reference to the class in which the field is to be found. The class of objectref must not be an array. If the field is protected (§4.6), and it is either a member of the current class or a member of a superclass of the current class, then the class of objectref must be either the current class or a subclass of the current class.

The referenced field is resolved (§5.4.3.2). The type of a value stored by a putfield instruction must be compatible with the descriptor of the referenced field (§4.3.2). If the field descriptor type is boolean, byte, char, short, or int, then the value must be an int. If the field descriptor type is float, long, or double, then the value must be a float, long, or double, respectively. If the field descriptor type is a reference type, then the value must be of a type that is assignment compatible (§2.6.7) with the field descriptor type. If the field is final, it should be declared in the current class. Otherwise, an IllegalAccessError is thrown.

The value and objectref are popped from the operand stack. The objectref must be of type reference. The value undergoes value set conversion (§3.8.3), resulting in value', and the referenced field in objectref is set to value'.

Linking Exceptions

During resolution of the symbolic reference to the field, any of the exceptions pertaining to field resolution documented in Section 5.4.3.2 can be thrown.


Otherwise, if the resolved field is a static field, putfield throws an IncompatibleClassChangeError.

Otherwise, if the field is final, it must be declared in the current class. Otherwise, an IllegalAccessError is thrown.

Runtime Exception

Otherwise, if objectref is null, the putfield instruction throws a NullPointerException.


putstatic

Operation

Set static field in class

Format

putstatic
indexbyte1
indexbyte2

Forms

putstatic = 179 (0xb3)

Operand Stack

..., value ...

Description

The unsigned indexbyte1 and indexbyte2 are used to construct an index into the runtime constant pool of the current class (§3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The runtime constant pool item at that index must be a symbolic reference to a field (§5.1), which gives the name and descriptor of the field as well as a symbolic reference to the class or interface in which the field is to be found. The referenced field is resolved (§5.4.3.2).

On successful resolution of the field the class or interface that declared the resolved field is initialized (§5.5) if that class or interface has not already been initialized.

The type of a value stored by a putstatic instruction must be compatible with the descriptor of the referenced field (§4.3.2). If the field descriptor type is boolean, byte, char, short, or int, then the value must be an int. If the field descriptor type is float, long, or double, then the value must be a float, long, or double, respectively. If the field descriptor type is a reference type, then the value must be of a type that is assignment compatible (§2.6.7) with the field descriptor type. If the field is final, it should be declared in the current class. Otherwise, an IllegalAccessError is thrown.

The value is popped from the operand stack and undergoes value set conversion (§3.8.3), resulting in value'. The class field is set to value'.

Linking Exceptions

During resolution of the symbolic reference to the class or interface field, any of the exceptions pertaining to field resolution documented in Section 5.4.3.2 can be thrown.

Otherwise, if the resolved field is not a static (class) field or an interface field, putstatic throws an IncompatibleClassChangeError.

Otherwise, if the field is final, it must be declared in the current class. Otherwise, an IllegalAccessError is thrown.

Runtime Exception

Otherwise, if execution of this putstatic instruction causes initialization of the referenced class or interface, putstatic may throw an Error as detailed in Section 2.17.5.

Notes

A putstatic instruction may be used only to set the value of an interface field on the initialization of that field. Interface fields may be assigned to only once, on execution of an interface variable initialization expression when the interface is initialized (§2.17.4).


Contents | Prev | Next | Index

The JavaTM Virtual Machine Specification
Copyright © 1999 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to jvm@java.sun.com