deep

a Cross Development Platform for Java

User Tools

Site Tools


dev:crosscompiler:arrays

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
dev:crosscompiler:arrays [2016/02/25 13:33] – external edit 127.0.0.1dev:crosscompiler:arrays [2019/07/16 12:01] – [Multidimensional Arrays] ursgraf
Line 2: Line 2:
 The following figure demonstrates how arrays are implemented in the memory.  The following figure demonstrates how arrays are implemented in the memory. 
 [{{ .:array1.png?250&direct | //Implementation of an array//}}] [{{ .:array1.png?250&direct | //Implementation of an array//}}]
-An array extends //java/lang/object//. The field //Tag// points to the type descriptor of this array (//[ClassA// for this example). The single array elements themselves are of type //ClassA// and have a //Tag// which points to the type descriptor of //ClassA//. For this reason arrays of base types like ([B, [S ...) need a einen class descritor as well. \\+An array extends //java/lang/object//. The field //Tag// points to the type descriptor of this array (//[ClassA// for this example). The single array elements themselves are of type //ClassA// and have a //Tag// which points to the type descriptor of //ClassA//. For this reason arrays of base types like ([B, [S ...) need a class descritor as well. \\
 The field //length// denotes the number of elements of the array (16 bit). //heap// is used for the garbage collection ([[..:rts:heap|Heap Manager and Garbage Collection]]). In between there is a byte which contains an array bit. This is used for type checking. The //P// bit is for garbage collection. It is set for arrays of primitive types\\ The field //length// denotes the number of elements of the array (16 bit). //heap// is used for the garbage collection ([[..:rts:heap|Heap Manager and Garbage Collection]]). In between there is a byte which contains an array bit. This is used for type checking. The //P// bit is for garbage collection. It is set for arrays of primitive types\\
 When accessing array elements the code generator inserts code to check if the element index is in the range 0 to //length//.\\ When accessing array elements the code generator inserts code to check if the element index is in the range 0 to //length//.\\
Line 47: Line 47:
   short[][] a = new short[2][3]   short[][] a = new short[2][3]
 </code> </code>
-gives a Bytecode+leads to the Bytecode
 <code> <code>
 0 iconst_2 0 iconst_2
dev/crosscompiler/arrays.txt · Last modified: 2022/12/20 11:24 by ursgraf