系统环境为ubuntu 16.04,uname -a:

Linux ddy-Aspire-V5-573G 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

在本文中,要编译的openjdk版本为:openjdk-8u40-src-b25-10_feb_2015
尝试了编译openjdk-8-src-b132-03_mar_2014,但是失败。网上说,因为ubuntu16.04较新,但是该版本的JDK较老,所以失败。

下面说明编译过程。

make版本

OpenJDK8可以使用"config && make"编译构建,不再使用Ant和ALT_ *环境变量来配置构建。
不过需要GNU make 3.81或更新的版本

安装引导JDK

我使用的引导JDK是jdk-7u76-linux-x64

java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

安装编译工具类库:

#安装gcc、g++、make等
sudo apt-get install build-essential
#安装ant 1.7以上
sudo apt-get install ant
#安装XRender
sudo apt-get install libxrender-dev
sudo apt-get install xorg-dev
#安装alsa
sudo apt-get install libasound2-dev
#Cups
sudo apt-get install libcups2-dev
#安装零碎的工具包
sudo apt-get install gawk zip libxtst-dev libxi-dev libxt-dev

建立编译脚本

--with-boot-jdk:指定引导JDK所在目录,以防其他安装的JDK影响(本机上以前安装了JDK8,并配置了JAVA_HOME指向JDK8);
--with-target-bits:指定编译64位系统的JDK;

为可以进行源码调试,再指定下面三个参数:
--with-debug-level=slowdebug:指定可以生成最多的调试信息;
--enable-debug-symbols ZIP_DEBUGINFO_FILES=0:生成调试的符号信息,并且不压缩;
在openjdk目录下新建build.sh,内容如下:

cd openjdk
bash ./configure --with-target-bits=64 --with-boot-jdk=/usr/java/jdk1.7.0_80/ --with-debug-level=slowdebug --enable-debug-symbols ZIP_DEBUGINFO_FILES=0
make all ZIP_DEBUGINFO_FILES=0  

编译

执行./build.sh
编译完成是这样的:

用GDB测试是否能debug

ddy@ddy-Aspire-V5-573G ~/openjdk-compile/openjdk-8u40-src-b25-10_feb_2015/openjdk/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-ddy_2017_06_11_23_26-b00)
OpenJDK 64-Bit Server VM (build 25.40-b25-debug, mixed mode)
ddy@ddy-Aspire-V5-573G ~/openjdk-compile/openjdk-8u40-src-b25-10_feb_2015/openjdk/build/linux-x86_64-normal-server-slowdebug/jdk/bin $ export CLASSPATH=.:/home/
ddy/java_src
ddy@ddy-Aspire-V5-573G ~/openjdk-compile/openjdk-8u40-src-b25-10_feb_2015/openjdk/build/linux-x86_64-normal-server-slowdebug/jdk/bin $ gdb --args java FileChann
elTest
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from java...done.
(gdb) break init.cpp:95
No source file named init.cpp.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (init.cpp:95) pending.
(gdb) run
Starting program: /home/ddy/openjdk-compile/openjdk-8u40-src-b25-10_feb_2015/openjdk/build/linux-x86_64-normal-server-slowdebug/jdk/bin/java FileChannelTest
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff7fc8700 (LWP 9311)]
[Switching to Thread 0x7ffff7fc8700 (LWP 9311)]

Thread 2 "java" hit Breakpoint 1, init_globals ()
    at /home/ddy/openjdk-compile/openjdk-8u40-src-b25-10_feb_2015/openjdk/hotspot/src/share/vm/runtime/init.cpp:95
95  jint init_globals() {
(gdb) l
90    chunkpool_init();
91    perfMemory_init();
92  }
93
94
95  jint init_globals() {
96    HandleMark hm;
97    management_init();
98    bytecodes_init();
99    classLoader_init();
(gdb) quit
A debugging session is active.

    Inferior 1 [process 9307] will be killed.

Quit anyway? (y or n) y
ddy@ddy-Aspire-V5-573G ~/openjdk-compile/openjdk-8u40-src-b25-10_feb_2015/openjdk/build/linux-x86_64-normal-server-slowdebug/jdk/bin $ 

openjdk之编译经常出现的问题
openjdk7的编译和debug
编译主要参考:ubuntu14.04 编译openjdk7
debug主要参考:CentOS上编译OpenJDK8源码 以及 在eclipse上调试HotSpot虚拟机源码

openjdk8之编译和debug的更多相关文章

  1. openjdk7之编译和debug

    大家也可以看我的博客: openjdk7之编译和debug,这里格式更好. 为了更好的学习JDK.HotSpot等源码,需要能debug JDK.HotSpot等源码.本文主要讲述,怎么编译open ...

  2. vs2010 创建预编译头 Debug 正常 Release Link Error问题解决

    问题:创建预编译头 Debug 正常 Release Link Error Main.obj : error LNK2005: ___@@_PchSym_@00@UmfilkilqUdrmzkkUki ...

  3. 创建预编译头 Debug 正常 Release Link Error:预编译头已存在,使用第一个 PCH

    创建预编译头 Debug 正常 Release Link Error Main.obj : error LNK2005: ___@@_PchSym_@00@UmfilkilqUdrmzkkUkilqU ...

  4. VS2015 dlib编译 x64 Debug .lib生成

    VS2015 dlib编译 x64 Debug >------ 已启动生成: 项目: ZERO_CHECK, 配置: Debug x64 ------ > Checking Build S ...

  5. 如何在其他电脑上运行VS2005编译的DEBUG版应用程序

    做项目的过程中,遇到这样的问题:在自己的电脑上用VS2005编译好的DEBUG版程序在其它的没有安装VS2005的电脑上没有办法运行,郁闷至极啊. 直 接拷贝文件后,错误信息如下:"This ...

  6. 在用VC编译下debug和release的什么区别

    DEBUG和RELEASE 版本差异及调试相关问题:.         内存分配问题 1.          变量未初始化.下面的程序在debug中运行的很好. thing * search(thin ...

  7. Keil中使用宏编译来定义DEBUG输出

    使用宏编译来格式化调试信息,是一个不错的方法,即可以在需要的时候打印出信息,还可以格式化我们所需要的输出. #define DEBUG 1 #if (DEBUG == 1) #define DBG(A ...

  8. windows下vc编译和debug nginx

    总体来说,各个步骤以及版本参考官方文档http://nginx.org/en/docs/howto_build_on_win32.html一点没错,有些细节没说清楚. To build nginx: ...

  9. JVM-Ubuntu18.04.1下编译OpenJDK8

    近期开始学习JVM,看的是周老师的<深入理解Java虚拟机>,打算先自己编译个JDK来提升对JVM的兴趣.本文分三部分来描述编译OpenJDK的过程,分别是编译前准备工作.构建编译环境.进 ...

随机推荐

  1. 一个例子简要说明include和require的区别

    先编辑command.php文件 echo 'hello'.PHP_EOL; 然后编辑console.php文件 for($i=1;$i<=3;++$i){ require 'command1. ...

  2. PowerBI 第二篇:数据建模

    在分析数据时,不可能总是对单个数据表进行分析,有时需要把多个数据表导入到PowerBI中,通过多个表中的数据及其关系来执行一些复杂的数据分析任务,因此,为准确计算分析的结果,需要在数据建模中,创建数据 ...

  3. AOJ/初等排序习题集

    ALDS1_1_D-MaximumProfit. Codes: //#define LOCAL #include <cstdio> #include <algorithm> u ...

  4. DirectFB 之 环境配置

    1. 准备 directFB下载地址:http://www.directfb.org/index.php?path=Main%2FDownloads 本人采用的版本是DirectFB-1.5.3.ta ...

  5. Linux下安装单机版zookeeper(和dubbo配合验证)和redis(用图形化界面连接验证)

    上次写了篇zookeeper的集齐,并且用dubbo admin验证了集群结果.最近又特地装了个虚拟机,专门装各种单机版的,免得跟集群的机器混合了.安装的虚拟机IP为192.168.1.108 1.单 ...

  6. Kafka官方文档

    Apache Kafka是 一个分布式消息发布订阅系统.它最初由LinkedIn公司基于独特的设计实现为一个分布式的提交日志系统( a distributed commit log),,之后成为Apa ...

  7. jquery实现网页倒计时

    在毕设作品考试模块要做个倒计时,当时间到时自动结束答题.于是在jQuery插件社区找到一个简洁明了的倒计时.先上效果图. 感谢作者hacker(这是黑客的意思么),贴上地址:http://www.jq ...

  8. [原创]普通的MySQL多表连接查询

  9. 工具类总结---(三)---MD5加密

    用于给文件名等进行MD5加密: import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; / ...

  10. win彩 百款皮肤任选任换.可视化