JDK1.8 source code analysis of the idea to build 03 source code reading environment

Preamble: On a sequential read source said, have a general direction, we will know how to start. Next, it is necessary to build a source code easier to read and debug environment. Help call tracking source.

Current development of new projects, most of them are based on JDK1.8 development, so I chose this version of source code analysis.

JDK1.8 version number: jdk1.8.0_151

A. Where JDK1.8 in the src?

Find the JDK installation package directory, you will see src.zip archive, there is JDK source code, as shown below.

Two. Idea to build step

01. Create a simple Java project
to open the idea, the menu bar File => Project, appear as shown

In the Next point, Hello word a selected application initialization, appears below:

And then point Next, enter the project name, and save path:

Finally, the interface appears as follows:

02. The source src.zip extract to the src directory under the project

You think it enough? NO, NO, NO

After I import, run Main.java file inside, see if I can properly up and running, the results at compile time, there have been a variety of ERROR, xxx class and other issues can not be found.

Looked at so many errors, I have the intention to give up the idea. However, for the technology, I am a very stubborn person.

Simply thinking about it a problem, is not that I have not encountered it? If resolved, it is not yet increased knowledge.

Masochistic madness began my operation.

Xxx can not find such classes, you can go online to find related classes, added to it just fine. As long as there is not a conflict with the project JDK, they are okay.

The last question I have been simply resolved one by one, eventually succeeds.

III. Summary of issues build process

ERROR solve all kinds of ideas, to pave the way for future friends

I was a road worker.

Question 1: Missing com.sun.tools package

Solutions: File => Project Structure => the Libraries in the lib package jdk path added to the project, as shown below:

问题2:缺少sun.awt.UNIXToolkit 和 sun.font.FontConfigManager这两个类

解决思路: 在src的目录下手动添加这两个类

问题3:debug的时候,出现如下,调用的src.zip中的文件

解决思路: 排除掉src.zip文件,按下图操作即可。

问题4:debug的时候,误点Alternative source availble for the class xxxx 的disable

解决思路: 打开setting => Debugger, 如下图 选中该选项。

丑媳妇总要见公婆的。源码代码已经提交到github上, 欢迎大家fork和关注。

github: https://github.com/raysonfang/jdk1.8-source-analysis

刚起步,欢迎吐槽。争取打造成JDK源码分析系列资源合集,想学习JDK源码的, 就可以自行下载。

Guess you like

Origin www.cnblogs.com/werewolfBoy/p/11314400.html