下载主线版本openjdk源码
git clone /openjdk/
- 1
boot jdk选择
主线版本的jdk选择boot jdk不同于LTS版本。她需要选择一个与他当前最近的一个jdk才可以配置通过。打比方我的jdk版本当前是Oracle JDK17,而主线版本是20+。所以使用如下命令配置的时候就会报错。
sh configure --with-debug-level=slowdebug --disable-warnings-as-errors --disable-javac-server
// 报错为
configure: (Your Boot JDK version must be one of: 18 19 20)
- 1
- 2
- 3
- 4
下载最新jdk的编译环境并重新配置
这里我们选择下载最新的openjdk版本。
/20/
sh configure --with-debug-level=slowdebug --disable-warnings-as-errors --disable-javac-server --with-boot-jdk=/Users/rockjiang/jdk_source//Contents/Home
- 1
编译
make
make images
- 1
- 2
IDE
这块我们还使用老方法:
make compile-commands
Building target 'compile-commands' in configuration 'macosx-x86_64-server-slowdebug'
Cleaning compile-commands make support artifacts ... done
Updating compile_commands.json
Finished building target 'compile-commands' in configuration 'macosx-x86_64-server-slowdebug'
- 1
- 2
- 3
- 4
- 5
使用clion打开刚刚编译好的文件。在build目录下。
jdk/build/macosx-x86_64-server-slowdebug/compile_commands.json
这个时候要注意等待一下所以完成。等到索引完成了。你是看不到源码的。我们需要更改项目根目录。
工具栏:Tools -> Compilation Database -> Change Project Root
最后选择我们从git上下载的根目录即可。jdk这个目录就可以了。
到这里图形化编辑工具就可以打开了。对应的代码中的方法,变量的鼠标左键+Ctrl跳转也已经对接完成。其他的跟我之前的文章是一样一样的。