|
Re: Arrays in JVM
|
Posted: Jul 9, 2004 9:06 PM
|
|
2> pops length, allocates a new array of objects of class indicated by indexbyte1 and indexbyte2, pushes objectref of new array.
anewarray (with comments)
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 runtime constant pool of the current class (§3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2.
[*** get an index into the pool (of type names) ***]
The runtime constant pool item at that index must be a symbolic reference to a class, array, or interface type. The named class, array, or interface type is resolved (§5.4.3.1).
[*** use the index to lookup the type name ***] [*** index is a reference to a type, not a reference to an object ***]
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.
[*** an array object is allocated, component objects are not allocated ***] [*** a reference to the array object is returned ***]
All components of the new array are initialized to null, the default value for reference types (§2.5.1).
[*** components are initialized to null ***]
http://java.sun.com/docs/books/vmspec/2nd-edition/html/Instructions2.doc.html
|
|