ArticleDirectory
Class Loading
It directly showsCodeIt should be classloader. getsystemclassloader (). loadclass ("com. My. Test. abcclass "). So it is often mentioned that the class loader classloader is specialized in class loading. Specifically, "loading a class" refers to loading a class. the binary data in the class file is read into the memory and placed in the method area, and a Java is created in the heap area. lang. class Object. Therefore, the final output of "loading" is a class object in the heap. Once it is generated, loading will be done. Here is another example -- Method
The PPT captured by Master Bi Xuan depicts the JVM memory layout. The book will show that class information, class field information, and method information are stored in the method area; in addition, I have heard a saying before: "heap (New Generation + Old Generation) is reserved for Java developers, rather than heap (persistent zone is the method zone) it is left for the JVM to use ". Let's look back at the above description -- "loading a class" refers to loading a class. the binary data in the class file is read into the memory and placed in the method area, and a Java is created in the heap area. lang. class Object, in other words, "class loading" isProgramA window for getting class-related definition information. This window is a class object, in the course of class loading, the structured class definition information of the method area is mapped to an object class object in the heap. Then, the programmer can get an instance of the class through this bridge, for example, call the newinstance () of the class ().
Class loading time
Currently, I understand that the loading time of a class is not controlled by programmers and is controlled by the JVM itself. Maybe it needs to consider some optimization strategies, such as the classes that the JVM thinks are likely to need in the future, JVM can be loaded in advance when idle, that is, the class object in the heap is prepared in advance. The latest time for class loading should be clear, which is equivalent to the class initialization time. Next we will talk about it during initialization.