1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 3 <html> 4 5 <head> 6 <title>new-array</title> 7 <link rel=stylesheet href="opcode.css"> 8 </head> 9 10 <body> 11 12 <h1>new-array</h1> 13 14 <h2>Purpose</h2> 15 16 <p> 17 Construct a new array of the indicated type and size. The type must be an array 18 type. 19 </p> 20 21 <h2>Details</h2> 22 23 <table class="instruc"> 24 <thead> 25 <tr> 26 <th>Op & Format</th> 27 <th>Mnemonic / Syntax</th> 28 <th>Arguments</th> 29 </tr> 30 </thead> 31 <tbody> 32 <tr> 33 <td>23 22c</td> 34 <td>new-array vA, vB, type@CCCC</td> 35 <td><code>A:</code> destination register (8 bits)<br/> 36 <code>B:</code> size register<br/> 37 <code>C:</code> type index</td> 38 </tr> 39 </tbody> 40 </table> 41 42 <h2>Constraints</h2> 43 44 <ul> 45 <li> 46 A and B must be valid register indices for the current stack frame. 47 </li> 48 <li> 49 Register vB must not contain a reference value. 50 </li> 51 <li> 52 Register vB must not be part of a register pair. 53 </li> 54 <li> 55 C must be a valid index into the type pool. 56 </li> 57 <li> 58 Type constant pool entry C must contain a valid array type descriptor. 59 </li> 60 </ul> 61 62 <h2>Behavior</h2> 63 64 <ul> 65 <li> 66 An attempt is made to get a reference to the class K the name of which is 67 contained in type pool entry C. 68 </li> 69 <li> 70 If K has not been loaded and resolved before, it is being loaded and 71 resolved. All exceptions that are possible during class loading can occur at 72 this point. 73 </li> 74 <li> 75 An attempt is made to create a new instance I of K and length B. All 76 exceptions that are possible during instantiation can occur at this point. 77 </li> 78 <li> 79 All elements of the new array are initialized to null (for object arrays) or 80 0 (for numeric arrays) or false (for boolean arrays). 81 </li> 82 <li> 83 A reference to the new array is moved to register vA, that is, vA' = I. 84 </li> 85 <li> 86 If v(A-1) is the lower half of a register pair, v(A-1)' becomes undefined. 87 </li> 88 <li> 89 If v(A+1) is the upper half of a register pair, v(A+1)' becomes undefined. 90 </li> 91 </ul> 92 93 <h2>Exceptions</h2> 94 95 <ul> 96 <li> 97 NegativeArraySizeException if vB < 0 98 </li> 99 <li> 100 All exceptions that are possible during class loading can occur. 101 </li> 102 <li> 103 All exceptions that are possible during instantiation can occur. 104 </li> 105 </ul> 106 107 </body> 108 </html> 109