Classloader of java_jvm

Source: Internet
Author: User

Beijing Shengsi Park deep Java Virtual Machine _ classloader: http://wenku.baidu.com/view/42d0a389d0d233d4b14e6940.html

Java Virtual Machine and Program Lifecycle

• In the following situations, Java virtual machines will end their lifecycle

-The system. Exit () method is executed.

-Normal execution of the program ends.

-An exception or error occurred while executing the program and ended unexpectedly.

-Java virtual machine process terminated due to an error in the operating system

 

 

Class loading, connection, and initialization

• Loading: search for and load binary data of the class

Class loading refers to the operation of the class.ClassThe binary data in the file is read into the memory, stored in the Method Area of the runtime data area, and a Java is created in the heap area. lang. class Object, used to encapsulate the data structure of the class in the Method Area
Class file is JVM recognition command, equivalent to the operating system to identify the EXE, the specific content of the class file: http://blog.csdn.net/fg2006/article/details/6696774

• Connection (All abnormal questions for the interview are posted here. Note that both preparation and initialization are assigned values, which means that the assignment is made twice.)

-Verification: ensure the correctness of the loaded class(Prevent others from generating class files without using the javac command. Different JDK class files are also different)

-Preparation: allocate memory for static variables of the class and initialize it as the default value.(The default value is 0 for int type and null for string type)

-Resolution: converts a symbolic reference in a class to a direct reference.

• Initialization: Assign the correct initial value to the static variables of the class.(The real value is assigned, for example, static int A = 3; the previous value of A is 0 given by the preparation stage, and then this step is changed to 3; pay attention to staticCodeThe block has no connection phase, but only the initialization phase)

 

 

• Java programs can use classes in two ways:

-Active use

• Active use (6 types)-create a class instance ------- Test A = new test ();-access non-compiled static variables of a class or interface, or assign a value to the non-compiled static variable ------- read and write the static variable int B =. staticvariable; orA. staticvariable= B;-call the static method of a class ------- call the static method test of a class. dosomething ();-Reflection (such as class. forname ("com. shengsiyuan. test) ------- such as class. forname ("XXXX");-initialize the subclass of A Class (initialize the subclass instead of actively using the parent class. In this case, an object class is generated, so it is not necessary to initialize each class) ------- child. class, parent. class, initializationChildIsActive use of parent, initialize parent class first-Java test ------- indicates the class of the main method when the Java Virtual Machine starts.

In addition to the above six cases, other methods of using the Java class are regarded as passive usage of the class and will not lead to class initialization.

-Passive Use

• All Java Virtual Machine implementations must be implemented by Java programs in each class or interface"First active use"Initialize them

 

 

 

Class loading:
 
• Loading a class refers to loading a class. the binary data in the class file is read into the memory, stored in the Method Area of the runtime data area, and a Java is created in the heap area. lang. class Object, used to encapsulate the data structure of the class in the method area • load. class file method-load directly from the local system-download through the network. class file (urlclassloader)-Loads files from archive files such as zip and jar. class file-extract from apsaradb. class file-dynamically compile the Java source file. class File

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.