Site Tools


Smart Card Solution

User Manual

JavaCard API Samples

Java Card Specification

Knowledge Sharing


7.5.6 anewarray

Create new array of reference






anewarray = 145 (0x91)


…, count → …, arrayref


The count must be of type short. 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 package ( Section 3.5, Frames), where the value of the index is (indexbyte1 « 8) | indexbyte2. The item at that index in the constant pool must be of type CONSTANT_Classref ( Section 6.7.1, CONSTANT_Classref), a reference to a class or interface type. The reference is resolved. A new array with components of that type, of length count, is allocated from the 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.

Runtime Exception

If count is less than zero, the anewarray instruction throws a NegativeArraySizeException.

javacard/jcvm/7.5.6_anewarray.txt · Last modified: 2017/05/13 04:09 (external edit)