How can I determine for any Java .class file if that was compiled with debug info or not?
How can I tell exactly what -g{source|lines|vars} option was used?
To check if there's debug info inside the kernel object, you can add the following at the end of the objdump command: | grep debug . If this string is found, you know the kernel object contains debug information. If not, then it's a "clean" kernel object.
A Java class file is a compiled java file. It is compiled by the Java compiler into bytecode to be executed by the Java Virtual Machine.
There are two ways to debug a class file. The first way is to set the decompiler preference, and to realign the line number. The second way is to check the debug mode in the decompiler menu bar. When your Eclipse workspace is in debug perspective, the debug mode becomes the default.
A simple way to see what String literals are used in a ". class" file is to use the javap utility in your JDK installation to dump the file using the "-v" option. Then grep for text that looks like <String "..."> where ... is the String you are looking for.
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
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{ ...
Programmatically, I'd look at ASM rather than writing yet another bytecode reader.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With