在Ubuntu 12.04 上编译调试 OpenJDK8

前言

现在看的资料都是编译 openjdk7 的,openjdk8好像已经 openjdk7 编译方式大一样,按照前辈的文章使用

make sanity

会提示找不到 sanity 规则,然后编译过程其实基本就直接

./configure
make all

官方的 README 写的很清楚。

下面记录下过程

下载代码

hg clone http://hg.openjdk.java.net/jdk8u/jdk8u jdk8u
cd jdk8u
bash ./get_source.sh

然后下载代码,进入代码目录:

cd jdk8u

安装依赖

sudo aptitude build-dep openjdk-7
sudo aptitude install openjdk-7-jdk

配置

  • 环境变量
export LANG=C
export PATH="/usr/lib/jvm/java-7-openjdk/bin:${PATH}"
  • 配置编译选项
bash ./configure

这样生成相应默认配置,如果有需要,比如想编译出调试版本的,可以给 configure 加参数。

A new configuration has been successfully created in
/home/minix/SourceCode/openjdk8/jdk8u/build/linux-x86-normal-server-release
using default settings.

Configuration summary:
* Debug level:    release
* JDK variant:    normal
* JVM variants:   server
* OpenJDK target: OS: linux, CPU architecture: x86, address length: 32

Tools summary:
* Boot JDK:       java version "1.7.0_17" Java(TM) SE Runtime Environment (build 1.7.0_17-b02) Java HotSpot(TM) Server VM (build 23.7-b01, mixed mode)  (at /home/minix/Software/jdk1.7.0_17)
* C Compiler:     gcc-4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5) version 4.6.3 (at /usr/bin/gcc-4.6)
* C++ Compiler:   g++-4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5) version 4.6.3 (at /usr/bin/g++-4.6)

Build performance summary:
* Cores to use:   3
* Memory limit:   3878 MB
* ccache status:  not installed (consider installing)

Build performance tip: ccache gives a tremendous speedup for C++ recompilations.
You do not have ccache installed. Try installing it.
You might be able to fix this by running ‘sudo apt-get install ccache‘.

可以看出提示缺少 ccache 包,按提示安装就可以了。从提示可以看出,编译级别是 release,另外还有几种编译级别,可以在调试时候提供更多的信息。例如:

bash ./configure --enable-debug

这样会生成 fastdebug 版本的配置信息:

A new configuration has been successfully created in
/home/minix/openjdk8/jdk8u/build/linux-x86-normal-server-fastdebug
using configure arguments ‘--enable-debug‘.

Configuration summary:
* Debug level:    fastdebug
* JDK variant:    normal
* JVM variants:   server
* OpenJDK target: OS: linux, CPU architecture: x86, address length: 32

Tools summary:
* Boot JDK:       java version "1.7.0_17" Java(TM) SE Runtime Environment (build 1.7.0_17-b02) Java HotSpot(TM) Server VM (build 23.7-b01, mixed mode)  (at /home/minix/Software/jdk1.7.0_17)
* C Compiler:     gcc-4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5) version 4.6.3 (at /usr/bin/gcc-4.6)
* C++ Compiler:   g++-4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5) version 4.6.3 (at /usr/bin/g++-4.6)

Build performance summary:
* Cores to use:   3
* Memory limit:   3878 MB
* ccache status:  installed and in use

注意编译的级别已经变成 fastdebug 了。

编译

编译直接

make

就可以了,如果提示

No CONF given, but more than one configuration found in /home/minix/openjdk8/jdk8u//build.
Available configurations:
* linux-x86-normal-server-fastdebug
* linux-x86-normal-server-release
Please retry building with CONF=<config pattern> (or SPEC=<specfile>)

需要指定使用哪个编译配置:

make CONF=linux-x86-normal-server-fastdebug

最后编译成功后,会提示:

----- Build times -------
Start 2014-08-22 10:56:52
End   2014-08-22 11:16:31
00:00:30 corba
00:13:38 hotspot
00:00:22 jaxp
00:00:30 jaxws
00:04:10 jdk
00:00:29 langtools
00:19:39 TOTAL

查看 build 目录,可以看到 linux-x86-normal-server-fastdebug

切换到 jdk/bin 目录:

cd linux-x86-normal-server-fastdebug/jdk/bin/

运行可执行文件 java

./java -version

会得到提示

openjdk version "1.8.0-internal-fastdebug"
OpenJDK Runtime Environment (build 1.8.0-internal-fastdebug-minix_2014_08_22_10_56-b00)
OpenJDK Server VM (build 25.40-b05-fastdebug, mixed mode)

调试

下面展示一个启动 GDB, 加断点,并运行一个 Java 程序的过程。

$ gdb java

GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 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 "i686-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/minix/openjdk8/jdk8u/build/fastdebug/jdk/bin/java...done.

(gdb) b main
Breakpoint 1 at 0x8048410: file /home/minix/openjdk8/jdk8u/jdk/src/share/bin/main.c, line 94.

(gdb) r -classpath PossibleReordering

Starting program: /home/minix/openjdk8/jdk8u/build/fastdebug/jdk/bin/java -classpath PossibleReordering
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".

Breakpoint 1, main (argc=3, argv=0xbfffeca4)
    at /home/minix/openjdk8/jdk8u/jdk/src/share/bin/main.c:94

时间: 2024-08-03 17:31:46

在Ubuntu 12.04 上编译调试 OpenJDK8的相关文章

在Ubuntu 12.04上配置iSCSI Target服务

  今天自己按照网上搜来的教程自己在Ubuntu 12.04上配置了iSCSI Target服务,在这里简单地做个纪录.操作系统是全新安装的Ubuntu 12.04,配置一块500 GB的SATA笔记本硬盘.安装操作系统时将硬盘划分为两个分区,其中一个50 GB的分区(/dev/sda1)挂载为操作系统的根分区:另外一个450 GB的分区(/dev/sda2)作为提供存储服务的空间,暂时不挂载. 安装完操作系统之后,安装必要的软件: $ sudo apt-get install chkconfi

在 Ubuntu 12.04 上通过安装源安装 Open vSwitch (OVS)

先把Ubuntu 12.04更新一下 sudo apt-get update sudo apt-get upgrade sudo apt-get dist-upgrade 删除 Ebtables包 sudo aptitude purge ebtables 从安装源安装Open vSwitch (OVS) sudo apt-get install aptitude apt-show-versions openvswitch-controller openvswitch-brcompat openv

转【翻译】如何在Ubuntu 12.04上配置Apache SSL证书

关于SSL证书 SSL证书是加密站点信息和创建一个更安全的连接的一种方式.另外,证书可以向站点访问者展示VPS的身份信息.证书颁发机构颁发SSL证书,用来验证服务器的详细信息,而一个自签名的证书缺乏第三方机构的证明. 设置 以下教程,需要拥有VPS上root权限. 另外,你的虚拟服务器上需要安装并运行有apache.如果没有安装,可以通过以下命令安装: sudo apt-get install apache2 第一步--启用SSL模块 下一步启用SSL sudo a2enmod ssl 紧接着重

在Ubuntu Server14.04上编译Android6.0源码

此前编译过Android4.4的源码,但是现在Android都到了7.0的版本,不禁让我感叹Google的步伐真心难跟上,趁这周周末时间比较充裕,于是在过去的24小时里,毅然花了9个小时编译了一把Android6.0的源码,但是昨天编译完之后已经很晚了,没来得及记录编译的步骤,今天才慢悠悠地来记录一下我在Ubuntu Server14.04上编译Android6.0源码的步骤.好了,废话不多说,我们开始吧! 步骤一: 安装Ubuntu系统.我们既可以通过虚拟机的方式安装Ubuntu,也可以直接在

ubuntu 12.04上安装HBase并运行

Ubuntu 12.04上安装HBase并运行 作者:凯鲁嘎吉 - 博客园 http://www.cnblogs.com/kailugaji/ 一.HBase的安装 在官网上下载HBase-1.1.2,将其解压到/home/wrr文件夹下 配置环境变量 [email protected]:~$ sudo gedit ~/.bashrc [sudo] password for wrr: [email protected]:~$ source ~/.bashrc 在.bashrc文件最后添加 exp

在 Ubuntu 12.04 上通过源代码安装 Open vSwitch (OVS)

安装 Ubuntu 12.04, 并且更新系统 apt-getupdate; apt-getupgrade; 安装所需的package apt-get install automake autoconf gcc uml-utilities libtool build-essential pkg-config linux-headers-`uname –r` 下载Open vSwich的源码包 wget http://openvswitch.org/releases/openvswitch-1.1

在 Ubuntu 12.04 上安装 GitLab7.x

安装环境: 操作系统:    Ubuntu 12.4 LTS 英文 数据库:        postgresql web服务器: nginx 可以说到7.x的时候,GitLab的文档已经相当完善了!此文作为翻译和部分FAQ. 1. 安装依赖包 (1) 设置默认文本编辑器 使用Vim作为默认文本编辑器 sudo apt-get install -y vim sudo update-alternatives --set editor /usr/bin/vim.basic (2) 安装依赖 sudo

Ubuntu 16.04上编译SkyEye的测试程序

一.首先确保Ubuntu系统上已经安装了Skyeye.skyeye-testsuite和arm-linux-gcc交叉编译工具链,如果没有安装请参考: 1.Skyeye的安装:http://www.cnblogs.com/softhal/p/5697500.html 2.arm-linux-gcc的安装:http://www.cnblogs.com/softhal/p/5699381.html 二.编译skyeye-testsuite中的例子: 1.进入skyeye-testsuite的安装目录

【转】在Ubuntu 12.04 上为Virtualbox 启用USB 设备支持--不错

原文网址:http://www.cnblogs.com/ericsun/archive/2013/06/10/3130679.html 虚拟机我一直在用,不是说离不开Windows,而是有些时候一些应用在Windows 下体验确实要好一点,比如 Tencent QQ. 最近我找到了我失踪久矣的10moons 左轮摄像头,那还是我在北京念书的时候,在中关村买的.当时花了我100块RMB. 找到后甚是感触,于是便打算给我的虚拟机里面的QQ用起来. 众所周知,VirtualBox 使用宿主机的USB设