JDK-8207175 : Compilation succeeds without checking readability when --add-exports used
  • Type: CSR
  • Component: tools
  • Sub-Component: javac
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 11
  • Submitted: 2018-07-12
  • Updated: 2018-07-13
  • Resolved: 2018-07-13
Related Reports
CSR :  
Relates :  
Description
Summary
-------

`--add-exports` in javac currently implies readability. This is not intended and will be fixed so that `--add-reads` will be needed to inject readability in some cases.

Problem
-------

Consider compilation of two modules:

````
ma/module-info.java
    module ma {}

ma/a/A.java
    package a;
    public class A {}
````

````
mb/module-info.java
    module mb {}

mb/i/I.java
    package i;
    public class I { a.A a; }
````

Currently, when `--add-exports ma/a=mb` is passed to `javac`, `javac` will successfully compile the modules, even though module `mb` does not read module `ma`. This is not intended; the compilation should fail unless either `-add-reads mb=ma` is passed to `javac`, or a `requires ma;` directive is added to `mb/module-info.java`.

Solution
--------

`--add-exports` will be fixed to not imply readability.

Specification
-------------

`--add-exports` will inject `exports` directives to the source module, but will not change readability.


Comments
Moving to Approved conditional on a release note being written.
13-07-2018

Looks good. A release note is appropriate in this case.
12-07-2018