< prev index next >

jdk/src/java.base/share/classes/java/lang/ClassLoader.java

Print this page

        

*** 220,229 **** --- 220,232 ---- // The parent class loader for delegation // Note: VM hardcoded the offset of this field, thus all new fields // must be added *after* it. private final ClassLoader parent; + // class loader name + private final String name; + // the unnamed module for this ClassLoader private final Module unnamedModule; /** * Encapsulates the set of parallel capable loader types.
*** 336,346 **** security.checkCreateClassLoader(); } return null; } ! private ClassLoader(Void unused, ClassLoader parent) { this.parent = parent; this.unnamedModule = SharedSecrets.getJavaLangReflectModuleAccess() .defineUnnamedModule(this); if (ParallelLoaders.isRegistered(this.getClass())) { --- 339,350 ---- security.checkCreateClassLoader(); } return null; } ! private ClassLoader(Void unused, String name, ClassLoader parent) { ! this.name = name; this.parent = parent; this.unnamedModule = SharedSecrets.getJavaLangReflectModuleAccess() .defineUnnamedModule(this); if (ParallelLoaders.isRegistered(this.getClass())) {
*** 354,363 **** --- 358,386 ---- assertionLock = this; } } /** + * Creates a new class loader of the specified name and using the + * specified parent class loader for delegation. + * + * @param name class loader name; or {@code null} if not named + * @param parent the parent class loader + * + * @throws SecurityException + * If a security manager exists and its + * {@link SecurityManager#checkCreateClassLoader()} + * method doesn't allow creation of a new class loader. + * + * @since 9 + */ + protected ClassLoader(String name, ClassLoader parent) { + this(checkCreateClassLoader(), name, parent); + } + + + /** * Creates a new class loader using the specified parent class loader for * delegation. * * <p> If there is a security manager, its {@link * SecurityManager#checkCreateClassLoader()
*** 373,385 **** * of a new class loader. * * @since 1.2 */ protected ClassLoader(ClassLoader parent) { ! this(checkCreateClassLoader(), parent); } /** * Creates a new class loader using the <tt>ClassLoader</tt> returned by * the method {@link #getSystemClassLoader() * <tt>getSystemClassLoader()</tt>} as the parent class loader. * --- 396,409 ---- * of a new class loader. * * @since 1.2 */ protected ClassLoader(ClassLoader parent) { ! this(checkCreateClassLoader(), null, parent); } + /** * Creates a new class loader using the <tt>ClassLoader</tt> returned by * the method {@link #getSystemClassLoader() * <tt>getSystemClassLoader()</tt>} as the parent class loader. *
*** 392,404 **** * If a security manager exists and its * <tt>checkCreateClassLoader</tt> method doesn't allow creation * of a new class loader. */ protected ClassLoader() { ! this(checkCreateClassLoader(), getSystemClassLoader()); } // -- Class -- /** * Loads the class with the specified <a href="#name">binary name</a>. * This method searches for classes in the same manner as the {@link --- 416,443 ---- * If a security manager exists and its * <tt>checkCreateClassLoader</tt> method doesn't allow creation * of a new class loader. */ protected ClassLoader() { ! this(checkCreateClassLoader(), null, getSystemClassLoader()); } + + /** + * Returns the name of this class loader or {@code null} if + * this class loader is not named. + * + * @return name of this class loader; or {@code null} if + * this class loader is not named. + * + * @since 9 + */ + public String getName() { + return name; + } + + // -- Class -- /** * Loads the class with the specified <a href="#name">binary name</a>. * This method searches for classes in the same manner as the {@link
< prev index next >