编写代码
public class TestStack {
public static void main(String[] args) {
int i = 2 + 3;
}
}
Maven编译
IDEA 打开终端,进入编译后的目录
cd javaSE/target/classes/com/javaSE/JVM/
反编译
javap -v TestStack.class
可以看到2+3编译完就直接是5
修改如下
解释
0: iconst_2 //常量2入栈
1: istore_1 //保存到栈1
2: iconst_3 //常量3入栈
3: istore_2 //保存到栈2
4: iload_1 //加载栈1
5: iload_2 //加载栈2
6: iadd //求和
7: istore_3 //保存到栈3
8: return //返回