Exporting a package from system module is not allowed with --release
It appears from this bug ticket that --release
cannot be used in combination with --add-exports
, --add-reads
, and --patch-module
.
From the link:
The overall proposal here is to get make --release 9 work consistently between JDK 9 and the (anticipated) JDK 10, even at the cost of a possible different behavior of commands like:
$ <jdk9>/javac Test.java
$ <jdk9>/javac --release 9 Test.java
Also:
Which should be acceptable, given the intents of --release - allow to compile code using supported APIs for the given JDK release.
In particular the proposal is to:
[edit]
-prevents use of --add-exports, -add-reads and --patch-module for system modules in combination with --release (any version)
Here is the file diff that contains:
exporting a package from system module {0} is not allowed with --release
I can't comment on the rationale but from the above quote, it pertains to allowing JDK 9 to work consistently with JDK 10.
If you are using IntelliJ idea, try checking your Java compiler settings:
Go to the File menu -> [Settings] -> [Build, Execution, Deployment] -> [Java Compiler] and check the setting "Project bytecode version". I got a similar error ("exporting a package from system module java.datatransfer is not allowed with --release") when using JDK 11 while this value was still set to version 9. Setting it to 11 fixed the problem for me.