我知道编译时此调试信息包含在 .class 文件中
和:
javac -g Main.java
并且可以从手动观察LineNumberTable:
部分:
javap -c -constants -private -verbose '$<' > '$@'
我想要的是做javap
在字节码中间显示源。
输入示例:
public class New {
public static void main(String[] args) {
System.out.println(new Integer(1));
}
}
Actual javap
output:
0: getstatic #2 // Field java/lang/System.out:Ljava/io/PrintStream;
3: new #3 // class java/lang/Integer
6: dup
7: iconst_1
8: invokespecial #4 // Method java/lang/Integer."<init>":(I)V
11: invokevirtual #5 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
14: return
LineNumberTable:
line 3: 0
line 4: 14
所需的 javap 输出:
System.out.println(new Integer(1));
0: getstatic #2 // Field java/lang/System.out:Ljava/io/PrintStream;
3: new #3 // class java/lang/Integer
6: dup
7: iconst_1
8: invokespecial #4 // Method java/lang/Integer."<init>":(I)V
11: invokevirtual #5 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
}
14: return
LineNumberTable:
line 3: 0
line 4: 14
这会让它更容易解释javap
output.
类似但更通用的问题:如何使用javap查看字节码中的哪些行与Java代码中的行相对应? https://stackoverflow.com/questions/26870826/how-to-use-javap-to-see-what-lines-of-bytecode-correspond-to-lines-in-the-java-c
我尝试过:
- 在以下位置创建功能请求:http://bugreport.java.com/submit_intro.do http://bugreport.java.com/submit_intro.do
- 发送电子邮件至邮件列表:
[email protected] /cdn-cgi/l/email-protection
但没有回复,我的消息甚至没有出现在那些网站上。不是一个非常开放的项目。
我不认为javap
支持这个用例,但过去几天我一直在研究一些类文件解析代码,截至今天,它能够将源代码与汇编代码混合。看https://github.com/gagern/classfile https://github.com/gagern/classfile了解详细信息和源代码。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)