ModuleLayer for java.base only

Michał Kłeczek michal at kleczek.org
Wed Oct 8 18:06:13 UTC 2025



> On 8 Oct 2025, at 19:39, Alan Bateman <alan.bateman at oracle.com> wrote:
> 
> 
> 
> On 08/10/2025 06:19, Jaroslav Tulach wrote:
>> 
>> How that is supposed to work? How do I create a `ModuleLayer` with just
>> `java.base` and control what the Enso library JARs can access? Can I control
>> that regardless of how the JVM was initialized? There must a a way, right? Or
>> am I asking for too much encapsulation?
> I think what you are looking for is to create the Configuration for a child layer in a way that "hides" all but java.base from the modules in the parent configuration. There isn't a way to do this as resolution time. That is, if the configuration for the parent/boot has java.base, enso, and apache.foo (used by enso) then there is no way to have resolution fail if a user module requires enso or requires apache.foo.
> 
> Who creates the configuration for the child layer? Can it process the Configuration and fail if any module in the configurations reads a module other than java.base?

Another approach would be to have only a closed “bootstrap" module in module path. It would provide main class, initialize a module layer with all Enzo modules and their dependencies, and pass execution to it.
Since bootstrap module does not export anything and is closed, having it in a boot layer would be harmless.

The downside is that with such setup there is no way to package Enzo and its dependencies in runtime image generated by jpackage.

—
Michal




More information about the jigsaw-dev mailing list