This demo project contains the code for an answer to a Stack Overflow question. It explores cyclic dependencies With Project Jigsaw.
The code is released into the public domain via CC0 so it can be used without any limitations.
We have two disjunct cycles:
- pair:
pair.two
requirespair.one
requirespair.two
- triple:
triple.three
requirestriple.two
requirestriple.one
requirestriple.three
Running compile.sh
shows how they fail:
./compile.sh
> creating clean directories
> compiling and packaging cycle "pair"
src/org.codefx.demo.cyclic.pair.one/module-info.java:2: error: cyclic dependence involving org.codefx.demo.cyclic.pair.two
requires org.codefx.demo.cyclic.pair.two;
^
1 error
> compiling and packaging cycle "triple"
src/org.codefx.demo.cyclic.triple.three/module-info.java:2: error: cyclic dependence involving org.codefx.demo.cyclic.triple.two
requires org.codefx.demo.cyclic.triple.two;
^
1 error
The code was developed against build 106 of the
Jigsaw early access prototype.
For it to work the environment variable JIGSAW_BIN
has to point
to the bin
directory in such a Java 9 install, e.g.:
export JIGSAW_HOME=/opt/java/jdk9
export JIGSAW_BIN=/opt/java/jdk9/bin