How Eclipse debugs Debug JDK source code and display local variables

Source: Internet
Author: User

1 How debug debug JDK source code

Unable to enter the source code, most are line unavailable, need to set.

"Window"-"Preference"-"Java"-"Installed JREs"

Here you can see the Java environment that eclipse can use, using the default JRE (Java Runtime Environment), which is not supported for debugging and needs to be replaced by JDK (Java development Kit).

"Add"-"Next"-"Add JRE"

In "directory" Select the directory of the JDK installed on the machine, not the JRE. At this point, the JDK jar file will be selected by default in the JDK directory Src.zip as source, if not, manually set by itself.

Then, choose to use the JDK.

Then, use the JDK you just added in the project's "Build Path" to remove the default JRE reference.

End, the JDK source code can now be debugged in Debug.

2. How to display local variables during debug debugging

The reason for this is that Rt.jar does not have debug information in the JRE provided by Oracle:Orcale uses javac-g:none when compiling src, meaning that the Rt.jar can be reduced in size without any debugging information. If you want to debug the JDK properly, you can only recompile src.zip. Here is a description of the method for compiling src.zip.

    1. Create a new Java project "JDK" in Eclipse, then import "Archive File" in the SRC directory, select the source Src.zip import, and complete the directory structure as follows (without the compiler Error):

    2. Right-click the project Export ..., then exported as a jar package, named Rt_debug.jar:

    3. Modify the JRE settings for Eclipse, add Rt_debug.jar to the JRE, and move to the front:

    4. Finally, we look at the debug variable and see the value of the variable:

How Eclipse debugs Debug JDK source code and display local variables

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.