--- old/src/java.base/share/classes/java/lang/ClassLoader.java 2018-06-14 15:10:33.182836221 -0400 +++ new/src/java.base/share/classes/java/lang/ClassLoader.java 2018-06-14 15:10:31.496870091 -0400 @@ -59,6 +59,7 @@ import java.util.stream.Stream; import java.util.stream.StreamSupport; +import jdk.internal.loader.BuiltinClassLoader; import jdk.internal.perf.PerfCounter; import jdk.internal.loader.BootLoader; import jdk.internal.loader.ClassLoaders; @@ -246,6 +247,9 @@ // the unnamed module for this ClassLoader private final Module unnamedModule; + // a string for exception message printing + private final String nameAndId; + /** * Encapsulates the set of parallel capable loader types. */ @@ -381,6 +385,24 @@ package2certs = new Hashtable<>(); assertionLock = this; } + this.nameAndId = nameAndId(this); + } + + /** + * If the defining loader has a name explicitly set then + * '' @ + * If the defining loader has no name then + * @ + * If it's built-in loader then omit `@` as there is only one instance. + */ + private static String nameAndId(ClassLoader ld) { + String nid = ld.getName() != null ? "\'" + ld.getName() + "\'" + : ld.getClass().getName(); + if (!(ld instanceof BuiltinClassLoader)) { + String id = Integer.toHexString(System.identityHashCode(ld)); + nid = nid + " @" + id; + } + return nid; } /**