确定 .class 文件是否使用调试信息编译? [英] Determine whether .class file was compiled with debug info?
本文介绍了确定 .class 文件是否使用调试信息编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何确定任何 Java .class 文件是否使用调试信息编译?
How can I determine for any Java .class file if that was compiled with debug info or not?
我怎样才能确切地知道使用了哪个 -g{source|lines|vars} 选项?
How can I tell exactly what -g{source|lines|vars} option was used?
推荐答案
如果您在命令行上,则 javap -l 将显示 LineNumberTable 和 LocalVariableTable(如果存在):
If you're on the command line, then javap -l will display LineNumberTable and LocalVariableTable if present:
peregrino:$ javac -d bin -g:none src/Relation.java
peregrino:$ javap -classpath bin -l Relation
public class Relation extends java.lang.Object{
public Relation();
peregrino:$ javac -d bin -g:lines src/Relation.java
peregrino:$ javap -classpath bin -l Relation
public class Relation extends java.lang.Object{
public Relation();
LineNumberTable:
line 1: 0
line 33: 4
peregrino:$ javac -d bin -g:vars src/Relation.java
peregrino:$ javap -classpath bin -l Relation
public class Relation extends java.lang.Object{
public Relation();
LocalVariableTable:
Start Length Slot Name Signature
0 5 0 this LRelation;
javap -c
将显示反编译开始时的源文件:
javap -c
will display the source file if present at the start of the decompilation:
peregrino:$ javac -d bin -g:none src/Relation.java
peregrino:$ javap -classpath bin -l -c Relation | head
public class Relation extends java.lang.Object{
...
peregrino:$ javac -d bin -g:source src/Relation.java
peregrino:$ javap -classpath bin -l -c Relation | head
Compiled from "Relation.java"
public class Relation extends java.lang.Object{
...
以编程方式,我会查看 ASM 而不是编写另一个字节码阅读器.
Programmatically, I'd look at ASM rather than writing yet another bytecode reader.
这篇关于确定 .class 文件是否使用调试信息编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文