【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>
java开发一阵子了,想深入了解下jvm,所以在ubuntu下本地编译学习一下openjdk代码
1,java虚拟机有很多不稳定参数,以xx开头可以使用java -XX:+PrintFlagsFinal 查看;
2,编译java
下载open jdk 源码;http://download.java.net/openjdk/jdk8/
放到ubuntu 虚拟机,解压,根据readme.build操作
configure: error: Could not find freetype! You might be able to fix this by running 'sudo apt-get install libfreetype6-dev'.
安装完依然这个鸟样。FUCK!最近工作忙,找个时间继续
--------------------------------------
开始重编译一次
1,在ubuntu 14.04 64b,先安装需要的软件
sudo apt-get install build-essential gawk m4 libasound2-dev libxrender-dev xorg-dev xutils-dev x11proto-print-dev binutils libmotif3 libmotif-dev ant
2,下载openjdk,1.7 http://www.java.net/download/openjdk/jdk7u40/promoted/b43/openjdk-7u40-fcs-src-b43-26_aug_2013.zip
下载上传服务器,解压缩;
3,
make sanity
----------------------------------------------
ERROR: You do not have access to valid Cups header files.
Please check your access to
/usr/include/cups/cups.h
and/or check your value of ALT_CUPS_HEADERS_PATH,
CUPS is frequently pre-installed on many systems,
or may be downloaded from http://www.cups.org
安装解决:sudo apt-get install libcups2-dev
ERROR: HOTSPOT_SERVER_PATH does not point to a valid HotSpot VM.
Please check your access to
/NOT-SET/re/jdk/1.7.0/promoted/latest/binaries/linux-amd64/jre/lib/amd64/server/libjvm.so
and/or check your value of ALT_HOTSPOT_SERVER_PATH.
执行目录不对,应该在open jdk根目录运行
运行后显示:Sanity check passed.
运行命令:make
/jvm/openjdk/langtools/make/build.xml:860: Error running /usr/lib/jvm/java-7-openjdk-amd64/bin/javac compiler
安装openjdk sudo apt-get install openjdk-7-jdk
再运行命令:
make ALT_BOOTDIR=/usr/lib/jvm/jdk1.7.0_80
开始编译
/bin/sh: 2: zip: not found
apt-get install zip
再运行命令: make ALT_BOOTDIR=/usr/lib/jvm/jdk1.7.0_80
再报错
make[5]: Entering directory `/jvm/openjdk/build/linux-amd64/hotspot/outputdir'
>&2 echo "*** This OS is not supported:" `uname -a`; exit 1;
*** This OS is not supported: Linux 466e7b25085c 4.4.52-1.el7.elrepo.x86_64 #1 SMP Sun Feb 26 08:48:14 EST 2017 x86_64 x86_64 x86_64 GNU/Linux
make[5]: *** [check_os_version] Error 1
make[5]: Leaving directory `/jvm/openjdk/build/linux-amd64/hotspot/outputdir'
make[4]: *** [linux_amd64_compiler2/debug] Error 2
make[4]: Leaving directory `/jvm/openjdk/build/linux-amd64/hotspot/outputdir'
make[3]: *** [generic_build2] Error 2
make[3]: Leaving directory `/jvm/openjdk/hotspot/make'
make[2]: *** [product] Error 2
make[2]: Leaving directory `/jvm/openjdk/hotspot/make'
make[1]: *** [hotspot-build] Error 2
make[1]: Leaving directory `/jvm/openjdk'
make: *** [build_product_image] Error 2
真是日了狗了,原来是hot spot makefile版本指定太低,
修改文件/jvm/openjdk/hotspot/make/linux# vi Makefile
SUPPORTED_OS_VERSION = 2.4% 2.5% 2.6% 3% 这后面添加自己的linux版本 4%
继续 make 命令:make ALT_BOOTDIR=/usr/lib/jvm/java-7-openjdk-amd64
程序开始正常编译,过了大约5-6分钟,又报错:
Using java runtime at
Error occurred during initialization of VM
java.lang.NullPointerException
at java.util.Hashtable.hash(Hashtable.java:262)
at java.util.Hashtable.remove(Hashtable.java:585)
at java.lang.System.initProperties(Native Method)
at java.lang.System.initializeSystemClass(System.java:1119)
真是日了狗了,这个明显是代码空指针异常,更改使用jdk1.6
make ALT_BOOTDIR=/jvm/jdk1.6.0_45
注:此处至少说明oracle jdk和openjdk 此处文件
java.lang.System.initializeSystemClass(System.java:1119)有较大改动。
编译通过,继续往下走:
又报错:
/jvm/jdk1.6.0_45/bin/java -XX:-PrintVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-LogVMOutput -Xmx512m -Xms512m -XX:PermSize=32m -XX:MaxPermSize=160m -jar /jvm/openjdk/build/linux-amd64/btjars/generatecurrencydata.jar -o /jvm/openjdk/build/linux-amd64/lib/currency.data.temp \
< ../../../src/share/classes/java/util/CurrencyData.properties
Error: time is more than 10 years from present: 1136059200000
java.lang.RuntimeException: time is more than 10 years from present: 1136059200000
at build.tools.generatecurrencydata.GenerateCurrencyData.makeSpecialCaseEntry(GenerateCurrencyData.java:285)
at build.tools.generatecurrencydata.GenerateCurrencyData.buildMainAndSpecialCaseTables(GenerateCurrencyData.java:225)
at build.tools.generatecurrencydata.GenerateCurrencyData.main(GenerateCurrencyData.java:154)
make[4]: *** [/jvm/openjdk/build/linux-amd64/lib/currency.data] Error 1
make[4]: Leaving directory `/jvm/openjdk/jdk/make/java/java'
时间过长?查看文件,发现如下注释:
# Mappings from ISO 3166 country codes to ISO 4217 currency codes.
#
# Three forms are used:
# Form 1: <country code>=<currency code>
# Form 2: <country code>=<currency code 1>;<time stamp>;<currency code 2>
# Form 3: <country code>=
# Form 1 is used if no future change in currency is known.
# Form 2 indicates that before the specified time currency 1 is used, from
# the specified time currency 2. The time is given in SimpleDateFormat's
# yyyy-MM-dd-HH-mm-ss format in the GMT time zone.
# Form 3 indicates the country doesn't have a currency (the entry is still
# needed to verify that the country code is valid).
修改文件如下:
#
# Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
formatVersion=1
# Version of the currency code information in this class.
# It is a serial number that accompanies with each amendment, such as
# 'MAxxx.doc'
dataVersion=151
# List of all valid ISO 4217 currency codes.
# To ensure compatibility, do not remove codes.
all=ADP020-AED784-AFA004-AFN971-ALL008-AMD051-ANG532-AOA973-ARS032-ATS040-AUD036-\
AWG533-AYM945-AZM031-AZN944-BAM977-BBD052-BDT050-BEF056-BGL100-BGN975-BHD048-BIF108-\
BMD060-BND096-BOB068-BOV984-BRL986-BSD044-BTN064-BWP072-BYB112-BYR974-\
BZD084-CAD124-CDF976-CHF756-CLF990-CLP152-CNY156-COP170-CRC188-CSD891-CUP192-CUC931-\
CVE132-CYP196-CZK203-DEM276-DJF262-DKK208-DOP214-DZD012-EEK233-EGP818-\
ERN232-ESP724-ETB230-EUR978-FIM246-FJD242-FKP238-FRF250-GBP826-GEL981-\
GHC288-GHS936-GIP292-GMD270-GNF324-GRD300-GTQ320-GWP624-GYD328-HKD344-HNL340-\
HRK191-HTG332-HUF348-IDR360-IEP372-ILS376-INR356-IQD368-IRR364-ISK352-\
ITL380-JMD388-JOD400-JPY392-KES404-KGS417-KHR116-KMF174-KPW408-KRW410-\
KWD414-KYD136-KZT398-LAK418-LBP422-LKR144-LRD430-LSL426-LTL440-LUF442-\
LVL428-LYD434-MAD504-MDL498-MGA969-MGF450-MKD807-MMK104-MNT496-MOP446-MRO478-\
MTL470-MUR480-MVR462-MWK454-MXN484-MXV979-MYR458-MZM508-MZN943-NAD516-NGN566-\
NIO558-NLG528-NOK578-NPR524-NZD554-OMR512-PAB590-PEN604-PGK598-PHP608-\
PKR586-PLN985-PTE620-PYG600-QAR634-ROL946-RON946-RSD941-RUB643-RUR810-RWF646-SAR682-\
SBD090-SCR690-SDD736-SDG938-SEK752-SGD702-SHP654-SIT705-SKK703-SLL694-SOS706-\
SRD968-SRG740-STD678-SVC222-SYP760-SZL748-THB764-TJS972-TMM795-TMT934-TND788-TOP776-\
TPE626-TRL792-TRY949-TTD780-TWD901-TZS834-UAH980-UGX800-USD840-USN997-USS998-\
UYU858-UZS860-VEB862-VEF937-VND704-VUV548-WST882-XAF950-XAG961-XAU959-XBA955-\
XBB956-XBC957-XBD958-XCD951-XDR960-XFO000-XFU000-XOF952-XPD964-XPF953-\
XPT962-XSU994-XTS963-XUA965-XXX999-YER886-YUM891-ZAR710-ZMK894-ZWD716-ZWL932-ZWN942-ZWR935
# Mappings from ISO 3166 country codes to ISO 4217 currency codes.
#
# Three forms are used:
# Form 1: <country code>=<currency code>
# Form 2: <country code>=<currency code 1>;<time stamp>;<currency code 2>
# Form 3: <country code>=
# Form 1 is used if no future change in currency is known.
# Form 2 indicates that before the specified time currency 1 is used, from
# the specified time currency 2. The time is given in SimpleDateFormat's
# yyyy-MM-dd-HH-mm-ss format in the GMT time zone.
# Form 3 indicates the country doesn't have a currency (the entry is still
# needed to verify that the country code is valid).
#
# The table is based on the following web sites:
# http://www.din.de/gremien/nas/nabd/iso3166ma/codlstp1/db_en.html
# http://www.bsi-global.com/iso4217currency
# http://www.cia.gov/cia/publications/factbook/indexgeo.html
# AFGHANISTAN
AF=AFN
# \u00c5LAND ISLANDS
AX=EUR
# ALBANIA
AL=ALL
# ALGERIA
DZ=DZD
# AMERICAN SAMOA
AS=USD
# ANDORRA
AD=EUR
# ANGOLA
AO=AOA
# ANGUILLA
AI=XCD
# ANTARCTICA
AQ=
# ANTIGUA AND BARBUDA
AG=XCD
# ARGENTINA
AR=ARS
# ARMENIA
AM=AMD
# ARUBA
AW=AWG
# AUSTRALIA
AU=AUD
# AUSTRIA
AT=EUR
# AZERBAIJAN
AZ=AZM;2015-12-31-20-00-00;AZN
# BAHAMAS
BS=BSD
# BAHRAIN
BH=BHD
# BANGLADESH
BD=BDT
# BARBADOS
BB=BBD
# BELARUS
BY=BYR
# BELGIUM
BE=EUR
# BELIZE
BZ=BZD
# BENIN
BJ=XOF
# BERMUDA
BM=BMD
# Bonaire, Sint Eustatius and Saba
BQ=USD
# BHUTAN
BT=BTN
# BOLIVIA
BO=BOB
# BOSNIA AND HERZEGOVINA
BA=BAM
# BOTSWANA
BW=BWP
# BOUVET ISLAND
BV=NOK
# BRAZIL
BR=BRL
# BRITISH INDIAN OCEAN TERRITORY
IO=USD
# BRUNEI DARUSSALAM
BN=BND
# BULGARIA
BG=BGN
# BURKINA FASO
BF=XOF
# BURUNDI
BI=BIF
# CAMBODIA
KH=KHR
# CAMEROON
CM=XAF
# CANADA
CA=CAD
# CAPE VERDE
CV=CVE
# CAYMAN ISLANDS
KY=KYD
# CENTRAL AFRICAN REPUBLIC
CF=XAF
# CHAD
TD=XAF
# CHILE
CL=CLP
# CHINA
CN=CNY
# CHRISTMAS ISLAND
CX=AUD
# COCOS (KEELING) ISLANDS
CC=AUD
# COLOMBIA
CO=COP
# COMOROS
KM=KMF
# CONGO
CG=XAF
# CONGO, THE DEMOCRATIC REPUBLIC OF THE
CD=CDF
# COOK ISLANDS
CK=NZD
# COSTA RICA
CR=CRC
# COTE D'IVOIRE
CI=XOF
# CROATIA
HR=HRK
# CUBA
CU=CUP
# Cura\u00e7ao
CW=ANG
# CYPRUS
CY=EUR
# CZECH REPUBLIC
CZ=CZK
# DENMARK
DK=DKK
# DJIBOUTI
DJ=DJF
# DOMINICA
DM=XCD
# DOMINICAN REPUBLIC
DO=DOP
# ECUADOR
EC=USD
# EGYPT
EG=EGP
# EL SALVADOR
# USD is also legal currency as of 2001/01/01
SV=SVC
# EQUATORIAL GUINEA
GQ=XAF
# ERITREA
ER=ERN
# ESTONIA
EE=EUR
# ETHIOPIA
ET=ETB
# FALKLAND ISLANDS (MALVINAS)
FK=FKP
# FAROE ISLANDS
FO=DKK
# FIJI
FJ=FJD
# FINLAND
FI=EUR
# FRANCE
FR=EUR
# FRENCH GUIANA
GF=EUR
# FRENCH POLYNESIA
PF=XPF
# FRENCH SOUTHERN TERRITORIES
TF=EUR
# GABON
GA=XAF
# GAMBIA
GM=GMD
# GEORGIA
GE=GEL
# GERMANY
DE=EUR
# GHANA
GH=GHS
# GIBRALTAR
GI=GIP
# GREECE
GR=EUR
# GREENLAND
GL=DKK
# GRENADA
GD=XCD
# GUADELOUPE
GP=EUR
# GUAM
GU=USD
# GUATEMALA
GT=GTQ
# GUERNSEY
GG=GBP
# GUINEA
GN=GNF
# GUINEA-BISSAU
GW=XOF
# GUYANA
GY=GYD
# HAITI
HT=HTG
# HEARD ISLAND AND MCDONALD ISLANDS
HM=AUD
# HOLY SEE (VATICAN CITY STATE)
VA=EUR
# HONDURAS
HN=HNL
# HONG KONG
HK=HKD
# HUNGARY
HU=HUF
# ICELAND
IS=ISK
# INDIA
IN=INR
# INDONESIA
ID=IDR
# IRAN, ISLAMIC REPUBLIC OF
IR=IRR
# IRAQ
IQ=IQD
# IRELAND
IE=EUR
# ISLE OF MAN
IM=GBP
# ISRAEL
IL=ILS
# ITALY
IT=EUR
# JAMAICA
JM=JMD
# JAPAN
JP=JPY
# JERSEY
JE=GBP
# JORDAN
JO=JOD
# KAZAKSTAN
KZ=KZT
# KENYA
KE=KES
# KIRIBATI
KI=AUD
# KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF
KP=KPW
# KOREA, REPUBLIC OF
KR=KRW
# KUWAIT
KW=KWD
# KYRGYZSTAN
KG=KGS
# LAO PEOPLE'S DEMOCRATIC REPUBLIC
LA=LAK
# LATVIA
LV=LVL
# LEBANON
LB=LBP
# LESOTHO
LS=LSL
# LIBERIA
LR=LRD
# LIBYAN ARAB JAMAHIRIYA
LY=LYD
# LIECHTENSTEIN
LI=CHF
# LITHUANIA
LT=LTL
# LUXEMBOURG
LU=EUR
# MACAU
MO=MOP
# MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF
MK=MKD
# MADAGASCAR
MG=MGA
# MALAWI
MW=MWK
# MALAYSIA
MY=MYR
# MALDIVES
MV=MVR
# MALI
ML=XOF
# MALTA
MT=EUR
# MARSHALL ISLANDS
MH=USD
# MARTINIQUE
MQ=EUR
# MAURITANIA
MR=MRO
# MAURITIUS
MU=MUR
# MAYOTTE
YT=EUR
# MEXICO
MX=MXN
# MICRONESIA, FEDERATED STATES OF
FM=USD
# MOLDOVA, REPUBLIC OF
MD=MDL
# MONACO
MC=EUR
# MONGOLIA
MN=MNT
# MONTENEGRO
ME=EUR
# MONTSERRAT
MS=XCD
# MOROCCO
MA=MAD
# MOZAMBIQUE
MZ=MZM;2016-06-30-22-00-00;MZN
# MYANMAR
MM=MMK
# NAMIBIA
NA=NAD
# NAURU
NR=AUD
# NEPAL
NP=NPR
# NETHERLANDS
NL=EUR
# NETHERLANDS ANTILLES
AN=ANG
# NEW CALEDONIA
NC=XPF
# NEW ZEALAND
NZ=NZD
# NICARAGUA
NI=NIO
# NIGER
NE=XOF
# NIGERIA
NG=NGN
# NIUE
NU=NZD
# NORFOLK ISLAND
NF=AUD
# NORTHERN MARIANA ISLANDS
MP=USD
# NORWAY
NO=NOK
# OMAN
OM=OMR
# PAKISTAN
PK=PKR
# PALAU
PW=USD
# PALESTINIAN TERRITORY, OCCUPIED
PS=ILS
# PANAMA
PA=PAB
# PAPUA NEW GUINEA
PG=PGK
# PARAGUAY
PY=PYG
# PERU
PE=PEN
# PHILIPPINES
PH=PHP
# PITCAIRN
PN=NZD
# POLAND
PL=PLN
# PORTUGAL
PT=EUR
# PUERTO RICO
PR=USD
# QATAR
QA=QAR
# REUNION
RE=EUR
# ROMANIA
RO=ROL;2015-06-30-21-00-00;RON
# RUSSIAN FEDERATION
RU=RUB
# RWANDA
RW=RWF
# SAINT BARTHELEMY
BL=EUR
# SAINT HELENA
SH=SHP
# SAINT KITTS AND NEVIS
KN=XCD
# SAINT LUCIA
LC=XCD
# SAINT MARTIN
MF=EUR
# SAINT PIERRE AND MIQUELON
PM=EUR
# SAINT VINCENT AND THE GRENADINES
VC=XCD
# SAMOA
WS=WST
# SAN MARINO
SM=EUR
# SAO TOME AND PRINCIPE
ST=STD
# SAUDI ARABIA
SA=SAR
# SENEGAL
SN=XOF
# SERBIA
RS=RSD
# SERBIA AND MONTENEGRO
CS=CSD
# SEYCHELLES
SC=SCR
# SIERRA LEONE
SL=SLL
# SINGAPORE
SG=SGD
# SLOVAKIA
SK=EUR
# SLOVENIA
SI=EUR
# SOLOMON ISLANDS
SB=SBD
# SOMALIA
SO=SOS
# SOUTH AFRICA
ZA=ZAR
# SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS
GS=GBP
# SPAIN
ES=EUR
# SRI LANKA
LK=LKR
# SUDAN
SD=SDG
# SURINAME
SR=SRD
# SVALBARD AND JAN MAYEN
SJ=NOK
# Sint Maarten (Dutch part)
SX=ANG
# SWAZILAND
SZ=SZL
# SWEDEN
SE=SEK
# SWITZERLAND
CH=CHF
# SYRIAN ARAB REPUBLIC
SY=SYP
# TAIWAN
TW=TWD
# TAJIKISTAN
TJ=TJS
# TANZANIA, UNITED REPUBLIC OF
TZ=TZS
# THAILAND
TH=THB
# TIMOR-LESTE
TL=USD
# TOGO
TG=XOF
# TOKELAU
TK=NZD
# TONGA
TO=TOP
# TRINIDAD AND TOBAGO
TT=TTD
# TUNISIA
TN=TND
# TURKEY
TR=TRL;2014-12-31-22-00-00;TRY
# TURKMENISTAN
TM=TMT
# TURKS AND CAICOS ISLANDS
TC=USD
# TUVALU
TV=AUD
# UGANDA
UG=UGX
# UKRAINE
UA=UAH
# UNITED ARAB EMIRATES
AE=AED
# UNITED KINGDOM
GB=GBP
# UNITED STATES
US=USD
# UNITED STATES MINOR OUTLYING ISLANDS
UM=USD
# URUGUAY
UY=UYU
# UZBEKISTAN
UZ=UZS
# VANUATU
VU=VUV
# VENEZUELA
VE=VEB;2016-01-01-04-00-00;VEF
# VIET NAM
VN=VND
# VIRGIN ISLANDS, BRITISH
VG=USD
# VIRGIN ISLANDS, U.S.
VI=USD
# WALLIS AND FUTUNA
WF=XPF
# WESTERN SAHARA
EH=MAD
# YEMEN
YE=YER
# ZAMBIA
ZM=ZMK
# ZIMBABWE
ZW=ZWL
# List of currencies with 0, 1, OR 3 decimals for minor units, or where there
# are no minor units defined. All others use 2 decimals.
minor0=\
ADP-BEF-BIF-BYB-BYR-CLF-CLP-DJF-ESP-GNF-\
GRD-ISK-ITL-JPY-KMF-KRW-LUF-MGF-PYG-PTE-RWF-\
TPE-TRL-VUV-XAF-XOF-XPF
minor1=
minor3=\
BHD-IQD-JOD-KWD-LYD-OMR-TND
minorUndefined=\
XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-\
XPT-XSU-XTS-XUA-XXX
编译通过,继续往下走
结束编译。
/jvm/openjdk/build/linux-amd64/bin# ./java -version
openjdk version "1.7.0-internal"
OpenJDK Runtime Environment (build 1.7.0-internal-root_2017_04_06_05_42-b00)
OpenJDK 64-Bit Server VM (build 24.0-b56, mixed mode)
上传一个Test.java;
./javac ./Test.java
/jvm/openjdk/build/linux-amd64/bin# ./java Test
hi jvm.Thu Apr 06 06:27:40 UTC 2017
总结:编译openjdk1.7,建议ALT_BOOTDIR使用sun jdk1.6较高版本进行编译。
来源:oschina
链接:https://my.oschina.net/u/856051/blog/789335