Does --add-opens work for dynamically created layers in JPMS?
Asked Answered
F

1

2

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?

Form answered 31/3, 2020 at 16:47 Comment(3)
The --add-opens CLI option is for the boot layer only.Stirring
@AlanBateman Thank you for the answer. That's bad and I think this is an obvious flaw of JPMS. Could you say if I should open feature request or there is no chance it will be implemented?Form
It's not a flaw or oversight. If you really want to do this then you'll need to open the package to the module in the boot layer that creates the child layer. It can then use 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
F
1

The answer was given by @AlanBateman

The --add-opens CLI option is for the boot layer only.

Form answered 1/4, 2020 at 9:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.