-
Bug
-
Resolution: Unresolved
-
P4
-
9
-
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.
/**
* 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.