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