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.
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 and display local variables