当前位置:   article > 正文

《深入理解JAVA虚拟机 ● 第三版》MacOS编译OpenJDK12_深入理解java虚拟机第三版 密码

深入理解java虚拟机第三版 密码

编译环境

  • MacOS Catalina 10.15.4
  • Xcode 11.5
  • command line tools
  • Homebrew 2.2.5

编译准备

OpenJDK12源码下载

浏览器打开地址:https://hg.openjdk.java.net/jdk/jdk12/

点击左侧Browse,将显示源码根目录页面:
在这里插入图片描述
点击左侧bz2、zip、gz 中任意一个,即可下载压缩好的源码包。
在这里插入图片描述
如果下载较慢或者下载失败,可使用百度网盘下载。建议从官网下载,可以获取最新源码。
链接: OpenJDK12源码
提取密码: sbcf

安装JDK11

由于JDK源码中大部分代码还是采用JAVA语言实现,所以在编译前需要准备好另一个编译期可用的JDK,官方称此JDK为Bootstrap JDK。假设需要编译的JDK大版本号为N,我们必须准备好另外一个大版本号至少为N-1的JDK。

安装Xcode

App Store安装
在这里插入图片描述

安装command line tools

从App Store上下载的Xcode,默认是不会安装Command Line Tools的,Command Line Tools是在Xcode中的一款工具,可以在命令行中运行C程序。

打开终端,在终端中输入命令

xcode-select --install 
  • 1

安装完成后,在终端中执行 gcc -v 命令查看是否安装成功。
如果显示如下内容,则安装成功。

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
  • 1
  • 2
  • 3
  • 4
  • 5

安装Homebrew

进入Homebrew官网获取最新下载链接;
在这里插入图片描述
打开终端,运行拷贝的命令:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  • 1

执行过程中会要求输入密码,输入密码回车继续安装;

安装完成后,会出现 Installation successful! 字样,即安装成功。

终端运行如下命令,可查看安装的版本信息:

brew -v
  • 1

输出示例:

Homebrew 2.2.5
Homebrew/homebrew-core (git revision e6c5f; last commit 2020-02-09)
  • 1
  • 2

安装依赖库

打开终端,执行如下命令:

brew install ccache
brew install freetype
brew install autoconf
  • 1
  • 2
  • 3

编译JDK

编译参数

编译参数可通过在JDK源码目录下执行以下命令查询:

bash  configure --help
  • 1

查询结果示例如下:

`configure' configures OpenJDK openjdk to adapt to many kinds of systems.

Usage: /Users/fcc/Project/JDKSource/jdk12-06222165c35f/configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking ...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                     
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/212489
推荐阅读
相关标签
  

闽ICP备14008679号