Contents | Prev | Next | Index | The JavaTM Virtual Machine Specification |
reference
from arrayaaload |
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
.
reference
arrayaastore |
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:
[]
, that is, an array of components of type SC, then:
Object
(§2.4.6), or:
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
.
null
aconst_null |
Description
Push the null
object reference
onto the operand stack.
Notes
The Java Virtual Machine does not mandate a concrete value for null
.
reference
from local variableaload | |
index |
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.
reference
from local variableaload_<n> |
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 | |
indexbyte1 | |
indexbyte2 |
reference
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.
reference
from methodareturn |
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 |
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
.
reference
into local variableastore | |
index |
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> |
reference
into local variable
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 |
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.
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