Debugging jdk8 source code in idea

Difficulties in debugging jdk source code

1. Debug cannot view local variables

2. During learning, comments cannot be added.

With these two questions, let’s continue to look down.

Solve the problem of not being able to add comments

1. Open idea->select Project->File->Project Structure->SDKS->SourcePath as shown below


2. The two source code files currently seen added to the idea are .zip files. If you want to add comments to the source code, unzip the zip file and then rely on the unzipped file, as shown below.


In this way, you can add comments to the source code when debugging. Why not try it now!

Solve the problem of not being able to view local variables

Let me talk about it first, the version before jdk8 is different from the jdk8 method.

1. Unzip src.zip, create a project in eclipse, and import the unzipped file.

2. Delete the com\sun\java\swing and javax\swing packages, as well as the com\sun\source\util\JavacTask.java and com\sun\source\util\Plugin.java files.

3. Export project export->rt_debug.jar

3. Copy the rt_debug.jar package to JDK_HOME\jre\lib\endorsed. If there is no endorsed directory, create it yourself.

Explain: There is a directory called endorsed in the JAVA running environment, which allows you to put some special class libraries into it for project use.

Official description:

   Specifying the -Djava.endorsed.dirs=lib/endorsed system property on the Java command line will force the JVM to prefer any library  it finds in the endorsed directory over its own system libraries. Copying the jars into $JAVA_HOME/jre/lib/endorsed will do the same  thing.

   The general idea is: if you specify the directory containing special jar packages pointed to by the -D java.endorsed.dirs parameter when running the program, or copy those jars to the default $JAVA_HOME/jre/lib/endorsed Under contents. Then when the project is running, the virtual machine will give priority to using these jar packages. The priority is higher than the system class library that comes with the JDK, but the classes under the java.lang language package will be excluded.
So everyone knows the role of endorsed technology!


Guess you like

Origin blog.csdn.net/u011837804/article/details/80450809