写一个程序要求实现javap的功能(手工完成,不借助ASM等工具)如Java源代码:
public static void main(String[] args) { int i = 0; i += 1; i *= 1; System.out.println(i); }
编译后读取class文件输出以下代码:
public static void main(java.lang.String[]); Code: Stack=2, Locals=2, Args_size=1 0: iconst_0 1: istore_1 2: iinc 1, 1 5: iload_1 6: iconst_1 7: imul 8: istore_1 9: getstatic #2; //Field java/lang/System.out:Ljava/io/PrintStream; 12: iload_1 13: invokevirtual #3; //Method java/io/PrintStream.println:(I)V 16: return LineNumberTable: line 4: 0 line 5: 2 line 6: 5 line 7: 9 line 8: 16
|
|