我想学习Java字节码,我无意中发现了这一点: 我与-g
选项编译这个非常简单的代码:局部变量
public class Test
{
public static void main(String args[])
{
double a = 1.0;
int b = (int)a;
}
}
的主要代码竟然是:
0 dconst_1
1 dstore_1
2 dload_1
3 d2i
4 istore_3
5 return
此外,main的最大局部变量是4,LocalVariableTable只有3个条目(args,a,b)。我很想知道为什么编译器保留4个局部变量,而显然只有3个,并且localvariable[2]
未使用。有什么我失踪?谢谢