Dependencies to a root modules when creating a dynamic module layer

forax at forax at
Mon May 1 17:37:01 UTC 2017

----- Mail original -----
> De: "Alan Bateman" <Alan.Bateman at>
> À: "Remi Forax" <forax at>, "jigsaw-dev" <jigsaw-dev at>
> Envoyé: Lundi 1 Mai 2017 13:41:30
> Objet: Re: Dependencies to a root modules when creating a dynamic module layer

> On 01/05/2017 10:48, Remi Forax wrote:
>> Hi all,
>> i try to load a kind of dynamic plugin using a ModuleLayer,
>> the plugin is wrapped in a module which is loaded dynamically.
>> This module has a requires directive to "java.sql" which is part of the 'root'
>> modules.
>> The problem is that my application do not requires "java.sql" because it do not
>> need it,
>> so "java.sql" is not part of the module loaded when the VM is booted,
>> then when i load the plugin module
>> - either it fails to find the required module java.sql [1]
>> - or i try to load java.sql from the ModuleLayer and get an exception because
>> java.sql can not be loaded by the boot classloader
>> I'm sure i've missed something ?
> There isn't general support for dynamically augmenting the platform
> modules. There is partial support to allow the and
> java.instrument modules be dynamically loaded but that's all at this time.

In both cases, the VM adds modules to the configuration like with --add-modules before the boot layer is created, so there are not dynamically loaded.

> One thing to point out is `--add-modules ALL-DEFAULT` in JEP 261. This
> is motivated by the scenario where a container needs to load
> applications that require additional modules.

I've decided to add a requires because i know that no plugin will reference a module which is not present in but like -with -add-modules ALL-DEFAULT, this is a kind of a workaround,
it's pre-loading all modules because you may need one.

I wonder if we can explore how to add modules to an existing configuration (if they were already accessible by the module finder used to create the configuration) in 10.

> -Alan.


More information about the jigsaw-dev mailing list