
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak cd /etc/apt/ sudo sed -i "s@http://.*archive.ubuntu.com@http://repo.huaweicloud.com@g" /etc/apt/sources.list sudo sed -i "s@http://.*security.ubuntu.com@http://repo.huaweicloud.com@g" /etc/apt/sources.list sudo apt-get update
git clone https://github.com/openjdk/jdk cd jdk git checkout jdk8-b119
wget https://repo.huaweicloud.com/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz tar -zxvf jdk-7u80-linux-x64.tar.gz mv jdk-7u80-linux-x64 jdk1.7
sudo apt install build-essential sudo apt install libfreetype6-dev sudo apt install libcups2-dev sudo apt install libx11-dev libxext-dev libxrender-dev libxrandr-dev libxtst-dev libxt-dev sudo apt install libasound2-dev sudo apt install libffi-dev sudo apt install autoconf sudo apt install ccache
编译文档:https://github.com/openjdk/jdk/blob/master/doc/building.md
cd ${openjdk8 home}
sudo bash configure --disable-ccache --with-debug-level=slowdebug --enable-debug-symbols ZIP_DEBUGINFO_FIELS=0 --with-boot-jdk=${jdk1.7 home}
sudo make images
## Finished images (build time 00:01:08) ----- Build times ------- Start 2021-09-29 15:36:01 End 2021-09-29 16:01:12 00:01:15 corba 00:00:51 demos 00:10:37 hotspot 00:01:08 images 00:00:37 jaxp 00:00:51 jaxws 00:07:25 jdk 00:01:54 langtools 00:00:33 nashorn 00:25:11 TOTAL ------------------------- Finished building OpenJDK for target 'images'
./build/linux-x86_64-normal-server-slowdebug/jdk/bin/java -version
openjdk version "1.8.0-internal-debug"
OpenJDK Runtime Environment (build 1.8.0-internal-debug-root_2021_09_29_15_35-b00)
OpenJDK 64-Bit Server VM (build 25.0-b61-debug, mixed mode)
vim Test.java
public class Test {
public static void main(String[] args) {
System.out.println(System.getProperty("user.home"));
System.out.println(System.getProperty("java.version"));
System.out.println(System.getProperty("os.name"));
}
}
./build/linux-x86_64-normal-server-slowdebug/jdk/bin/javac Test.java
./build/linux-x86_64-normal-server-slowdebug/jdk/bin/java Test
/home/test
1.8.0-internal-debug
Linux
异常1
check_os_version] Error 1 这个错误是因为不支持版本,这里先看看自己的内核版本 uname -r 我的内核版本是5.x vim hotspot/make/linux/Makefile SUPPORTED_OS_VERSION = 2.4% 2.5% 2.6% 3% 4% 5% 重新回到步骤5
异常2
top.make:91: ad_stuff] Error 2 这个错误是因为make参数的问题 vim hotspot/make/linux/makefiles/adjust-mflags.sh 大约67行的样子 s/ -([^ ][^ ]*)j/ -1 -j/ 改成(注意是大写的i, 而不是竖线) s/ -([^ I][^ ]*)j/ -1 -j/ 重新回到步骤5
异常3
cc1plus: all warnings being treated as errors 这个错误是因为gcc版本的问题 gcc版本控制在5.0以下 sudo apt install gcc-4.8 g++-4.8 如果出现Package 'gcc-4.8' has no installation candidate sudo vim /etc/apt/sources.list deb http://dk.archive.ubuntu.com/ubuntu xenial main deb http://dk.archive.ubuntu.com/ubuntu xenial universe sudo apt update 配置新安装的gcc 4.8的启动优先级为100 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 100 配置新安装的g++ 4.8的启动优先级为100 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 100 vim hotspot/make/linux/makefiles/gcc.make #WARNINGS_ARE_ERRORS = -Werror 重新回到步骤5
异常4
warning: [options] bootstrap class path not set in conjunction with -source 1.6 vim hotspot/make/linux/makefiles/rules.make BOOT_SOURCE_LANGUAGE_VERSION = 7 BOOT_TARGET_CLASS_VERSION = 7 重新回到步骤5