Mac OSX 10.10 Yosemite compile OpenJDK 9

Source: Internet
Author: User

Mac OSX 10.10 Yosemite compile OpenJDK 9

OpenJDK9 is compiled on Mac OSX 10.10. The following is only a personal installation record for your reference.

Compilation Time:

System Version: Mac OS X Yosemite 10.10.4

Compile OpenJDK: JDK 9

Related Software Versions:

  • XCode Version: XCode6-Beat4 Version 6.0 (6A267n)
  • JDK version: 1.8.0 _ 45
  • Software management tool: brew
  • Xquartz (X11): 2.7.7

References:

  • OpenJDK Home Page

  • OpenJDK official compilation steps (the README-builds file is available after the source code is downloaded)

  • Jdk bug System (you can search for problems during compilation)

  • OpenJDK official website operating system requirements

Preparations for compilation:

• A general understanding of the system requirements on the official website:


Https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms

• Install the source code download tool (Here we use the Mercurial tool [OpenJDK version control tool] to download it from the official website ):


Installation references:

Http://openjdk.java.net/guide/repositories.html

Https://mercurial.selenic.com/wiki/Download#Mac_ OS _X

Local installation script:

Installation:

$ Brew install mercurial

If link fails:

$ Sudo brew link mercurial

Verification version no less than 2.6.3: hg version

After the installation, the version 3.0.2 is changed to the official website to download and install 3.4.1.

• Install ccache to increase Compilation speed

$ Brew search ccache
$ Brew install ccache

• Install freetype (required during compilation ):

Brew install freetype

Installation failed, prompting that the dependent libpng cannot be downloaded. Manual installation:

Download libpng Latest Version 1.6.17 (http://sourceforge.net/projects/libpng/files/) and unzip:

$ Pwd
$ Cd./libpng-1.6.17
$./Configure -- prefix =/usr/local/libpng-1.6.17
$ Make
$ Make install
$ Cd/usr/local/
$ Ln-s libpng-1.6.17/usr/local/libpng
$ Brew install freetype

• Obtain the JDK source code:

$ Mkdir OpenJDK9; cd OpenJDK9
$ Hg clone
$ Cd dev
$ Chmod u + x get_source.sh
$./Get_source.sh
 

Compilation Configuration:

$ Bash./configure -- help = short
$ Bash./configure -- enable-debug -- with-target-bits = 64
...
========================================================== ================
A new configuration has been successfully created in
OpenJDK9/jdk9/build/macosx-x86_64-normal-server-fastdebug
Using configure arguments '-- enable-debug -- with-target-bits = 64 '.
 
Configuration summary:
* Debug level: fastdebug
* HS debug level: fastdebug
* JDK variant: normal
* JVM variants: server
* OpenJDK target: OS: macosx, CPU architecture: x86, address length: 64
 
Tools summary:
* Boot JDK: java version "1.8.0 _ 45" Java (TM) SE Runtime Environment (build 1.8.0 _ 45-b14) Java HotSpot (TM) 64-Bit Server VM (build 25.45-b02, mixed mode) (at/Library/Java/JavaVirtualMachines/jdk1.8.0 _ 45.jdk/ Contents/Home)
* Toolchain: clang (clang/LLVM)
* C Compiler: Version Apple LLVM version 6.0 (clang-600.0.41.2) (based on LLVM 3.5svn) Target: x86_64-apple-darwin14.4.0 Thread model: posix (at/usr/bin/clang)
* C ++ Compiler: Version Apple LLVM version 6.0 (clang-600.0.41.2) (based on LLVM 3.5svn) Target: x86_64-apple-darwin14.4.0 Thread model: posix (at/usr/bin/clang ++)
 
Build performance summary:
* Cores to use: 2
* Memory limit: 4096 MB

Compile:

$ Make
...
OpenJDK9/jdk9/jdk/src/java. desktop/macosx/native/libosxapp/NSApplicationAWT. m: 387: 29: error: sending 'id <NSApplicationDelegate> 'to parameter of incompatible type' id <NSFileManagerDelegate> '[-Werror]
[NSApp setDelegate: applicationDelegate];
^ ~~~~~~~~~~~~~~~~~~
/System/Library/Frameworks/Foundation. framework/Headers/NSFileManager. h: 109: 47: note: passing argument to parameter 'delegate' here
@ Property (assign) id <NSFileManagerDelegate> delegate NS_AVAILABLE (10_5, 2_0 );
^
1 error generated.
Make [3]: **** [OpenJDK9/jdk9/build/macosx-x86_64-normal-server-fastdebug/support/native/java. desktop/libosxapp/NSApplicationAWT. o] Error 1
Make [2]: *** [java. desktop-libs] Error 2
Make [2]: *** Waiting for unfinished jobs ....
 

The solution is as follows or replace XCode with version 6.3.2 or 5.0:

// OpenJDK9/jdk9/jdk/src/java. desktop/macosx/native/libosxapp/NSApplicationAWT. m
// Change row 387:
If (NSApp! = Nil ){
// [NSApp setDelegate: applicationDelegate];
[(NSApplication *) NSApp setDelegate: applicationDelegate];
 
If (applicationDelegate & qad ){
[Qad processQueuedEventsWithTargetDelegate: applicationDelegate];
Qad = nil;
}
}
 

Re-compile:

$ Make clean
$ Make
...
OpenJDK9/jdk9/jdk/src/java. desktop/share/native/libawt/awt/image/awt_parseImage.c: 855: 33: error: comparison of array 'rasterp-> spsms. offsets 'not equal to a null pointer is always true [-Werror,-Wtautological-pointer-compare]
Else if (rasterP-> spsms. offsets! = NULL ){
~~~~~~~~~~~~~~~ ^ ~~~~~~ ~~~~
1 error generated.
Make [3]: *** [OpenJDK9/JDK 9/build/macosx-x86_64-normal-server-fastdebug/support/native/java. desktop/libawt/awt_parseImage.o] Error 1
Make [2]: *** [java. desktop-libs] Error 2
Make [2]: *** Waiting for unfinished jobs ....
 
ERROR: Build failed for target 'default' in configuration 'macosx-x86_64-normal-server-fastdebug '(exit code 2)
Hint: If caused by a warning, try configure -- disable-warnings-as-errors
 
Make [1]: *** [main] Error 2
Make: *** [default] Error 2

Solution:

// OpenJDK9/jdk9/jdk/src/java. desktop/share/native/libawt/awt/image/awt_parseImage.c
// Change row 855 to the following (comment out the IF condition ):
Else/** if (rasterP-> spsms. offsets! = NULL )**/{

Re-compile:

$ Make clean
$ Make
...
1 error generated.
Make [3]: *** [OpenJDK9/jdk9/build/macosx-x86_64-normal-server-fastdebug/support/native/java. desktop/libsplashscreen/splashscreen_sys.o] Error 1
Make [3]: *** Waiting for unfinished jobs ....
Make [2]: *** [java. desktop-libs] Error 2
 
ERROR: Build failed for target 'default' in configuration 'macosx-x86_64-normal-server-fastdebug '(exit code 2)
Hint: If caused by a warning, try configure -- disable-warnings-as-errors
 
Make [1]: *** [main] Error 2
Make: *** [default] Error 2

Solution:

// OpenJDK/openJDK9/jdk9/jdk/src/java. desktop/macosx/native/libsplashscreen/splashscreen_sys.m
// Comment out 278 rows:
// [Image setScalesWhenResized: YES];

Re-compile, no error occurred:

$ Make clean
$ Make
...
Finished building target 'default' in configuration 'macosx-x86_64-normal-server-fastdebug'

• Preliminary verification of compilation results:

$ Cd./build /*
$ Ls
Makefile configure-support jdk
Bootcycle-spec.gmk configure. log make-support
Build. log configure. log. old spec. gmk
Build. log. old hotspot support
Buildtools hotspot-spec.gmk
Compare. sh images
$ Cd jdk/bin
$./Java-versionopen
Openjdk version "1.9.0-internal-fastdebug"
OpenJDK Runtime Environment (build 1.9.0-internal-fastdebug-stxpons_2015_06_13_16_14-b00)
OpenJDK 64-Bit Server VM (build 1.9.0-internal-fastdebug-stxpons_2015_06_13_16_14-b00, mixed mode)
 

• Refer to the Testing chapter in the readme-builds.html file in the jdksource code directory:


Oh, mom. It's been a long time. Come back. You have to install jreg first... If you are not available next time, follow the Official Method for verification...

$ Cd test
$ Make PRODUCT_HOME = 'pwd'/../build/*/images/j2sdk-image all
/Applications/Xcode. app/Contents/Developer/usr/bin/make-k-C ../jdk/test TEST = jdk_all
Echo "Running tests: jdk_all"
Running tests: jdk_all
For each in jdk_all; do \
/Applications/Xcode. app/Contents/Developer/usr/bin/make-j 1 TEST_SELECTION = ": $ each" UNIQUE_DIR = $ each jtreg_tests ;\
Done
Make [2]: *** No rule to make target 'openjdk9/jdk9/test/../build/macosx-x86_64-normal-server-fastdebug/images/j2sdk-image ', needed by 'glast '.
Make [2]: *** No rule to make target '/java/re/jregulatory/4.1/promoted/latest/binaries/jregulatory ', needed by '/java/re/jregulatory/4.1/promoted/latest/binaries/jregulatory/bin/jregulatory '.
Make [2]: Target 'jregulatory _ tests 'not remade because of errors.
Make [1]: *** [jdk_all] Error 2
Make: *** [jdk_all] Error 2

Compile and install OpenJDK7 source code on CentOS 6.5

RHEL6.5 install OpenJDK1.7.0 + JBoss7.1.1 + Maven3.0.4

Install the official JDK under Fedora 20 to replace OpenJDK and configure environment variables.

Install Ubuntu OpenJDK + Tomcat 7

Upgrade Ubuntu 13.04 to Maven3.10 to support OpenJDK7

Compile and install OpenJDK 7 in Ubuntu 12.10

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.