MacOS 编译OpenJDK13

官方说明 :

  1. Get the complete source code:
    hg clone http://hg.openjdk.java.net/jdk/jdk

  2. Run configure:
    bash configure

    If configure fails due to missing dependencies (to either the toolchainbuild toolsexternal libraries or the boot JDK), most of the time it prints a suggestion on how to resolve the situation on your platform. Follow the instructions, and try running bash configure again.

  3. Run make:
    make images

  4. Verify your newly built JDK:
    ./build/*/images/jdk/bin/java -version

  5. Run basic tests:
    make run-test-tier1

  6.  

如何构建,可以查看里面的文档说明: doc/building.html

 

 

============  以下为操作实例 ==============================================

 

1. 准备安装环境:

 

1.首先需要准备一个Xcode

我用的是Xcode9.4.1 版本 .  [如果用其他高版本尚未测试.我编译OpenJDK10的时候是报错的.]

官方下载地址:   https://developer.apple.com/download/more/

网盘下载地址:    https://pan.baidu.com/s/1yp0eqLJtHV0X-ppcxeUewg  密码:nnlt

 

2.JDK版本要求 12 或者13

 

3. brew 这个命令我就不说了, 去查一下,怎么安装.

brew install freetype ccache

brew install mercurial

 

在命令行输入 hg 命令有如下输出:

 

2.拉取源码包:

 

git clone  git@github.com:openjdk/jdk13u.git

注: 这个超级难下载,易炸毛.   不过比 hg 下载容易多了...

下载完的目录:

 

3.配置参数

 

接下来配置编译参数,以下是相关选项说明

  • --with-debug-level=slowdebug 启用slowdebug级别调试
  • --enable-dtrace 启用dtrace
  • --with-jvm-variants=server 编译server类型JVM
  • --with-target-bits=64 指定JVM为64位
  • --enable-ccache 启用ccache,加快编译
  • --with-num-cores=8 编译使用CPU核心数
  • --with-memory-size=8000 编译使用内存
  • --disable-warnings-as-errors 忽略警告  , mac 使用 xcode 编译, 官方要求加上这个参数.
  • --with-freetype  设置freetype的路径, 这个路径必须为你机器上的路径,记得修改 !!!! 

 

$ bash configure --with-debug-level=slowdebug --enable-dtrace --with-jvm-variants=server --with-target-bits=64 --enable-ccache --with-num-cores=4 --with-memory-size=8000 --disable-warnings-as-errors

编译完输出:

 

A new configuration has been successfully created in
/workspace/openjdk-13/build/macosx-x86_64-server-slowdebug
using configure arguments '--with-debug-level=slowdebug --enable-dtrace --with-jvm-variants=server --with-target-bits=64 --enable-ccache --with-num-cores=4 --with-memory-size=8000 --disable-warnings-as-errors'.

Configuration summary:
* Debug level:    slowdebug
* HS debug level: debug
* JVM variants:   server
* JVM features:   server: 'aot cds cmsgc compiler1 compiler2 dtrace epsilongc g1gc graal jfr jni-check jvmci jvmti management nmt parallelgc serialgc services shenandoahgc vm-structs'
* OpenJDK target: OS: macosx, CPU architecture: x86, address length: 64
* Version string: 13.0.4-internal+0-adhoc.sysadmin.openjdk-13 (13.0.4-internal)

Tools summary:
* Boot JDK:       java version "13.0.2" 2020-01-14 Java(TM) SE Runtime Environment (build 13.0.2+8) Java HotSpot(TM) 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)  (at /Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home)
* Toolchain:      clang (clang/LLVM from Xcode 9.4.1)
* C Compiler:     Version 9.1.0 (at /usr/bin/clang)
* C++ Compiler:   Version 9.1.0 (at /usr/bin/clang++)

Build performance summary:
* Cores to use:   4
* Memory limit:   8000 MB
* ccache status:  Active (3.7.10)

 

 

 

执行编译

$ make images

Creating support/demos/image/jfc/CodePointIM/CodePointIM.jar
Creating support/demos/image/jfc/FileChooserDemo/FileChooserDemo.jar
Creating support/demos/image/jfc/SwingSet2/SwingSet2.jar
Creating support/demos/image/jfc/Font2DTest/Font2DTest.jar
Creating support/demos/image/jfc/J2Ddemo/J2Ddemo.jar
Creating support/demos/image/jfc/Metalworks/Metalworks.jar
Creating support/demos/image/jfc/Notepad/Notepad.jar
Creating support/demos/image/jfc/Stylepad/Stylepad.jar
Creating support/demos/image/jfc/SampleTree/SampleTree.jar
Creating support/demos/image/jfc/TableExample/TableExample.jar
Creating support/demos/image/jfc/TransparentRuler/TransparentRuler.jar
Creating jdk image
Creating CDS archive for jdk image
Stopping sjavac server
Finished building target 'images' in configuration 'macosx-x86_64-server-slowdebug'

 

 

测试

编译后的jdk目录: /workspace/openjdk-13/build/macosx-x86_64-server-slowdebug/jdk

$ ./build/*/images/jdk/bin/java -version

bogon:openjdk-13 sysadmin$
bogon:openjdk-13 sysadmin$ ./build/*/images/jdk/bin/java -version
openjdk version "13.0.4-internal" 2020-07-14
OpenJDK Runtime Environment (slowdebug build 13.0.4-internal+0-adhoc.sysadmin.openjdk-13)
OpenJDK 64-Bit Server VM (slowdebug build 13.0.4-internal+0-adhoc.sysadmin.openjdk-13, mixed mode, sharing)
bogon:openjdk-13 sysadmin$
bogon:openjdk-13 sysadmin$

 

 

 

参考:

https://zhangboyi.blog.csdn.net/article/details/89207433

https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms

https://github.com/openjdk/jdk13u

 

 

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 适合毕业设计、课程设计作业。这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。 所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值