从JDK源码级别彻底剖析JVM类加载机制
1.类加载运行全过程
当我们用java命令运行某个类的main函数启动程序时,首先需要通过类加载器把主类加载到 JVM。
package com.sn.jvm;/*** @author snwu*/public class MathTest {private int compute(){int a = 1;int b = 2;return a+b;}public static void main(String[] args) {MathTest mathTest = new MathTest();int compute = mathTest.compute();System.out.println(compute);}}
通过Java命令执行代码的大体流程如下:
