In JRE-9/lib
directory (at least on Windows), there is a new file called modules
whose size is about 107 MB. Is it possible to extract that file or maybe list java modules within it?
I can see that a new tool called jmod
is available at jdk-9/bin/jmod.exe
, but that is for reading .jmod
files which is located at jdk-9/jmods
and it cannot read the file modules
.
The
modules
file is a container file. It's internal to the JDK and the format is not documented (it may change at any time). For troubleshooting purposes, thejimage
tool in the bin directory can be used to list or extract the contents.You can use libjimage to read this file.
The runtime resources are handled in a backwards compatible way. E.g. when you did
in the past, you usually got something like
Running the same under Java 9 will give you
instead. In either case, you can open a
FileSystem
on it to inspect the other available resources (since Java 7). While theZipFileSystem
had to be created viaFileSystems.newFileSystem
first, Java 9’s file system is even already open for use:If you are running under a different JRE than the one you want to inspect, you have to load the appropriate file system implementation manually first, but this opens the possibility to inspect a Java 9 installation even from a Java 8 JRE:
Once you have a file system (or a
Path
into it), you can use all standard functions of, e.g.Files
to inspect or extract/copy the data, though the right term would be “to store an equivalent class file” in a different file system, as the runtime image’s representation doesn’t have to be a class file at all.The
modules
file is meant to be a single file (not meant to be extracted anywhere) which contains a binary representation of all of the modules present in the JDK in an undocument format which is subject to change. You can list the modules it contains withjava --list-modules
.Initially the
modules
file will contain every module and basically double the side of the JDK on its own, but once you "minify" your JDK using thejlink
utility, themodules
file will become smaller (assuming your program contains a subset of the modules provided with the JDK). For more info onjlink
see here: http://openjdk.java.net/jeps/282You can list modules via
java --list-modules