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

Naman Nigam naman_nigam at rediffmail.com
Tue Jul 10 18:06:49 UTC 2018


Well, this looks similar to what the increasing readability
<http://openjdk.java.net/jeps/261#Increasing-readability%E2%80%8B> section
in JEP-261 reads.

As a consequence, code in the source module will be able to access types in
> a package of the target module at both compile time and run time if that
> package is exported via an exports clause in the source module's
> declaration, an invocation of the Module::addExports method
> <http://download.java.net/java/jdk9/docs/api/java/lang/reflect/Module.html#addExports-java.lang.String-java.lang.reflect.Module->,
> or an instance of the --add-exports option


Another doubt, if it could add to the current context, would be, what does
the term "invocation of an unrestricted form" precisely mean in the
document?

        Regards
    Naman Nigam


On Tue, Jul 10, 2018 at 9:26 PM Stephan Herrmann <stephan.herrmann at berlin.de>
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