Create new array of objects
Bytecode
Type | Description |
u1 | anewarray_quick opcode = 0xDE (222) |
u2 | index |
Stack ..., count =>..., arrayref
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.
In bytecode, immediately after the anewarray opcode there is a 16-bit unsigned integer index. The item at that index in the constant pool must be a class entry, which is a symbolic reference to a class, array, or interface type. The symbolic reference is resolved.
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. A reference to
the new array is pushed onto the stack. Entries in the new array are initially set to
null.
Exception
NegativeArraySizeException
- size is less than zero.
The opcode of this instruction was originally anewarray. The operands of the anewarray instruction are not modified.
The anewarray_quick instruction is used to create a single dimension of an array of object references. It can also be used to create the first dimension of a multidimensional array.