Other Topics
- Java allows classes to be loaded at the run-time, type checking happens at the compile time and bytecode is verified at the time of run.
- Classes can be loaded using
ClassLoader
and also can be unloaded. - Initialization is Java is complex and as COOL is a subset of Java, it also has a complex initialization.
- A class is initialized when it is first used not when it is loaded, as it will be non-deterministic to locate the error source, because classes are loaded in different sections many times.
- Initializing a class object in Java:
1. Lock the class object for the class wait for the lock if another thread is using it 2. If class is being initialized then release the lock and return 3. If it has been initialized the return normally 4. Otherwise mark the object as initialization in progress and release the lock on class 5. Initialize the super class in static order, but initialize static final fields first and before initialization give every field a default value. 6. If error, then mark the class as erroneous 7. If no error, lock class and mark i as initialized and then notify thread that object is ready to use and unlock class
- If N features are there in the systems then there are potentially N^2 interactions.