Contents | Prev | Next | IndexThe JavaTM Virtual Machine Specification


aaload

Operation Load reference from array

aaload


Forms aaload = 50 (0x32)

Stack ..., arrayref, index ..., value

Description The arrayref must be of type reference and must refer to an array whose components are of type reference. The index must be of type int. Both arrayref and index are popped from the operand stack. The reference value in the component of the array at index is retrieved and pushed onto the top of the operand stack.

Runtime Exceptions If arrayref is null, aaload throws a NullPointerException.

Otherwise, if index is not within the bounds of the array referenced by arrayref, the aaload instruction throws an ArrayIndex-OutOfBounds-Exception.


aastore

Operation Store into reference array

aastore


Forms aastore = 83 (0x53)

Stack ..., arrayref, index, value ...

Description The arrayref must be of type reference and must refer to an array whose components are of type reference. The index must be of type int and value must be of type reference. The arrayref, index, and value are popped from the operand stack. The reference value is stored as the component of the array at index.

The type of value must be assignment compatible (§2.6.6) with the type of the components of the array referenced by arrayref. Assignment of a value of reference type S (source) to a variable of reference type T (target) is allowed only when the type S supports all the operations defined on type T. The detailed rules follow:

S cannot be an interface type, because there are no instances of interfaces, only instances of classes and arrays.

Runtime Exceptions If arrayref is null, aastore throws a NullPointerException.

Otherwise, if index is not within the bounds of the array referenced by arrayref, the aastore instruction throws an ArrayIndex-OutOfBounds-Exception.

Otherwise, if arrayref is not null and the actual type of value is not assignment compatible (§2.6.6) with the actual type of the components of the array, aastore throws an ArrayStoreException.


aconst_null

Operation Push null

aconst_null


Forms aconst_null = 1 (0x1)

Stack ... ..., null

Description Push the null object reference onto the operand stack.

Notes The Java Virtual Machine does not mandate a concrete value for null.


aload

Operation Load reference from local variable

aload
index


Forms aload = 25 (0x19)

Stack ... ..., objectref

Description The index is an unsigned byte that must be a valid index into the local variables of the current frame (§3.6). The local variable at index must contain a reference. The objectref in the local variable at index is pushed onto the operand stack.

Notes The aload instruction cannot be used to load a value of type returnAddress from a local variable onto the operand stack. This asymmetry with the astore instruction is intentional.

The aload opcode can be used in conjunction with the wide instruction to access a local variable using a two-byte unsigned index.


aload_<n>

Operation Load reference from local variable

aload_<n>


Forms aload_0 = 42 (0x2a)

aload_1 = 43 (0x2b)

aload_2 = 44 (0x2c)

aload_3 = 45 (0x2d)

Stack ... ..., objectref

Description The <n> must be a valid index into the local variables of the current frame (§3.6). The local variable at <n> must contain a reference. The objectref in the local variable at index is pushed onto the operand stack.

Notes An aload_<n> instruction cannot be used to load a value of type returnAddress from a local variable onto the operand stack. This asymmetry with the corresponding astore_<n> instruction is intentional. Each of the aload_<n> instructions is the same as aload with an index of <n>, except that the operand <n> is implicit.


anewarray

Operation Create new array

anewarray
indexbyte1
indexbyte2


of reference

Forms anewarray = 189 (0xbd)

Stack ..., count ..., arrayref

Description The count must be of type int. It is popped off the operand stack. The count represents the number of components of the array to be created. The unsigned indexbyte1 and indexbyte2 are used to construct an index into the constant pool of the current class (§3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The item at that index in the constant pool must be tagged CONSTANT_Class (§4.4.1), a symbolic reference to a class, array, or interface type. The symbolic reference is resolved (§5.1). A new array with components of that type, of length count, is allocated from the garbage-collected heap, and a reference arrayref to this new array object is pushed onto the operand stack. All components of the new array are initialized to null, the default value for reference types (§2.5.1).

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

Runtime Exception Otherwise, if count is less than zero, the anewarray instruction throws a NegativeArraySizeException.

Notes The anewarray instruction is used to create a single dimension of an array of object references. It can also be used to create part of a multidimensional array.


areturn

Operation Return reference from method

areturn


Forms areturn = 176 (0xb0)

Stack ..., objectref

[empty]

Description The objectref must be of type reference and must refer to an object of a type that is assignment compatible (§2.6.6) with the type represented by the return descriptor (§4.3.3) of the returning method. The objectref is popped from the operand stack of the current frame (§3.6) and pushed onto the operand stack of the frame of the invoker. Any other values on the operand stack of the current method are discarded. If the returning method is a synchronized method, the monitor acquired or reentered on invocation of the method is released or exited (respectively) as if by execution of a monitorexit instruction.

The interpreter then reinstates the frame of the invoker and returns control to the invoker.


arraylength

Operation

arraylength


Get length of array

Forms arraylength = 190 (0xbe)

Stack ..., arrayref ..., length

Description The arrayref must be of type reference and must refer to an array. It is popped from the operand stack. The length of the array it references is determined. That length is pushed onto the operand stack as an int.

Runtime Exception If the arrayref is null, the arraylength instruction throws a NullPointerException.


astore

Operation Store reference into local variable

astore
index


Forms astore = 58 (0x3a)

Stack ..., objectref ...

Description The index is an unsigned byte that must be a valid index into the local variables of the current frame (§3.6). The objectref on the top of the operand stack must be of type returnAddress or of type reference. It is popped from the operand stack, and the value of the local variable at index is set to objectref.

Notes The astore instruction is used with an objectref of type return-Address when implementing Java's finally keyword (see Section 7.13, "Compiling finally"). The aload instruction cannot be used to load a value of type returnAddress from a local variable onto the operand stack. This asymmetry with the astore instruction is intentional.

The astore opcode can be used in conjunction with the wide instruction to access a local variable using a two-byte unsigned index.


astore_<n>

Operation

astore_<n>


Store reference into local variable

Forms astore_0 = 75 (0x4b)

astore_1 = 76 (0x4c)

astore_2 = 77 (0x4d)

astore_3 = 78 (0x4e)

Stack ..., objectref ...

Description The <n> must be a valid index into the local variables of the current frame (§3.6). The objectref on the top of the operand stack must be of type returnAddress or of type reference. It is popped from the operand stack, and the value of the local variable at <n> is set to objectref.

Notes An astore_<n> instruction is used with an objectref of type returnAddress when implementing Java's finally keyword (see Section 7.13, "Compiling finally"). An aload_<n> instruction cannot be used to load a value of type returnAddress from a local variable onto the operand stack. This asymmetry with the corresponding astore_<n> instruction is intentional.

Each of the astore_<n> instructions is the same as astore with an index of <n>, except that the operand <n> is implicit.


athrow

Operation Throw exception

athrow


or error

Forms athrow = 191 (0xbf)

Stack ..., objectref

objectref

Description The objectref must be of type reference and must refer to an object which is an instance of class Throwable or of a subclass of Throwable. It is popped from the operand stack. The objectref is then thrown by searching the current frame (§3.6) for the most recent catch clause that catches the class of objectref or one of its superclasses.

If a catch clause is found, it contains the location of the code intended to handle this exception. The pc register is reset to that location, the operand stack of the current frame is cleared, objectref is pushed back onto the operand stack, and execution continues. If no appropriate clause is found in the current frame, that frame is popped, the frame of its invoker is reinstated, and the objectref is rethrown.

If no catch clause is found that handles this exception, the current thread exits.

Runtime Exception If objectref is null, athrow throws a NullPointerException instead of objectref.


athrow

Notes The operand stack diagram for the athrow instruction may be misleading: If a handler for this exception is found in the current method, the athrow instruction discards all the words on the operand stack, then pushes the thrown object onto the stack. However, if no handler is found in the current method and the exception is thrown farther up the method invocation chain, then the operand stack of the method (if any) that handles the exception is cleared and objectref is pushed onto that empty operand stack. All intervening stack frames from the method that threw the exception up to, but not including, the method that handles the exception are discarded.



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