In layman's language JVM (a): How do you write .java file is loaded into memory executed

As we all know, .java file needs to be compiled to generate JVM .class files can be executed.

Which, JVM is how to load .class files, you have done it?

.class files by loading - what did "analytical and other processes, methods loaded into the area, waiting for the calling code, the following talk about it each step -" Validation - "Preparing

 

A load

  .Class file is loaded into the jvm.

So when it loaded? When the class is called! For example: new A (); when A is loaded into memory. It should be noted that not every time will be used to load, just load came in the first time use.

 

Second, verify

  Verify compliance .class files.

Prevent .class file has been tampered with, resulting file can not be executed

 

Third, prepare

  Allocation of classes, to the static variable initialization assignment default

 

Fourth, resolve

  The symbolic reference becomes a direct reference

It will become a reference pointer to.

 

Class above class loader in the loading process is complete, the details is actually very complicated, we just need to understand the core can be. The class loader delegate also involves the parents. Self-learning

  

Guess you like

Origin www.cnblogs.com/zjting/p/11301419.html