The 'modules' image (jimage) packaged JDK resources

Jiangli Zhou jianglizhou at google.com
Wed Jan 31 01:41:44 UTC 2024


As part of the discussions of bringing
https://github.com/openjdk/leyden/tree/hermetic-java-runtime related work
into OpenJDK mainline under the leyden project, some of us (cc'ed on the
email) have started brainstorming (in several zoom meetings) the idea of
placing JDK resources in the modules image (jimage). The resources would
include conf/*, lib/<resources>, etc in a regular JDK binary. In the
hermetic-java-runtime prototype, the JDK resources are packaged into an
executable JAR image as normal JAR entries. At runtime, accessing these
resources goes through a JavaHome
<https://github.com/openjdk/leyden/blob/hermetic-java-runtime/src/java.base/share/classes/jdk/internal/misc/JavaHome.java>
class
using a ZipFileSystem. If JDK resources are part of the modules, the
static/hermetic image packaging and runtime accessing becomes further
cleaner.

I recently prototyped that idea with a jlink plugin and some quick runtime
changes to access using Module.getResourceAsStream
<https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Module.html#getResourceAsStream(java.lang.String)>
(not
in the hermetic-java-runtime branch yet). The quick prototype indicates it
is feasible from an implementation point of view.  Following are a few
points that have been discussed among us for more broad discussions:

- This probably will involve specification changes in order to place the
JDK resources into the modules image. Particularly, the conf/* resource
files were intended to be user configurable (pointed out by Alan). Alan has
been looking into those parts.

- Where should the resources be placed within the modules image? For
example, if conf/security/java.security is written (using the new jlink
plugin) into the image as /java.base/java.security, runtime can just access
"java.security" resource using the "java.base" module (via
getResourceAsStream()). Alternatively, if the file is written as
/java.base/conf/security/java.security, the conf/security package needs to
be added for the java.base module.

Thoughts and input?

Thanks!
Jiangli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/leyden-dev/attachments/20240130/f27df742/attachment.htm>


More information about the leyden-dev mailing list