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

exports statement uses empty observable package

XMLWordPrintable

      If 'exports' statement uses package name, then this package should be observable (contain compilation unit in it or in subpackages) and contain file with package declaration due to assertion jigsaw-1.1.2-210:

      If the named package is observable in the current module, then at least one compilation unit containing a declaration of the package must be observable in the current module, or a compile-time error occurs.

      So compile-time error is expected if
      1) there is empty file (without package declaration) or
      2) there is file with wrong package statement
       in the package, but there is file in subpackage. But no error occurs.

      --------------------------
      Minimal case:

      Directory layout:
      mod1/module-info.java
      mod1/p/B.java
      mod1/p/q/A.java

      Code:
      module-info.java:
      {code}
      module mod1{
          exports p;
      }
      {/code}

      A.java:
      {code}
      package p.q;
      class A { }
      {/code}

      1st example:
      -----
      B.java:
      // no code here

      -----
      2nd example:

      B.java:
      {code}
      package wrong;
      {/code}

            vromero Vicente Arturo Romero Zaldivar
            kbarzilovich Konstantin Barzilovich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: