Re[2]: Patch-module with dynamic layer creating.

Alex Sviridov ooo_saturn7 at mail.ru
Fri Oct 12 12:16:15 UTC 2018


Hi Alan

Maybe it is necessary to add possibility to have equal control for boot layer and
other layers. Because layers are graph but at this moment we can do for boot layer
more then for others -> if we work with non boot layers we must use another 
solutions -> different solutions within one technology is not good.

For example we could pass something like String[] args when we create custom layer.

Alex


>Четверг, 11 октября 2018, 14:27 +03:00 от Alan Bateman <Alan.Bateman at oracle.com>:
>
>On 11/10/2018 10:57, Alex Sviridov wrote:
>> Hi all,
>>
>> I create ModuleLayer this way
>>
>> ModuleFinder finder = ModuleFinder.of(dir1, dir2, dir3);
>> ModuleLayer parent = ModuleLayer.boot();
>> Configuration cf = parent.configuration().resolve(finder, ModuleFinder.of(), Set.of("myapp"));
>> ClassLoader scl = ClassLoader.getSystemClassLoader();
>> ModuleLayer layer = parent.defineModulesWithOneLoader(cf, scl);
>> Class<?> c = layer.findLoader("myapp").loadClass("app.Main");
>>
>> And I need for newly created layer make the following:
>> -patch-module java.xml.ws.annotation=jsr305-3.0.2.jar
>>
>> Could anyone say, how I can do it, taking into consideration that when I start JVM I don't
>> know what layers I will create and what patch module I will need to use, so
>> I can not use for it JVM parameters.
>>
>The --patch-module option is for patching modules in the boot layer, 
>there is no API support for patching modules when creating module layers 
>with the API. If you want to patch modules in custom module layers then 
>you need a create a ModuleFinder that will find the patched module - 
>it's not too hard to do, it's essentially scanning the patch locations 
>to find additional packages and then pre-pending the patch so that 
>resources are found in the patch before looking in the unpatched module.
>
>-Alan


-- 
Alex Sviridov


More information about the jigsaw-dev mailing list