Busy Java Developer's Guide to Hacking the OpenJDK

Objectives

Tackling the OpenJDK can be intimidating.Therefore, let's....

Objectives

My goal is not to teach you all of the OpenJDK

My goal is to teach you enough that you can start learning

Requirements

In order to make the most of this talk, you should...

History

How OpenJDK got the 'open' in its name

History

In the beginning...

History

Back in the earliest days of Java (JDK 1.0.2)

History

This non-FOSS arrangement was not popular

History

Note that the sources were available, just not free

History

Java5: Time to go open-source!

History

Java5: Time to go open-source!

History

Java6: Almost there

History

This bifurcation remains true today

Overview

OpenJDK is a mix of Java and C++ source

OpenJDK8 (and older)

Source layout and instructions

OpenJDK8

Release pages:** JDK 6--- http://openjdk.java.net/projects/jdk6/** JDK 7--- http://openjdk.java.net/projects/jdk7/** JDK 8--- http://openjdk.java.net/projects/jdk8/

OpenJDK8

Note that JDK 'updates' are a different project!** for gnarly legal and licensing reasons** JDK 7u--- updates to the JDK 7 project** JDK 8u--- updates to the JDK 8 project** all development has closed down on the non-update repositories!--- I am going to assume you don't care about pre-8u sources

OpenJDK8

Building OpenJDK 8u** Clone the root repo--- hg clone http://hg.openjdk.java.net/jdk8u/jdk8u** Pull the "dependent" source trees--- cd jdk8u; bash get_source.sh

OpenJDK8

Source layout** a "root project" with several "subprojects"** technically this is a Mercurial "forest"--- but that's really complicated, so they simplified by adding the get_source script** subprojects:*** corba*** hotspot*** jaxp*** jaxws*** jdk*** langtools*** nashorn

OpenJDK8

Source layout** within each subproject, usually a "make" and "src"--- sometimes a "test" directory** "make" typically is black-box build stuff** "src" usually breaks down into*** platform-specific ("windows", "share")*** Java- vs native ("classes" vs not "classes")*** and for "classes", the usual package-qualified breakdown

OpenJDK8

Configure the makefiles** run the "configure" script to configure all the makefiles--- bash configure** note that any missing dependencies will be flagged and configure will terminate** check out ./README-builds.html for build details

OpenJDK8

Requirements** All:*** a "boot JDK" installation for Java files compilation*** generally the boot JDK must be one version behind (JDK 7)** MacOS:--- Xcode 4 (!) and command-line tools** Windows:*** Visual Studio 2013*** Cygwin (for Unix-style build chain)** Linux:--- usual build chain (g++, etc)

OpenJDK9

Source layout and instructions

OpenJDK9

Release page:** JDK 9--- http://openjdk.java.net/projects/jdk9/** big change:--- complete project restructure for modules

OpenJDK9

Building OpenJDK 9:** Clone root repo:--- hg clone http://hg.openjdk.java.net/jdk9/jdk9** Pull the "dependent" source trees--- cd jdk9; bash get_source.sh

OpenJDK9

Source layout** a "root project" with several "subprojects"** technically this is a Mercurial "forest"--- but that's really complicated, so they simplified by adding the get_source script** subprojects:*** corba*** hotspot*** jaxp*** jaxws*** jdk*** langtools*** nashorn

OpenJDK9

Source layout** within each subproject, usually a "make" and "src"--- sometimes a "test" directory** "make" typically is black-box build stuff** "src" usually breaks down into*** java modules ("java.desktop", "java.rmi", etc)*** or os-specific ("bsd", "solaris", "windows", etc)** within each module, breaks down into*** "share" (os-independent) or os-specific*** "classes" (Java) v "native" (C++)

OpenJDK9

Configure the makefiles** run the "configure" script to configure all the makefiles--- bash configure** note that any missing dependencies will be flagged and configure will terminate** check out ./README-builds.html for build details

OpenJDK9

Requirements** All:*** a "boot JDK" installation for Java files compilation*** generally the boot JDK must be one version behind (JDK 7)** MacOS:--- XCode and command-line tools** Windows:*** Visual Studio 2015*** Cygwin (for Unix-style build chain)** Linux:--- usual build chain (g++, etc)

OpenJDK10 (and beyond)

Source layout and instructions

OpenJDK10

Release pages:

OpenJDK10

Github repositories:

OpenJDK Project

Building OpenJDK project

OpenJDK Project

Source layout

OpenJDK Project

Source layout

OpenJDK Project

Source layout

OpenJDK Project

Configure the makefiles

OpenJDK Project

Requirements

OpenJDK8

Configure flags of note

Challenges

Find the java "launcher" code (java / java.exe)

Change the java.vendor system property

Get a list of all the -XX flags in a diagnostic build

Find where -XX:DisableExplicitGC is checked

Write your own garbage collector

Credentials

Who is this guy?