How Eclipse debugs debug JDK source code

Source: Internet
Author: User

Java is an open-source programming language, Java developers like to study the source will not be tempted to debug the JDK source code. Although the official JDK comes with the source package src.zip, it is cumbersome to view the variables at debug time. For example, debugging the public V put (K key, V value) method of HashMap and looking at the value of key will prompt:

You can see that the value of the variable cannot be displayed because 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

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.