Jigsaw classpath mode support
mandy.chung at oracle.com
Tue Aug 7 10:47:35 PDT 2012
I have implemented the "classpath mode" support running on
a module image.
JDK has been modularized in the jigsaw repo. There no longer
has a rt.jar, tools.jar, or any jar file. The system classes
are now installed in a system module library as modules. This
change will allow the bootstrap class loader, extension class
loader, and system class loader to search classes and resources
in the system module library as the default. Some implementation
1. VM used to maintain the default bootclasspath list and search
classes in it. Now it will call jigsaw native interface to find
classes from the module library unless -Xbootclasspath is set
to override the default bootclasspath. The -Xbootclasspath/p
and -Xbootclasspath/a will continue to work as it is today.
Karen will be sending out the webrev for the hotspot change
For compatibility, -classpath tools.jar should continue
to work. There are existing applications using URLClassLoader
that loads classes from tools.jar (e.g. test harness) that
also should continue to work.
To be able to determine if the path of the given tools.jar
to either -classpath option or URL parameter to URLClassLoader
is the same path as JAVA_HOME/lib/tools.jar in a lightweight,
the module image for the full JDK will contain an empty tools.jar.
This also allows applications that check for the existence of
tools.jar to continue to work.
sun.misc.URLClassPath is the main implementation class to
support URLClassLoader to search a file from the given URLs.
Both ExtClassLoader and AppClassLoader are URLClassLoader.
URLClassPath is extended to find resource file from the
appropriate system modules if the given URL is
JAVA_HOME/lib/tools.jar or JAVA_HOME/lib/ext.
3. How to determine which modules belong to bootclasspath,
ext directory, and tools.jar (and a few jar files in JDK/lib)
A configuration for the classpath mode support is loaded at
startup rather than generated to minimize the startup cost.
The idea is to have one ClassPathContext for bootclasspath,
one for extension and one for the jdk tools.
In this prototype, I just define a new module "jdk.classpath"
and install it in the module image. It hardcodes the list
of modules for each ClassPathContext for now. One alternative
is to extend jpkg to generate "jdk.classpath" config specifically
for this classpath mode. We'll explore this later. But I
think this is good enough for now.
4. I made simple change in StoredConfiguration to reduce
the footprint of the configuration stored on disk. There
were several regression tests setting -Xmx failed due to
the increase of the startup footprint without this change.
With storing the context names and package names only once,
it reduces the size of the config with 35-40%. I suspect
the fast configuration will make similar change.
$ du -k `find . -name 'config'`
$ du -k `find . -name 'config'`
5. I ran the jtreg regression tests and JCK api& lang tests.
The test results are looking real good. Compared with the
jigsaw repo as the baseline, there are 2 new JCK test failures
that I have to investigate (passed: 23,685; failed: 138; error: 28)
There is a startup initialization issue due to the use of
Files.isSameFile method and the default file system provider
is replaced with user defined one. I'm currently looking into
a fix for it.
I'd like to get this webrev out for review early and I also
expect any issue found will be minor that I will generate a
separate patch on top of this as a separate review.
1. sun.boot.class.path no longer represents the search path
for the bootstrap class loader. Any application depending
on this system property may be impacted.
rmic is one example that uses this property value to find
system classes. There has been work to convert rmic to
use the javax.tool APIs that will support a module image.
Unless rmic becomes module-aware, it continues to use
the launcher hack setting -Xbootclasspath/p as a workaround.
More information about the jigsaw-dev