@@ -51,32 +51,31 @@ private static final class Mapper implements Function<String, ClassLoader> {
5151 private static final ClassLoader APP_CLASSLOADER =
5252 ClassLoaders .appClassLoader ();
5353
54- private static final Integer PLATFORM_LOADER_INDEX = 1 ;
55- private static final Integer APP_LOADER_INDEX = 2 ;
54+ private static final String PLATFORM_LOADER_NAME = "PLATFORM" ;
55+ private static final String APP_LOADER_NAME = "APP" ;
5656
5757 /**
58- * Map from module to a class loader index . The index is resolved to the
58+ * Map from module name to class loader name . The name is resolved to the
5959 * actual class loader in {@code apply}.
6060 */
61- private final Map <String , Integer > map ;
61+ private final Map <String , String > map ;
6262
6363 /**
6464 * Creates a Mapper to map module names in the given Configuration to
6565 * built-in classloaders.
6666 *
6767 * As a proxy for the actual classloader, we store an easily archiveable
68- * index value in the internal map. The index is stored as a boxed value
69- * so that we can cheaply do identity comparisons during bootstrap.
68+ * loader name in the internal map.
7069 */
7170 Mapper (Configuration cf ) {
72- var map = new HashMap <String , Integer >();
71+ var map = new HashMap <String , String >();
7372 for (ResolvedModule resolvedModule : cf .modules ()) {
7473 String mn = resolvedModule .name ();
7574 if (!Modules .bootModules .contains (mn )) {
7675 if (Modules .platformModules .contains (mn )) {
77- map .put (mn , PLATFORM_LOADER_INDEX );
76+ map .put (mn , PLATFORM_LOADER_NAME );
7877 } else {
79- map .put (mn , APP_LOADER_INDEX );
78+ map .put (mn , APP_LOADER_NAME );
8079 }
8180 }
8281 }
@@ -85,12 +84,12 @@ private static final class Mapper implements Function<String, ClassLoader> {
8584
8685 @ Override
8786 public ClassLoader apply (String name ) {
88- Integer loader = map .get (name );
89- if (loader == APP_LOADER_INDEX ) {
87+ String loader = map .get (name );
88+ if (APP_LOADER_NAME . equals ( loader ) ) {
9089 return APP_CLASSLOADER ;
91- } else if (loader == PLATFORM_LOADER_INDEX ) {
90+ } else if (PLATFORM_LOADER_NAME . equals ( loader ) ) {
9291 return PLATFORM_CLASSLOADER ;
93- } else { // BOOT_LOADER_INDEX
92+ } else {
9493 return null ;
9594 }
9695 }
0 commit comments