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.
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):
Right-click the project Export ..., then exported as a jar package, named Rt_debug.jar:
Modify the JRE settings for Eclipse, add Rt_debug.jar to the JRE, and move to the front:
Finally, we look at the debug variable and see the value of the variable:
How Eclipse debugs debug JDK source code