8165563: ClassLoader::getSystemClassLoader will never be null
authormchung
Thu, 08 Sep 2016 09:45:50 -0700
changeset 40796 91ffd8a6f473
parent 40795 bf74cb76388a
child 40797 4618571397a5
8165563: ClassLoader::getSystemClassLoader will never be null Reviewed-by: alanb, dholmes, psandoz
jdk/src/java.base/share/classes/java/lang/ClassLoader.java
--- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java	Thu Sep 08 16:16:44 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java	Thu Sep 08 09:45:50 2016 -0700
@@ -1167,17 +1167,7 @@
     protected final Class<?> findSystemClass(String name)
         throws ClassNotFoundException
     {
-        ClassLoader system = getSystemClassLoader();
-        if (system == null) {
-            if (!checkName(name))
-                throw new ClassNotFoundException(name);
-            Class<?> cls = findBootstrapClass(name);
-            if (cls == null) {
-                throw new ClassNotFoundException(name);
-            }
-            return cls;
-        }
-        return system.loadClass(name);
+        return getSystemClassLoader().loadClass(name);
     }
 
     /**
@@ -1437,11 +1427,7 @@
      * @since  1.1
      */
     public static URL getSystemResource(String name) {
-        ClassLoader system = getSystemClassLoader();
-        if (system == null) {
-            return BootLoader.findResource(name);
-        }
-        return system.getResource(name);
+        return getSystemClassLoader().getResource(name);
     }
 
     /**
@@ -1464,17 +1450,13 @@
      *
      * @throws  IOException
      *          If I/O errors occur
-
+     *
      * @since  1.2
      */
     public static Enumeration<URL> getSystemResources(String name)
         throws IOException
     {
-        ClassLoader system = getSystemClassLoader();
-        if (system == null) {
-            return BootLoader.findResources(name);
-        }
-        return system.getResources(name);
+        return getSystemClassLoader().getResources(name);
     }
 
     /**
@@ -1631,8 +1613,7 @@
      * this method during startup should take care not to cache the return
      * value until the system is fully initialized.
      *
-     * @return  The system <tt>ClassLoader</tt> for delegation, or
-     *          <tt>null</tt> if none
+     * @return  The system <tt>ClassLoader</tt> for delegation
      *
      * @throws  SecurityException
      *          If a security manager is present, and the caller's class loader