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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 9
    • core-libs
    • None

      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.

            jpai Jaikiran Pai
            jpai Jaikiran Pai
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: