Specification of java.lang.module.ModuleDescriptor.packages() method can be improved

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 26
    • Affects Version/s: 9
    • Component/s: core-libs

      The specification of java.lang.module.ModuleReference.packages() method says:

      /**
       * Returns the set of packages in the module.
       *
       * <p> The set of packages includes all exported and open packages, as well
       * as the packages of any service providers, and the package for the main
       * class. </p>
      ...

      That seems to suggest that the method will return only exported/open (to all) packages of that module. But the implementation of that method returns all packages belonging to that module, even those that aren't exported/open to any module.

      For example, this trivial example code returns all packages in the java.base module even if those aren't exported or open to any modules:

      ModuleFinder.ofSystem().find("java.base").get().descriptor().packages().forEach(System.out::println)

      The specification of this method should be clarified that all packages are returned.

            Assignee:
            Jaikiran Pai
            Reporter:
            Jaikiran Pai
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: