确定.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屋!
查看全文