Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7179567

JCK8 tests: api/java_net/URLClassLoader/index.html#Ctor3 failed with NPE

XMLWordPrintable

    • b115
    • x86
    • windows_xp
    • Verified

      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.

            bpb Brian Burkhalter
            dpochepk Dmitrij Pochepko
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: