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

Next revisionBoth sides next revision
dev:crosscompiler:class_initialization [2014/11/03 13:31] – external edit 127.0.0.1dev:crosscompiler:class_initialization [2015/04/06 13:29] – [Initialize Classes] ursgraf
Line 32: Line 32:
   }   }
 </code> </code>
-Class A starts initializing, //a1 = b1 + 1// causes //clinit// of class B to be executed after which //clinit// of class A finishes. //a1// will be assigned the correct value of 101, but //b2// will be assigned 1 instaed of 201.+Class A starts initializing, //a1 = b1 + 1// causes //clinit// of class B to be executed after which //clinit// of class A finishes. //a1// will be assigned the correct value of 101, but //b2// will be assigned 1 instead of 201.
 This error goes undetected. A user has to make sure that the initialization is done in a correct way.  This error goes undetected. A user has to make sure that the initialization is done in a correct way. 
  
 ==== Our Solution ==== ==== Our Solution ====
-Beim Linken sollen alle Top-Level Klassen als Parameter angegeben werden könnenDiese Liste wird von links nach rechts geparst und die Imports in der richtigen Reihenfolge aufgelöstWenn sich Probleme mit zyklischen Imports ergebensoll der Linker eine Warnung ausgebenIm ausführbaren Image sollen die Klassen der Importreihenfolge nach geordnet sein, sodass das Laufzeitsystem die Konstruktoren nacheinander aufrufen kannDas bietet auch die Möglichkeit, beispielsweise diese Konstruktoren im Supervisor-Modus auszuführen (Konfiguration von Hardwareund anschliessend in den User-Modus zu wechseln. It's important that the heap class and the kernel class are initialized first. For this they are put at the beginning of the list.\\ +Before compilation all top-level classes (also called root classes) can be specifiedThis list will be parsed from left to right and the imports will be resolved in this orderIf there are problems with cyclic importsthe linker will output a warningIn the target image the classes should be ordered in the same mannerThe kernel will call the class constructors accordingly. This would allow to call the constructors in the supervisor mode (configuration of hardwareand subsequently change to user mode\\ 
-In Java ist die Initialisierungsreihenfolge nicht klar definiertFalls Test auf dem Host und dem Target stets das gleiche Resultat ergeben sollenbietet sich folgende Lösung anIm Klassenkonstruktor einer obersten Hauptklasse (die ansonsten vollständig leer ist) werden alle anderen Klassenkonstruktoren aufgerufenBei dieser Lösung entfällt auch die Notwendigkeit einer Systemtabelle.+It's important that the heap class and the kernel class are initialized first. For this they are put at the beginning of the list.\\ 
 +Java does not define the order of initialization clearlyIf tests on the host and the target should lead to the same resultthe following solution would be appropriatethe class constructor of a otherwise empty helper class calls all the other class constructorsThis solution would also allow to get rid of the system table.
    
 ===== Initialisierung von Objekten ===== ===== Initialisierung von Objekten =====
dev/crosscompiler/class_initialization.txt · Last modified: 2021/05/10 19:52 by ursgraf