mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8198810: URLClassLoader does not specify behavior when URL array contains null
Reviewed-by: alanb, darcy, dholmes
This commit is contained in:
parent
ec495ebede
commit
fa4abe66dd
2 changed files with 54 additions and 47 deletions
|
@ -105,7 +105,8 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||||
* @exception SecurityException if a security manager exists and its
|
* @exception SecurityException if a security manager exists and its
|
||||||
* {@code checkCreateClassLoader} method doesn't allow
|
* {@code checkCreateClassLoader} method doesn't allow
|
||||||
* creation of a class loader.
|
* creation of a class loader.
|
||||||
* @exception NullPointerException if {@code urls} is {@code null}.
|
* @exception NullPointerException if {@code urls} or any of its
|
||||||
|
* elements is {@code null}.
|
||||||
* @see SecurityManager#checkCreateClassLoader
|
* @see SecurityManager#checkCreateClassLoader
|
||||||
*/
|
*/
|
||||||
public URLClassLoader(URL[] urls, ClassLoader parent) {
|
public URLClassLoader(URL[] urls, ClassLoader parent) {
|
||||||
|
@ -149,7 +150,8 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||||
* @exception SecurityException if a security manager exists and its
|
* @exception SecurityException if a security manager exists and its
|
||||||
* {@code checkCreateClassLoader} method doesn't allow
|
* {@code checkCreateClassLoader} method doesn't allow
|
||||||
* creation of a class loader.
|
* creation of a class loader.
|
||||||
* @exception NullPointerException if {@code urls} is {@code null}.
|
* @exception NullPointerException if {@code urls} or any of its
|
||||||
|
* elements is {@code null}.
|
||||||
* @see SecurityManager#checkCreateClassLoader
|
* @see SecurityManager#checkCreateClassLoader
|
||||||
*/
|
*/
|
||||||
public URLClassLoader(URL[] urls) {
|
public URLClassLoader(URL[] urls) {
|
||||||
|
@ -192,7 +194,8 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||||
* @exception SecurityException if a security manager exists and its
|
* @exception SecurityException if a security manager exists and its
|
||||||
* {@code checkCreateClassLoader} method doesn't allow
|
* {@code checkCreateClassLoader} method doesn't allow
|
||||||
* creation of a class loader.
|
* creation of a class loader.
|
||||||
* @exception NullPointerException if {@code urls} is {@code null}.
|
* @exception NullPointerException if {@code urls} or any of its
|
||||||
|
* elements is {@code null}.
|
||||||
* @see SecurityManager#checkCreateClassLoader
|
* @see SecurityManager#checkCreateClassLoader
|
||||||
*/
|
*/
|
||||||
public URLClassLoader(URL[] urls, ClassLoader parent,
|
public URLClassLoader(URL[] urls, ClassLoader parent,
|
||||||
|
@ -221,7 +224,8 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||||
* @param parent the parent class loader for delegation
|
* @param parent the parent class loader for delegation
|
||||||
*
|
*
|
||||||
* @throws IllegalArgumentException if the given name is empty.
|
* @throws IllegalArgumentException if the given name is empty.
|
||||||
* @throws NullPointerException if {@code urls} is {@code null}.
|
* @throws NullPointerException if {@code urls} or any of its
|
||||||
|
* elements is {@code null}.
|
||||||
*
|
*
|
||||||
* @throws SecurityException if a security manager exists and its
|
* @throws SecurityException if a security manager exists and its
|
||||||
* {@link SecurityManager#checkCreateClassLoader()} method doesn't
|
* {@link SecurityManager#checkCreateClassLoader()} method doesn't
|
||||||
|
@ -256,7 +260,8 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||||
* @param factory the URLStreamHandlerFactory to use when creating URLs
|
* @param factory the URLStreamHandlerFactory to use when creating URLs
|
||||||
*
|
*
|
||||||
* @throws IllegalArgumentException if the given name is empty.
|
* @throws IllegalArgumentException if the given name is empty.
|
||||||
* @throws NullPointerException if {@code urls} is {@code null}.
|
* @throws NullPointerException if {@code urls} or any of its
|
||||||
|
* elements is {@code null}.
|
||||||
*
|
*
|
||||||
* @throws SecurityException if a security manager exists and its
|
* @throws SecurityException if a security manager exists and its
|
||||||
* {@code checkCreateClassLoader} method doesn't allow
|
* {@code checkCreateClassLoader} method doesn't allow
|
||||||
|
@ -805,7 +810,8 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||||
*
|
*
|
||||||
* @param urls the URLs to search for classes and resources
|
* @param urls the URLs to search for classes and resources
|
||||||
* @param parent the parent class loader for delegation
|
* @param parent the parent class loader for delegation
|
||||||
* @exception NullPointerException if {@code urls} is {@code null}.
|
* @exception NullPointerException if {@code urls} or any of its
|
||||||
|
* elements is {@code null}.
|
||||||
* @return the resulting class loader
|
* @return the resulting class loader
|
||||||
*/
|
*/
|
||||||
public static URLClassLoader newInstance(final URL[] urls,
|
public static URLClassLoader newInstance(final URL[] urls,
|
||||||
|
@ -831,7 +837,8 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||||
* loading the class.
|
* loading the class.
|
||||||
*
|
*
|
||||||
* @param urls the URLs to search for classes and resources
|
* @param urls the URLs to search for classes and resources
|
||||||
* @exception NullPointerException if {@code urls} is {@code null}.
|
* @exception NullPointerException if {@code urls} or any of its
|
||||||
|
* elements is {@code null}.
|
||||||
* @return the resulting class loader
|
* @return the resulting class loader
|
||||||
*/
|
*/
|
||||||
public static URLClassLoader newInstance(final URL[] urls) {
|
public static URLClassLoader newInstance(final URL[] urls) {
|
||||||
|
|
|
@ -71,14 +71,14 @@ public class NullURLTest {
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
// This section should be uncommented if 8026517 is fixed.
|
|
||||||
// try {
|
try {
|
||||||
// loader = new URLClassLoader(invalidURLArray);
|
loader = new URLClassLoader(invalidURLArray);
|
||||||
// System.err.println("URLClassLoader(invalidURLArray) did not throw NPE");
|
System.err.println("URLClassLoader(invalidURLArray) did not throw NPE");
|
||||||
// failures++;
|
failures++;
|
||||||
// } catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// // expected
|
// expected
|
||||||
// }
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loader = new URLClassLoader(validURLArray, null);
|
loader = new URLClassLoader(validURLArray, null);
|
||||||
|
@ -93,14 +93,14 @@ public class NullURLTest {
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
// This section should be uncommented if 8026517 is fixed.
|
|
||||||
// try {
|
try {
|
||||||
// loader = new URLClassLoader(invalidURLArray, null);
|
loader = new URLClassLoader(invalidURLArray, null);
|
||||||
// System.err.println("URLClassLoader(invalidURLArray, null) did not throw NPE");
|
System.err.println("URLClassLoader(invalidURLArray, null) did not throw NPE");
|
||||||
// failures++;
|
failures++;
|
||||||
// } catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// // expected
|
// expected
|
||||||
// }
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loader = new URLClassLoader(validURLArray, null, null);
|
loader = new URLClassLoader(validURLArray, null, null);
|
||||||
|
@ -115,14 +115,14 @@ public class NullURLTest {
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
// This section should be uncommented if 8026517 is fixed.
|
|
||||||
// try {
|
try {
|
||||||
// loader = new URLClassLoader(invalidURLArray, null, null);
|
loader = new URLClassLoader(invalidURLArray, null, null);
|
||||||
// System.err.println("URLClassLoader(invalidURLArray, null, null) did not throw NPE");
|
System.err.println("URLClassLoader(invalidURLArray, null, null) did not throw NPE");
|
||||||
// failures++;
|
failures++;
|
||||||
// } catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// // expected
|
// expected
|
||||||
// }
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loader = URLClassLoader.newInstance(validURLArray);
|
loader = URLClassLoader.newInstance(validURLArray);
|
||||||
|
@ -137,14 +137,14 @@ public class NullURLTest {
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
// This section should be uncommented if 8026517 is fixed.
|
|
||||||
// try {
|
try {
|
||||||
// loader = URLClassLoader.newInstance(invalidURLArray);
|
loader = URLClassLoader.newInstance(invalidURLArray);
|
||||||
// System.err.println("URLClassLoader.newInstance(invalidURLArray) did not throw NPE");
|
System.err.println("URLClassLoader.newInstance(invalidURLArray) did not throw NPE");
|
||||||
// failures++;
|
failures++;
|
||||||
// } catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// // expected
|
// expected
|
||||||
// }
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loader = URLClassLoader.newInstance(validURLArray, null);
|
loader = URLClassLoader.newInstance(validURLArray, null);
|
||||||
|
@ -159,14 +159,14 @@ public class NullURLTest {
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
// This section should be uncommented if 8026517 is fixed.
|
|
||||||
// try {
|
try {
|
||||||
// loader = URLClassLoader.newInstance(invalidURLArray, null);
|
loader = URLClassLoader.newInstance(invalidURLArray, null);
|
||||||
// System.err.println("URLClassLoader.newInstance(invalidURLArray, null) did not throw NPE");
|
System.err.println("URLClassLoader.newInstance(invalidURLArray, null) did not throw NPE");
|
||||||
// failures++;
|
failures++;
|
||||||
// } catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// // expected
|
// expected
|
||||||
// }
|
}
|
||||||
|
|
||||||
if (failures != 0) {
|
if (failures != 0) {
|
||||||
throw new Exception("URLClassLoader NullURLTest had "+failures+" failures!");
|
throw new Exception("URLClassLoader NullURLTest had "+failures+" failures!");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue