deep

a Cross Development Platform for Java

User Tools

Site Tools


dev:crosscompiler:class_initialization

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:class_initialization [2015/04/06 13:29] – [Initialize Classes] ursgrafdev:crosscompiler:class_initialization [2015/04/06 13:37] – [Initialization of Objects] ursgraf
Line 40: Line 40:
 Java does not define the order of initialization clearly. If tests on the host and the target should lead to the same result, the following solution would be appropriate: the class constructor of a otherwise empty helper class calls all the other class constructors. This solution would also allow to get rid of the system table. Java does not define the order of initialization clearly. If tests on the host and the target should lead to the same result, the following solution would be appropriate: the class constructor of a otherwise empty helper class calls all the other class constructors. This solution would also allow to get rid of the system table.
    
-===== Initialisierung von Objekten ===== +===== Initialization of Objects ===== 
-Die Initialisierung von Objekten wird in den Objektkonstruktoren zusammengefasst.+The initialization of objects is done in the object constructors.
 <code java> <code java>
   int len = 4;  // block 1   int len = 4;  // block 1
Line 50: Line 50:
   }   }
 </code> </code>
-Die Objektkonstruktoren heissen alle //init// im Bytecode und unterscheiden sich in der Parameterliste. Block 1 und werden in //init// zusammengefasst+In the Bytecode these constructors carry the name //init// and vary in the parameter list. Block 1 and block in the above code block will be combined in //init//. 
-Beim Erzeugen eines Objektes wird stets zuerst mit Hilfe von //new// ein Block auf dem Heap alloziertAnschliessend wird der Konstruktor der Oberklasse aufgerufen (dieser ruft seinerseits den Konstruktor der Oberklasse auf). Diese Aufrufe sind im Bytecode enthalten+When creating an object a call to //new// allocates a block on the heapNext, the constructor of the super class is called (which itself calls its super class constructor). These calls can be found in the Bytecode. 
-Klassen dürfen auch Instanzinitialisierer enthaltenz.B. +Classes might also have instance initializerssuch as: 
 <code java> <code java>
   int[] data = new int[10];     int[] data = new int[10];  
   {for (int i = 0; i < 10; i++) data[i] = i;}   {for (int i = 0; i < 10; i++) data[i] = i;}
 </code> </code>
-Auch diese Instanzinitialisierer befinden sich im Bytecode in den Objektkonstruktoren.+These initializers go into the object constructors as well.
  
dev/crosscompiler/class_initialization.txt · Last modified: 2021/05/10 19:52 by ursgraf