Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8207175

Compilation succeeds without checking readability when --add-exports used

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 11
    • tools
    • None
    • behavioral
    • low
    • Some existing build scripts may be relying on the implied readability from --add-exports. These will need to be updated.
    • add/remove/modify command line option

      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.

            jlahoda Jan Lahoda
            alanb Alan Bateman
            Alan Bateman, Jonathan Gibbons, Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: