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
Open the jdk directory, find src.zip, right click and unzip
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.
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
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
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
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.
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. |