How Eclipse Debug Debugging JDK source code

Source: Internet
Author: User

Java is an open source programming language, like to study the source of Java developers will not be tempted to debug the JDK source code. While the official JDK has its own source pack src.zip, it is cumbersome to view variables while in Debug. For example, when you debug the public V-put (K key, V value) method of HashMap and view the value of the key, you will be prompted:

You can see that the value of the variable cannot be displayed because the JRE in Oracle provides RT.JAR without debug information: Orcale uses javac-g:none when compiling src, meaning that it can reduce the size of Rt.jar without any debugging information. If you want to debug the JDK properly, you can only recompile src.zip. This article introduces the method of compiling src.zip.

Create a new Java project "JDK" in Eclipse, then import "Archive File" on the src directory, select source Src.zip Import, guide the directory structure as follows (do not compile error):

Right key project Export ..., then export as Jar package, named Rt_debug.jar:

Modify Eclipse's JRE settings, add Rt_debug.jar to the JRE, and move to the front:

Finally, look at the debug variable, and you can see the value of the variable:

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.