Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if Java bytecode contains debug symbols

Tags:

java

bytecode

I would like to know how can I check if a compiled Java class contains debug symbols. The problem is that I compile an application from ant with debug="on", but a specific JVM throws an exception: it says that the debug symbols are missing.

Thanks.

like image 472
Laurențiu Dascălu Avatar asked Jun 30 '10 01:06

Laurențiu Dascălu


People also ask

How do I run Java in debug mode?

A Java program can be debugged simply by right clicking on the Java editor class file from Package explorer. Select Debug As → Java Application or use the shortcut Alt + Shift + D, J instead. Either actions mentioned above creates a new Debug Launch Configuration and uses it to start the Java application.

Do debug symbols affect performance?

Load time will be increased when the debug symbols are present over when not present. The on-disk footprint will be larger. If you compiled with zero optimization then you really lose nothing. If you set optimization, then the optimized code will be less optimized because of the debug symbols.

What is the meaning of debug symbols?

A debug symbol is a special kind of symbol that attaches additional information to the symbol table of an object file, such as a shared library or an executable.


2 Answers

If you run javap -v on the class file, you will see the debug information that is present in the file.

It is worth compiling a simple test class with different -g option settings and looking at the results with javap.

If, you need to know exactly how javap presents the information, it is it is best for you to try it out in your Java installation. The output from the javap command may vary between different Java versions.

like image 130
Stephen C Avatar answered Sep 23 '22 14:09

Stephen C


The most important thing a class file with debug information will contain is the LineNumberTable which maps bytecode instructions to source line numbers and the LocalVariableTable which tells the debugger where your local variables, including arguments to a method reside inside the VM during execution.

like image 45
Raindog Avatar answered Sep 21 '22 14:09

Raindog