How to open a package from a module in the boot layer to a module in another layer?
Alan Bateman
alan.bateman at oracle.com
Sun Jan 12 08:35:45 UTC 2025
On 11/01/2025 22:06, Code Ranger wrote:
> I have an application that consists of a main part and plugins. The
> main part is in the boot layer, and for each plugin, a child layer is
> created. Plugins are dynamically added and removed.
>
> In one of my plugins, I use Gson, which requires the API module
> (located in the boot layer) to open a package to Gson. The boot layer
> controller is not accessible.
>
> Important! A few days ago (2025-01-08), I created an issue with ID
> 9077987 suggesting providing access to the boot layer controller, as
> it is impossible to work without it. However, my issue probably hasn't
> been reviewed yet, as I haven't received an email with the JDK_ID.
JDK-8347283 [1] was created a few days ago, looks like the same topic.
From the information in this mail then it looks like the API module (in
the boot layer) will need to open, using Module.addOpens, its package to
the plugin that uses Gson. The plugin will then, in turn, open it to the
Gson module. The API module doesn't need to know anything about Gson in
this setup, but it does allow need to allow for plugins that possibly
break in.
-Alan
[1] https://bugs.openjdk.org/browse/JDK-8347283
More information about the jigsaw-dev
mailing list