Jvm | "in-depth understanding of the Java Virtual Machine," the study notes | VM class loading mechanism

The role of the Java virtual machine?

Interpretation of byte code program to eliminate platform dependencies.    
The jvm java bytecode interpreter instructions specific for a particular platform. General high-level language such as to run on different platforms, at least needs to be compiled into a different object code. And the introduction of JVM, Java language does not need to be recompiled to run on different platforms when.
Java language using a Java virtual machine shielding pattern associated with a particular information platform, so that the Java language compiler generates only running in the Java virtual machine object code (byte code), can be used without modification on multiple platforms run. Java Virtual Machine byte code, when executed, the bytecode interpreter into machine instructions executed on a particular platform. Links: HTTPS:
// www.nowcoder.com/questionTerminal/057e91ba0d14402c93a7262ef68b5892

Memory allocation strategy? (Book - 91)

Java system advocated automatic memory management boils down to solving automation memory allocation problems, a few of the most common memory allocation rule is to follow the target allocation priority in the new generation of large objects directly into the old era, long-lived objects into the old era.

  What is a large object?

Java object requires a lot of contiguous memory space, typically a long string and array

  How to understand the long-lived objects?

If the object after birth and through the first Minor GC in Eden were still alive, and can accommodate Survivor, it will be moved to the survivor space and age is set to 1. Each survivor objects in the area "get through" a minor GC, age, increased 1, when its age to a certain extent (the default is 15 years old), they will be promoted to the old era. 
Object promoted's old age threshold can be set by parameters.

Class life cycle

Load -> Authentication -> Prepare -> parse -> Initialization -> Use -> Uninstall

Class loading process (P214)

 

Class loading timing (book -210)

Java Virtual Machine specification does not perform the obligation, to this point can be given to specific virtual machine to free grasp.

Understanding of the initialization phase? (Book -210 to 211)

- - virtual machine specification strict rules and only five cases of the class must be immediately "initialize" 
    - encounter new, getstatic, putstatic, when these four invokestatic bytecode instructions (object instance, read and set the class static field, call the class's static method), if the class is not initialized, you need to trigger their initialization 
    - use java.lang.reflect package approach to reflect the class when invoked, if the class is not been initialized, you need to trigger initialize 
    - when initializing a class, if you find the parent class has not been initialized, you need to initialize the parent class of trigger 
    - when the virtual machine is started, users need to specify a main class to be executed (a main ( ) method of that class), the virtual machine to initialize this master class 
    - the use of dynamic language support jdk1.7, ...

Describe class loader and its role (and class relations) (p228) in a Java program?

Class loader for loading classes implement the operation. 

For any class, we need to establish its uniqueness in the Java virtual machine by loading its class loader and the class itself together. Comparison of two classes whether "equal" (equal class object () method, isAssignableForm () method, isInstance () method of prevention), 
only in these two categories is a prerequisite loaded by a class loader makes sense, otherwise even two classes in the same source file a class, is loaded with a virtual machine, as long as the class loader to load them different, and that the two classes will surely not equal.

Parents can delegate process model? (P231)

- If a class loader class loader receives a request, it first will not try to load this class, but the class delegates to the parent class loader to complete each level class loader is true, therefore All loader final request should be sent to the top of the boot class loader, only when the parent class loader feedback they can not complete the request, child loader will try to load your own. 
- benefit as it is a java class with the class loader together with a priority hierarchy.

 

Guess you like

Origin www.cnblogs.com/jj81/p/11203174.html