Jigsaw questions
Remi Forax
forax at univ-mlv.fr
Thu Jul 13 09:30:10 UTC 2017
----- Mail original -----
> De: "Oleg Tsal-Tsalko" <oleg.tsalko at gmail.com>
> À: jigsaw-dev at openjdk.java.net
> Envoyé: Jeudi 13 Juillet 2017 09:34:53
> Objet: Jigsaw questions
> Dear experts,
>
> I'm from JUG UA and currently playing with new Java 9 Module System using
> Early Access Jigsaw build #174. As an exercise I'm modularising JUnit 5. In
> process I faced couple of issues and have couple of questions to you:
>
> 1. *How to compile test classes that are packaged in same packages as
> production code? *When I'm trying to compile test sources separately
> from application sources that have been already modularised (packaged in
> modules) I'm getting errors saying that particular packages already found
> in certain modules on module path. What are recommendations (best practice)
> here?
--patch-module is your friend.
The other solution is to put the test classes in another module and to be able to merge module (the tested module and the test module) but it requires support either by the build tool you use or by JUnit itself.
> 2. When I'm trying to run unit tests placed on classpath using
> modularised JUnit5 library put on module path I'm getting errors
> like "*Could
> not load class with
> name: org.junit.platform.commons.util.CollectionUtilsTests*". I have
> deduced that it is because CollectionUtilsTests class lives in same
> package as already exists in junit.platform.commons module placed on
> module path. If I run org.junit.mytests.SimpleTest from custom unique
> package instead everything works fine. My question is more general here
> though: *how to deal (access via reflection for example) with classes on
> classpath that use same packages as certain modules on module path?* We
> can't (it will be very difficult and inconvenient) ensure that no library
> on classpath uses same package as some of the modules on module path...
Christian Stein (sormuras on Github) has already played with running JUnit5 on Java 9,
see https://github.com/sormuras/application-junit5-jdk9-demo
and for your second question, you can't, a package should be in only one module at a time (a package in the classpath is part of the unamed module), that's why you have to use --path-module to put all the test classes with the tested classes in the same package inside the same module.
>
> Could you please clarify these aspects to me please or point me where I can
> read about it?
>
> Thank you,
> Oleg
cheers,
Rémi
More information about the jigsaw-dev
mailing list