Trying to build jdk.base

Erik Joelsson erik.joelsson at oracle.com
Tue Apr 24 08:15:35 PDT 2012


On 2012-04-18 16:17, Alan Bateman wrote:
> Great! A significant part to this will be working out the 
> bootstrapping and the sequence that things will be built. Jon is the 
> best person to advise on this as there is quite a bit of detail to 
> work out.
>
I have continued to experiment with this and particularly the bootstrap 
problem. A progress update follows:

I started by reviving a script that Fredrik originally wrote which takes 
the build directory from the old jigsaw build and by looking at the 
modules directory, generates a makefile that organizes the java source 
files into the same modules. I expanded on the script to include more 
sources (platform specific and generated source) and also made it 
include the generated module-info.java files. This is still not perfect, 
but enough for trying prototypes for the build. This script needs to be 
rerun if classes are added or removed to any module.

Next I created a new makefile in the style of the build-infra build, 
that compiles the modularized source in one go. To run that compilation, 
I needed to use the newly built JDK so this is still run as a post step, 
after the build-infra build. A couple of notes for this compilation to work:

* Had to use the javac launcher. Running java 
-Xbootclasspath/p:javac.jar -jar javac.jar gave me errors.
* Had to create a %jigsaw-library in $(JDK_OUTPUTDIR)/lib/modules (using 
jmod).
* Had to add the following to the command line: 
-Xbootclasspath:$(JDK_OUTPUTDIR)/lib/sa-jdi.jar$(PATH_SEP)$(CORBA_OUTPUTDIR)/classes$(PATH_SEP)$(JDK_OUTPUTDIR)/newdemo/nio/zipfs/zipfs.jar 
as those classes weren't included when modularizing the source. (First 
is from hotspot, second from corba and the last is a demo)
* javac complains about the output directories not existing for each 
module. Looks weird to me and should probably be fixed.

Now I wanted to make the bootstrap better than building the whole JDK 
first. I started by minimizing the JDK needed by hand and managed to get 
it down to the following and still compiling the modularized source above:

/classes (containing classes from jdk.base and langtools)
/lib/modules/%jigsaw-library
/lib/amd64/jvm.cfg
/lib/amd64/server/libjvm.so
/lib/amd64/libzip.so
/lib/amd64/libjava.so
/lib/amd64/jli/libjli.so
/lib/amd64/libverify.so
/lib/currency.data
/bin/javac
/bin/java
/bin/jmod

The next step was to change the build order in the build-infra build to 
produce this minimal "work JDK". I have achieved that now, but the 
implementation is a bit hacky at places. Mostly due to not having 
converted all the old Makefiles yet, particularly those generating 
sources that are part of the jdk.base module. I have also verified that 
my "work JDK" is able to compile the modularized source. Before I can 
put it all together into one build script, we still need to convert more 
Makefiles, especially those generating java source. Otherwise we will 
still need to run most of the old build-infra build before actually 
doing the module compile. A couple of notes on creating the "work JDK":

* When compiling the java sources in jdk.base without module support, 
having the module-info.java file present causes strange errors in javac, 
even if explicitly listing all java files except that one on the command 
line. I have a temporary hack that deletes the file before compiling for 
now.
* The java files in jdk.base seem to compile fine without other modules 
on the classpath. However, one of the native libraries requires 
sun_misc_GC.h from jdk.rmi.

/Erik



More information about the jigsaw-dev mailing list