Contents Prev Next Up


A.3 Managing Arrays (_quick variants)

anewarray_quick

Allocate new array
 
anewarray_quick
indexbyte1
indexbyte2
of references to objects

Stack: ..., size => result

size must be an integer. It represents the number of elements in the new array.

indexbyte1 and indexbyte2 are are used to construct an index into the constant pool of the current class. The entry must be a class.

A new array of the indicated class type and capable of holding size elements is allocated, and result is a reference to this new array. Allocation of an array large enough to contain size items of the given class type is attempted. All elements of the array are initialized to zero.

If size is less than zero, a NegativeArraySizeException is thrown. If there is not enough memory to allocate the array, an OutOfMemoryError is thrown.

multianewarray_quick

Allocate new multi-dimensional array
 
multianewarray_quick
indexbyte1
indexbyte2
dimensions

Stack: ..., size1, size2, ...sizen => result

Each size must be an integer. Each represents the number of elements in a dimension of the array.

indexbyte1 and indexbyte2 are used to construct an index into the constant pool of the current class. The resulting entry must be a class.

dimensions has the following aspects:

If any of the size arguments on the stack is less than zero, a NegativeArraySizeException is thrown. If there is not enough memory to allocate the array, an OutOfMemoryError is thrown.

The result is a reference to the new array object.

Note: More explanation needed about how this is an array of arrays.


Contents Prev Next Up