Using jlink with automatic modules

后端 未结 1 458
有刺的猬
有刺的猬 2021-02-12 16:05

I have an explicit modular project which is dependent on an automatic module; e.g. on java.activation. Is it still possible to use jlink?

See this module-info.java:

<
1条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-12 16:17

    From my understanding an automatic module would contain the whole classpath anyway, so I guess there would be no benefit in creating a runtime-image with jlink?

    No, automatic modules would not contain the whole classpath. In fact, the artifacts which are not explicitly defined as modules(contain module-info.java) but are found on the modulepath are treated as automatic modules to bridge the gap between explicit modules and the classpath code.

    Are there any possibilities to circumvent this issue, maybe generating a module-info for those dependencies?

    Yes, you can either create a module-info.java with jdeps or use plugins like moditect to generate module-info for the module and inject it in your existing JAR.

    Once the artifact(JAR) has an explicit module declaration, jlink should accept it without failure.

    0 讨论(0)
提交回复
热议问题