How to export a package from a module in a boot layer to module in a child layer.

Code Ranger coderanger2025 at outlook.com
Fri Jan 31 16:49:04 UTC 2025


Thank you for your suggestion.

jansi should be placed in the boot layer, because it is also used by log4j2, that also should be in the boot layer.

I think (I may be wrong, because I am not a JPMS guru like jigsaw team members) the problem arises due to two serious constraints:
1. we don't have access to the boot layer controller and we received a categorical refusal to grant access to it.
2. qualified opens/exports doesn't work to child layers.

For example, I can't even open an issue in jansi project to open internal package to jline because it gives nothing in this situation.

Best regards,CR

On 1/31/25 17:30, David Lloyd wrote:
> AFAIK it cannot be done with `jansi` in your boot layer. One solution would be to put it into a child layer, which will allow you to access the `Controller` for it, which you can then use to add the export manually after defining the `jline3` module in its sub-layer. Otherwise, `jansi` would have to cooperatively call `Module.addExports` for your module, which seems unlikely to me.
>
> On Fri, Jan 31, 2025 at 7:19 AM Code Ranger <coderanger2025 at outlook.com> wrote:
>
>     Hello all.
>
>     I have a boot layer with `org.fusesource.jansi` module a child layer with jline3 module. Jline3 wants to use jansi:
>
>     Caused by: java.lang.IllegalAccessError: class org.jline.terminal.impl.jansi.JansiTerminalProvider (in module org.jline) cannot access class org.fusesource.jansi.internal.Kernel32 (in module org.fusesource.jansi) because module org.fusesource.jansi does not export org.fusesource.jansi.internal to module org.jline
>          at org.jline at 3.28.0/org.jline.terminal.impl.jansi.JansiTerminalProvider.verifyAtLeast(JansiTerminalProvider.java:85) ~[jline-3.28.0.jar:?]
>          at org.jline at 3.28.0/org.jline.terminal.impl.jansi.JansiTerminalProvider.<init>(JansiTerminalProvider.java:93) ~[jline-3.28.0.jar:?]
>          at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62) ~[?:?]
>          at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502) ~[?:?]
>          at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486) ~[?:?]
>          at org.jline at 3.28.0/org.jline.terminal.spi.TerminalProvider.load(TerminalProvider.java:69) ~[jline-3.28.0.jar:?]
>
>     If I do
>          --add-exports org.fusesource.jansi/org.fusesource.jansi.internal=org.jline \
>
>     I get WARNING: Unknown module: org.jline specified to --add-exports
>     (as I was already told if a module is not the boot layer it is just ignored)
>
>     if I do
>          --add-exports org.fusesource.jansi/org.fusesource.jansi.internal=ALL-UNNAMED \
>
>     I get the same exception.
>
>     Could anyone say how to fix it?
>
>     Best regards, CR
>
>
>
> -- 
> - DML • he/him
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jigsaw-dev/attachments/20250131/3731e8a2/attachment-0001.htm>


More information about the jigsaw-dev mailing list