mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8256063: Module::getPackages on an unnamed module may return packages that are in a named module
Reviewed-by: alanb, chegar
This commit is contained in:
parent
531c56ea65
commit
dff26a489d
4 changed files with 122 additions and 5 deletions
|
@ -1077,9 +1077,9 @@ public final class Module implements AnnotatedElement {
|
|||
* <p> For named modules, the returned set contains an element for each
|
||||
* package in the module. </p>
|
||||
*
|
||||
* <p> For unnamed modules, this method is the equivalent to invoking the
|
||||
* {@link ClassLoader#getDefinedPackages() getDefinedPackages} method of
|
||||
* this module's class loader and returning the set of package names. </p>
|
||||
* <p> For unnamed modules, the returned set contains an element for
|
||||
* each package that {@link ClassLoader#getDefinedPackages() has been defined}
|
||||
* in the unnamed module.</p>
|
||||
*
|
||||
* @return the set of the package names of the packages in this module
|
||||
*/
|
||||
|
@ -1094,11 +1094,11 @@ public final class Module implements AnnotatedElement {
|
|||
} else {
|
||||
packages = loader.packages();
|
||||
}
|
||||
return packages.map(Package::getName).collect(Collectors.toSet());
|
||||
return packages.filter(p -> p.module() == this)
|
||||
.map(Package::getName).collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -- creating Module objects --
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue