Operation of a virtual machine on a class in startup
- Virtual machine load Class (ClassLoader), class for processing after the byte code, virtual machine know can do the following things. The process from hard disk to memory
- Link
- To validate the class, the header of the class is saved in two bytes, and this information, for details, is placed here with a professional documentation link.
- Allocate memory for the class, give the corresponding variable postscript the default value int give him a 0 Integer to give him a null ...
- Parsing special characters should be similar to spring's parsing of @autowrite, with its own routines, (find a suitable example to put here)
- The initialization variable assigns the correct value to the specific heat of the private String name= "Sky Cloud", first doing 2.2, allocating space, giving the default value null here gives him "Sky Cloud".
When does the initialization of a class occur?
The class (interface) is initialized only when it is "actively invoked" by the Java program for the first time.
What a good word!
First ~ ~ ~ Call
So how do I call calling it an active call
- When the class is instantiated, Object Object=new object ();
- Accesses a static variable of a class or interface, or assigns a value to the static variable object.name=b; (here is the question must be static?) )
- Call the static method of the class Object.exit ();
- Reflective Class.forName ("com.william.test")
- Initializes a subclass of a class. Object a=new String ();
- Class (Java Test) that is marked as the startup class when the Java virtual machine is started
The above can prove to write a class but not the active call, then do not have to worry about the logic inside, because the program cannot go anywhere.
Java VM (ii) the virtual machine initiates operations on the class