8237878: Improve ModuleLoaderMap datastructures

Reviewed-by: alanb, forax
This commit is contained in:
Claes Redestad 2020-02-10 13:58:12 +01:00
parent c23d1de2f8
commit 326a939e1b
5 changed files with 104 additions and 81 deletions

View file

@ -1094,13 +1094,14 @@ public final class Module implements AnnotatedElement {
// map each module to a class loader
ClassLoader pcl = ClassLoaders.platformClassLoader();
boolean isModuleLoaderMapper = ModuleLoaderMap.isBuiltinMapper(clf);
for (int index = 0; index < numModules; index++) {
String name = resolvedModules[index].name();
ClassLoader loader = clf.apply(name);
if (loader == null || loader == pcl) {
if (!(clf instanceof ModuleLoaderMap.Mapper)) {
if (!isModuleLoaderMapper) {
throw new IllegalArgumentException("loader can't be 'null'"
+ " or the platform class loader");
}