OpenJDK9在OSX平台下编译和调试

深入理解Java虚拟机一书中编译OpenJDK出现各种奇怪的错误,在这里集中做一下说明,以便日后查看。

Quick Start

安装hg

1
brew install hg

下载OpenJDK源码

1
hg clone http://hg.openjdk.java.net/jdk9/dev

安装freetype

1
brew install freetype

安装libffi(可选)

如果需要使用zero解释器,需要安装libffi

1
brew install libffi

configure

1
2
3
4
5
6
7
bash configure --with-debug-level=slowdebug \
--with-freetype=/usr/local/opt/freetype \
--disable-warnings-as-errors \
--with-jvm-features=zero \
--with-jvm-variants=zero \
--with-libffi=/usr/local/opt/libffi \
--with-libffi-include=/usr/local/Cellar/libffi/3.0.13/lib/libffi-3.0.13/include

–with-debug-level

设置调试级别,设成 slow debug 可以提供更多的调试信息

–with-free-type

设置 free type 路径

–disable-warnings-as-errors

忽略警告

–with-jvm-features

设置使用 c++ 实现的 zero 解释器,比基于模版的解释器更容易调试(如果汇编功力不够的话)

–with-jvm-variants

配合 –with-jvm-features 使用

–with-libffi

配合 –with-jvm-features 使用

–with-libffi-include

设置 libffi include 文件夹路径

make

1
make

Others

在实际编译过程中出现了错误信息:

1
error: ordered comparison between pointer and zero ('char *' and 'int')

将代码> 0或者>=0部分改为!= NULL继续编译即可通过。

结束

编译成功后,测试:

1
~/build/***/jdk/bin/java -version
Fiveplus wechat
扫一扫上方二维码,关注微信公众号:阿五编程
如果这篇文章对你有所帮助,请点击下方的打赏按钮。