Compiling classes for multi-release JAR with module-info.java
Alan Bateman
Alan.Bateman at oracle.com
Sat Feb 11 17:40:26 UTC 2017
On 10/02/2017 23:06, Gunnar Morling wrote:
> :
>
> If I don't have a module descriptor things work fine:
>
> javac --source-path=src/main/java -d target/classes --release 8
> $(find src/main/java -name "*.java")
> javac --source-path=src/main/java9 -cp target/classes -d
> target/classes-java9 --release 9 $(find src/main/java9 -name "*.java")
> jar --create --file mr.jar -C target/classes . --release 9 -C
> target/classes-java9 .
>
> Specifically, the second javac call picks up the (shared) class file
> for "Version" from the classpath by pointing to the output directory
> of the first compilation.
>
> Things fail when adding a module descriptor:
>
> --- src/main/java9/module-info.java
> module com.example {
> }
> ---
It is complicated but I think the reason you are running into issues is
because the second javac command is essentially compiling a module with
references to types on the class path.
If you move the module-info.java to the top-level directory directory
then I would expect this should work:
javac --release 8 -d target/classes src/main/java/com/example/A.java
src/main/java/com/example/Version.java
javac -d target/classes src/main/java/module-info.java
javac -d target/classes-java9 -cp target/classes
src/main/java9/com/example/A.java
jar --create --file mr.jar -C target/classes . --release 9 -C
target/classes-java9 .
Jon might have other suggestions.
-Alan
More information about the jigsaw-dev
mailing list