--------------------- Android training, Java training, and hope to communicate with you! ---------------------- Class Loader
1. Overview
Classes in Java need to be loaded into the memory (to become bytecode, that is, Class Object. Generally, the class loader is also a Java class and also needs to be loaded by the loader. Therefore, there must be a non-Java class loader in Java to load these loaders, it is Bootstrap. Other loaders are Java classes, such as extclassloader, appclassloader, and self-defined loaders. Their relationships are as follows:
Bootstrap is the parent of extclassloader. It is used to load the class file in JRE/lib/RT. jar, that is, the system class.
Extclassloader is the parent of appclassloader, used to load the class in JRE/lib/EXT/*. jar, that is, the extension class
Appclassloader is the parent of the custom loader. It is used to load the specified jar or directory of classpath.
The custom class loader is used to load classes in a specified directory.
2. Delegation mechanism of the Class Loader
When the class loader loads a class, it first delegates the parent (parent) to complete it. If the parent can complete it, you don't have to do it yourself. This solution avoids repeated loading of the same class, resulting in multiple bytecode of the same class.
3. Custom Class Loader
Class myclassloader extends classloader
{
... (You need to override the findclass method to load the class using your own method)
}
Classloader is a subclass of the abstract class classloader. classloader uses the template design mode to expose uncertain parts of the class to the subclass, for example, the findclass method here is the custom part.
-------------------- Android training, Java training, and hope to communicate with you! ---------------------- For details, please refer to: http://edu.csdn.net/heima