Does --add-exports imply --add-reads??

Alan Bateman Alan.Bateman at oracle.com
Wed Jul 11 08:18:17 UTC 2018


There seems to be a javac bug here, I've created the following to track it:
     https://bugs.openjdk.java.net/browse/JDK-8207032

-Alan

On 10/07/2018 16:56, Stephan Herrmann wrote:
> Hi,
>
> Given these sources:
>
> src/mod.one/module-info.java
> //---
> module mod.one {
>         requires transitive java.sql;
> }
> //---
>
> src/mod.one/p/X.java
> //---
> package p;
> public class X {
>         public static java.sql.Connection getConnection() {
>                 return null;
>         }
> }
> //---
>
> src/mod.two/module-info.java
> //---
> module mod.two {
>         requires java.sql;
> }
> //---
>
> src/mod.two/q/Y.java
> //---
> package q;
> public class Y {
>    java.sql.Connection con = p.X.getConnection();
> }
> //---
>
> Javac accepts the program when invoked like this:
>
> $ javac -d bin -source 9 --module-source-path src --add-exports 
> mod.one/p=mod.two \
>    src/mod.one/module-info.java src/mod.one/p/X.java \
>    src/mod.two/module-info.java src/mod.two/q/Y.java
>
> How come javac allows Y.java to access p.X, although mod.two does not 
> read mod.one?
>
> Is javac interpreting --add-exports to imply an additional --add-reads?
>
> best,
> Stephan



More information about the jigsaw-dev mailing list