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

Module reading two packages with the same name cause warning

XMLWordPrintable

      In case of module has two packages with the same name, at least one of them by exports statement from another module, compiler returns warnings, but error is expected due to:
      1) Modular Visibility and Accessibility wiki page:
      Resolution may also fail if it computes a graph of modules where multiple modules export a package of the same name.
      2) API spec of Configuration class, resolve() method:
      Resolution and the post-resolution consistency checks may fail for several reasons: Two or more modules in the configuration export the same package to a module that reads both. This includes the case where a module M containing package P reads another module that exports P to M.

      MINIMAL TEST CASE

      Directory structure:
      mod1/module-info.java
      mod1/pack/B.java
      mod2/module-info.java
      mod2/pack/A.java

      mod1 module-info:
      module mod1 {
          requires mod2;
      }

      mod2 module-info:
      module mod2{
          exports pack;
      }

      Command:
      ...bin/javac.exe -modulesourcepath . -d ../out mod1/pack/B.java mod2/pack/A.java

      Result:
      warning: package exists in another module: mod2
      warning: package exists in another module: mod1
      2 warnings

      Tested with jigsaw b92 on Windows x64.
      Same issue on Solaris.

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

              Created:
              Updated:
              Resolved: