I have a JPMS framework that dynamically creates JPMS layers and add modules to them. After some tests it seems to me that --add-opens
JVM parameter works only for the boot layer
, I mean the layer that is created when application starts.
So, the question - does --add-opens
work for dynamically created layers in JPMS?
Concrete example
--add-opens java.base/java.lang=weld.servlet.shaded
will java.base/java.lang
be opened to weld.servlet.shaded
if weld.servlet.shaded
is in dynamically created layer?
Object.class.getModule().addOpens("java.lang", weldModule)
to open it to the weld module. It's a workaround until Weld is fixed to not hack into non-public methods. – Stirring