How to compile JDK API source with debug info?

JDK API’s are compiled without debug info to save of space requirements, which means when debugging inside them the debugger cannot find local variable information to show during the debugging session.

It’s quite easy to compile the source and create a similar rt.jar to be used for debugging. Let’s see the steps.

Option 1: Add files and let IDE compile it

One way to extract the that ships with your distribution in a folder, create a project (in Eclipse of IntelliJ) and compile it. Once the project is build, create a jar and add it to jre/lib/endorsed directory (create if not present)

Option 2: Using an Apache Ant build

We can use Apache Ant to create the jar as well. The details are described here

Alternative way: without creating a jar

If you don’t want to do the jar thing and use IntelliJ, you can use the feature provided by IntelliJ. Go to Preference -> Build, Execution and Deployment -> Compiler -> Java Compiler, and uncheck the “Generate debugging info” like as shown in image below. This shall force IntelliJ to predict the variables like slot and display the debugging info. IntelliJ in most instances is able to decipher the name of the variables as well.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.