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

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

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Approved
    • Fix Version/s: 11
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      low
    • Compatibility Risk Description:
      Some existing build scripts may be relying on the implied readability from --add-exports. These will need to be updated.
    • Interface Kind:
      add/remove/modify command line option

      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: