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: