Jlink and automatic module

Remi Forax forax at univ-mlv.fr
Sun Jul 10 21:41:40 UTC 2016

Hi Antoine,
you were sleeping during my presentation at last Devoxx FR :)

The issue is that an automatic jar can access to the classpath while a modular jar can not,
so if jlink allows automatic modules, you may have surprising NoClassDefNotError at runtime ruining the whole idea of jigsaw.

A simple workaround is to use jdep -geninfo on the automatic jar to generate a module-info.java, compile it with javac and inject it into the jar with a jar --update.

see https://www.youtube.com/watch?v=a8xnnR3Bz6w&feature=youtu.be&t=2570 (in french)


----- Mail original -----
> De: "Antoine Sabot-Durand" <antoine at sabot-durand.net>
> À: jigsaw-dev at openjdk.java.net
> Envoyé: Dimanche 10 Juillet 2016 22:40:57
> Objet: Jlink and automatic module
> Hi All,
> I encounter the same problem than Sander in [1] regarding automatic modules
> and Jlink.
> My project has a lot of modules and uses a lot of dependencies (Java EE
> spec and impls) so it took me a few days to walk thru the writing of all my
> module-info.java files. hopefully I only found 2 automatics modules from
> 3rd parties that had split packages and propose PR to these project to
> correct these, in the meantime I use personal snapshot version for my JDK9
> compilation.
> At the end everything compiled fine without using classpath, but how
> frustrating it was to discover that I was unable to use Jlink because of
> this automatic module limitation.
> If you put my experience in perspective, it means that if you depend on
> tens of dependencies you'll have to wait months, even years before other
> projects decide to switch to JDK9 letting use use this great Jlink feature.
> IMO, if this limitation is not solved it may reatard jdk9 adoption on a lot
> of projects. I guess it's easier to say than do, but having a solution to
> externally add meta-data to these automatic modules (an kind of external
> module-info.class) could be doable for a more advance bridge approach.
> Anyway, thanks for all the great work and your feedback.
> Antoine Sabot-Durand
> [1] http://mail.openjdk.java.net/pipermail/jigsaw-dev/2016-March/006526.html

More information about the jigsaw-dev mailing list