On 27/07/2016 18:42, Paul Benedict wrote:
Dear Jigsaw experts,
Instead of loading modules through --module-path, I would like to discover
them programmatically through other means. I can produce a Configuration
and Layer for this. I would like to delegate the module finding to the
parent too. In other words, I want the parent to be the Java runtime itself
so that any pre-installed modules will be resolvable.
For the scenario then the parent will be the boot Layer so any
references to standard or JDK modules in the boot Layer will be resolved
(the boot Layer may contain modules on the application module path too,
maybe your "launcher" module if you deploy that as a named module).
One example in the JDK to look at is jlink where it creates a child
layer for jlink plugins that are loaded from a plugins module path
(`jlink --plugin-module-path ...`). Another one is javac where
annotation processors can be deployed as modules on a processor module
path (`javac --processor-module-path ...`).
On the phrase "any pre-installed modules will be resolvable" then
remember that not all modules in the runtime image may be in the boot
layer. That might be too much detail to be concerned about at this point
of course. The main thing is to get something working, I expect it
should be straight-forward.
Under this pattern, I am hoping all modules execute like no additional
Layer was introduced. I would like to know if there are any side-effects I
should be aware of?
The boot Layer is created before your main class is loaded. The layer of
modules that you create will be a child of the boot layer (assuming that
is how you create it).
One potential side effect might be visibility. If there are APIs that
are specified to locate modules or services or something via the system
class loader then they aren't going to find anything that is only
visible via class loaders for modules in a custom layer.
:
It's also my understanding that doing a Layer is the only way to get access
into the Module Descriptor of modules before they load. Can you confirm?
Creating a layer is just instantiating a graph of modules. That graph of
modules is described by a Configuration. From other mails then I'm
guessing you are want to change module descriptors as they are
located/loaded, in which case then it's ModuleFinder that you want.
-Alan