Using IDEA to build JDK source reading environment

Using IDEA to build JDK source reading environment

First create a new java basic project

Basic Directory

source

test test source code and entry

Prepare JDK source code

The path framed in the following figure is the storage location of jdk

image-20200410092921547

Open the jdk directory, find src.zip, right click and unzip

image-20200410093244953

After decompression, enter the src folder, select java, javax, org and paste it into the source directory of the project

Attention please! Do not copy the window system in IDEA, but copy it directly between folders as shown in the figure below.

image-20200410103548221

image-20200410103635416

The source code is ready

Remove Debug restrictions

Uncheck single step to enter the bottom class

Replace SourcePath

The original source code is protected and cannot be commented out, so it is replaced with the source code in the source directory of the project

image-20200410110027447

image-20200410112649981

Write test code

public class Test {
    public static void main(String[] args) {
       StringBuffer stringBuffer = new StringBuffer();
       stringBuffer.append("可变序列");
       stringBuffer.append("123456");

       System.out.println(stringBuffer.toString());
       System.out.println(stringBuffer);
    }
}

The output of the two sentences is the same, I want to explore what happened at the bottom

Make a breakpoint before printing out

image-20200410112903513

Debug view the underlying source code

F7 single step into view

The 9th line of the above test code is a string, so print String directly, and then wrap

image-20200410113106684

The 10th line of the above test code is passed an object, then println will automatically convert the object into a string, and then output, and finally wrap.

image-20200410113312171

It is recommended to look at common modules first

package description Key class
lang Basic syntax, packaging type Basic types, reflection, annotations
useful Basic tools Common tools, JUC, atomic class, lock
I Blocking io Byte stream
nio Non-blocking io
math Basic mathematics, large numbers
time Date, time
net Telecommunication socket etc.

Guess you like

Origin www.cnblogs.com/1101-/p/12672488.html