The end product of a class's load is a class object in the heap (heap)
class objects encapsulate the data structures in the method area and provide Java programmers with an interface to access data structures within the method area. And reflection is like a mirror. This interface is a reflection interface, so we can get the methods and properties of the class, including private methods and properties, by reflection.
Let's introduce the class loader in detail
There are two types of loaders for the class
1, Java Virtual machine with the loader
2, user-defined class loader
And the Java Virtual machine has its own loader and includes 3 kinds of loaders
? Root class loader (Bootstrap)
? Extended class loader (Extension)
? System class loader (Ststem)
The System class loader is also known as the Application class loader
where the extension class loader and the System class loader are implemented using Java. The root loader is implemented using C + +, and the JVM API does not expose the root class loader, and programmers cannot get the root loader in Java code.
The user-defined class loader is a class loader written by the user, but must inherit the Java.lang.ClassLoader class, which allows the user to customize how the class is loaded.
Let's take a look at the relevant API for the class loader
Each class object contains a definition of Classloader, that is, we can get the corresponding Classloader by class, so let's take a look at how the class object gets Classloader.
Class object has a getClassLoader method for returning the class loader of the class, but some implementations may use NULL to identify the boot class loader (root ClassLoader). That is, when we use the object loaded by the root loader using this method to get the ClassLoader is null, why is this so? As we've said before, the root loader is written in C + +, the JVM cannot and does not allow the programmer to get the class, so the return is null, and if this object represents a primitive type or void, then NULL is returned, in fact, the further implication is that all the bases in Java This data type is loaded by the root loader. (JDK1.5 Void is later included as the base data type).
Let's go through the code to see the class's first-off loader. (see section of code below)
package com.yhj.jvm.classloader.test;
/**
* @Description: ClassLoader Test and research
* @Author yhj create at 2011-6-25 04:08:32
* @FileName Com.yhj.jvm.classloader.test.ClassLoaderTest.java
*/
Public class classloadertest {
/**
*
* @Description: main function, launch entry
* @param args
* @author yhj create at 2011-6-25 04:08:57
* @throws classnotfoundexception
*/
Public Static void