Details
Description
URLClassLoader throws an NPE in constructor if first argument URLs[] is null.
According to javadoc, it throws a SecurityException only. It either should work without NPE, or declare for example IllegalArgumentException to be thrown - not NPE.
Code example:
public Status Ctor3T100() {
TestURLClassLoader ucl = null;
try {
ucl = new TestURLClassLoader(null, new ParentClassLoader(), new TestURLStreamHandlerFactory());
} catch (SecurityException se) {
return checkCreateClassLoader();
}
return Status.passed("OKAY");
}
this code throws an NPE at line: ucl = new TestURLClassLoader(null, new ParentClassLoader(), new TestURLStreamHandlerFactory());
There is also a sample code which provides non-null, but empty URLs[]. It also throws an NPE later, during findClass call.
Affected tests:
api/java_net/URLClassLoader/index.html#Ctor3[Ctor3T100]
api/java_net/URLClassLoader/index.html#Ctor3[Ctor3T103]
api/java_net/URLClassLoader/index.html#findClass[findClassT108]
api/java_net/URLClassLoader/index.html#getPermissions[getPermissionsT104]
Note: these tests are not present in JDK7 and exists only in JDK8.
According to javadoc, it throws a SecurityException only. It either should work without NPE, or declare for example IllegalArgumentException to be thrown - not NPE.
Code example:
public Status Ctor3T100() {
TestURLClassLoader ucl = null;
try {
ucl = new TestURLClassLoader(null, new ParentClassLoader(), new TestURLStreamHandlerFactory());
} catch (SecurityException se) {
return checkCreateClassLoader();
}
return Status.passed("OKAY");
}
this code throws an NPE at line: ucl = new TestURLClassLoader(null, new ParentClassLoader(), new TestURLStreamHandlerFactory());
There is also a sample code which provides non-null, but empty URLs[]. It also throws an NPE later, during findClass call.
Affected tests:
api/java_net/URLClassLoader/index.html#Ctor3[Ctor3T100]
api/java_net/URLClassLoader/index.html#Ctor3[Ctor3T103]
api/java_net/URLClassLoader/index.html#findClass[findClassT108]
api/java_net/URLClassLoader/index.html#getPermissions[getPermissionsT104]
Note: these tests are not present in JDK7 and exists only in JDK8.
Attachments
Issue Links
- relates to
-
JDK-6445180 URLClassLoader does not describe the behavior of several methods with respect to null arguments
- Closed
-
JDK-8026517 URLClassLoader constructors and newInstance() should throw NPE if URL array has a null element
- Closed