src/java.base/share/classes/java/lang/ClassLoader.java
changeset 50634 c349d409262a
parent 49528 c1eb35eb5f38
child 52220 9c260a6b6471
equal deleted inserted replaced
50633:b8055b38b252 50634:c349d409262a
    57 import java.util.concurrent.ConcurrentHashMap;
    57 import java.util.concurrent.ConcurrentHashMap;
    58 import java.util.function.Supplier;
    58 import java.util.function.Supplier;
    59 import java.util.stream.Stream;
    59 import java.util.stream.Stream;
    60 import java.util.stream.StreamSupport;
    60 import java.util.stream.StreamSupport;
    61 
    61 
       
    62 import jdk.internal.loader.BuiltinClassLoader;
    62 import jdk.internal.perf.PerfCounter;
    63 import jdk.internal.perf.PerfCounter;
    63 import jdk.internal.loader.BootLoader;
    64 import jdk.internal.loader.BootLoader;
    64 import jdk.internal.loader.ClassLoaders;
    65 import jdk.internal.loader.ClassLoaders;
    65 import jdk.internal.misc.Unsafe;
    66 import jdk.internal.misc.Unsafe;
    66 import jdk.internal.misc.VM;
    67 import jdk.internal.misc.VM;
   244     private final String name;
   245     private final String name;
   245 
   246 
   246     // the unnamed module for this ClassLoader
   247     // the unnamed module for this ClassLoader
   247     private final Module unnamedModule;
   248     private final Module unnamedModule;
   248 
   249 
       
   250     // a string for exception message printing
       
   251     private final String nameAndId;
       
   252 
   249     /**
   253     /**
   250      * Encapsulates the set of parallel capable loader types.
   254      * Encapsulates the set of parallel capable loader types.
   251      */
   255      */
   252     private static class ParallelLoaders {
   256     private static class ParallelLoaders {
   253         private ParallelLoaders() {}
   257         private ParallelLoaders() {}
   379             // no finer-grained lock; lock on the classloader instance
   383             // no finer-grained lock; lock on the classloader instance
   380             parallelLockMap = null;
   384             parallelLockMap = null;
   381             package2certs = new Hashtable<>();
   385             package2certs = new Hashtable<>();
   382             assertionLock = this;
   386             assertionLock = this;
   383         }
   387         }
       
   388         this.nameAndId = nameAndId(this);
       
   389     }
       
   390 
       
   391     /**
       
   392      * If the defining loader has a name explicitly set then
       
   393      *       '<loader-name>' @<id>
       
   394      * If the defining loader has no name then
       
   395      *       <qualified-class-name> @<id>
       
   396      * If it's built-in loader then omit `@<id>` as there is only one instance.
       
   397      */
       
   398     private static String nameAndId(ClassLoader ld) {
       
   399         String nid = ld.getName() != null ? "\'" + ld.getName() + "\'"
       
   400                                           : ld.getClass().getName();
       
   401         if (!(ld instanceof BuiltinClassLoader)) {
       
   402             String id = Integer.toHexString(System.identityHashCode(ld));
       
   403             nid = nid + " @" + id;
       
   404         }
       
   405         return nid;
   384     }
   406     }
   385 
   407 
   386     /**
   408     /**
   387      * Creates a new class loader of the specified name and using the
   409      * Creates a new class loader of the specified name and using the
   388      * specified parent class loader for delegation.
   410      * specified parent class loader for delegation.