当前位置:网站首页>JVM class loading mechanism

JVM class loading mechanism

2022-07-07 20:00:00 Whiteye too white

Class loading mechanism

load —> Connect ( verification -> Get ready -> analysis )—> initialization —> Use —> uninstall

1. load

  1. Get the binary byte stream defining this class through the full class name
  2. Convert the static storage structure represented by the byte stream to the runtime data structure of the method area
  3. Generate an in memory... That represents the class Class object , As the access to the data in the method area

2. verification

  1. class File format validation :class Document specification
  2. Metadata validation : Semantic analysis , Compliance java language norm
  3. Bytecode verification : Operation instruction is legal
  4. Symbol reference validation : Ensure that the parsing action is executed correctly

3. Get ready

Allocate memory for static variables of a class , And initialize it to the default value .
( It's not the initial value ,final Static constants decorated with keywords are directly assigned initial values , Load into the method area runtime constant pool .)

4. analysis

The process of replacing a symbolic reference in a constant pool with a direct reference .

5. initialization

Give the class the correct initial value for its static variables ,JVM Responsible for class initialization , Class variables are mainly initialized .
Initialization class triggers : new Instance object 、 Accessing static variables of a class 、 Calling static methods of a class 、 Reflection calls class 、 When subclasses need to be initialized, initialize the parent class first ( Same interface )、mian Method class .

6. uninstall

  1. All instance objects of this class have been GC, In other words, there is no instance object of this class in the heap .
  2. This class is not referenced anywhere .
  3. An instance of the class loader for this class has been GC.
原网站

版权声明
本文为[Whiteye too white]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071749177692.html