class loader for two types of classes
-java the loader that comes with the virtual machine
Root ClassLoader (Bootstrap): Written in C + +, Programer can not abtain the This class.
Extension class loader (Extension): Using Java code to implement
System ClassLoader: Using Java code to implement
-user-defined class loader
Java.lang.ClassLoader Subclass: (Public abstract class ClassLoader)
Users can customize how classes are loaded:
Packagepractise; Public classTestclassloader { Public Static voidMain (string[] args) {Class clz=NULL; Try{CLZ= Class.forName ("java.lang.String"); System.out.println (Clz.getclassloader ()); } Catch(ClassNotFoundException e) {//TODO auto-generated Catch blockE.printstacktrace (); } Class clz2=NULL; Try{CLZ2= Class.forName ("practise.c"); } Catch(ClassNotFoundException e) {//TODO auto-generated Catch blockE.printstacktrace (); } System.out.println (Clz2.getclassloader ()); }}classc{}
NULL--->This shows that this is the root ClassLoader .
[EMAIL protected]---> This description is the application loader
The JVM specification allows the ClassLoader to preload a class when it is expected to be used, if it encounters a. Class in the pre-loaded process.
If the file is missing or there is an error, the ClassLoader must report an error when the program first actively uses the class.
After the class is loaded, it enters the connection phase, which merges the binary data of the classes that have been read into the memory into the runtime environment of the virtual machine.
The contents of the validation of the class:
-Result checking of class files
-Semantic Check
-byte code verification
-Verification of binary compatibility
Preparation phase of the class
Parsing of classes
Java-deep Java Virtual Machine 2