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

ClassLoader.getResource fails for java/lang/ resource name

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description



      Name: skR10005 Date: 03/09/2001



      The JCK-merlin tests
      api/java_lang/ClassLoader/index.html#GetResource[ClassLoaderT113]
      api/java_lang/ClassLoader/index.html#GetResource[ClassLoaderT118]
      api/java_lang/ClassLoader/index.html#GetResources[ClassLoaderT124]
      api/java_lang/ClassLoader/index.html#GetResources[ClassLoaderT130]
      api/java_lang/ClassLoader/index.html#GetSystemResource[ClassLoaderT158]
      api/java_lang/ClassLoader/index.html#GetSystemResource[ClassLoaderT163]
      api/java_lang/ClassLoader/index.html#GetSystemResources[ClassLoaderT169]
      api/java_lang/ClassLoader/index.html#GetSystemResources[ClassLoaderT174]
      api/java_lang/ClassLoader/index.html#GetResourceAsStream[ClassLoaderT180]
      api/java_lang/ClassLoader/index.html#GetResourceAsStream[ClassLoaderT185]
      api/java_lang/ClassLoader/index.html#GetSysRscAsStream[ClassLoaderT191]
      api/java_lang/ClassLoader/index.html#GetSysRscAsStream[ClassLoaderT196]
      fail due to the same reason.

      In these tests "java/lang/" resource name is used to get resource via
      one of 6 ClassLoader methods (they are getResource, getResources,
      getSystemResource, getSystemResources, getResourceAsStream and
      getSystemResourceAsStream). The invocation <method>("java/lang/") returns
      null or empty enumeration
      if "java/lang/" subdirectory does not exist in current directory.

      It's a regression in JCK area.
      These tests have existed since JCK-122 and they always passed.
      Since JDK-merlin b44 these tests have failed.

      A short example represented this failure:
      =============================================================
      import java.net.URL;
      import java.net.URLClassLoader;
      import java.net.MalformedURLException;

      public class test {
          private String URLDIR = "file://.";
          private URLClassLoader ml1;
          
          public static void main(String[] args) {
              System.out.println(new test().ClassLoaderT113());
          }
          
          public String ClassLoaderT113() {
              // Test case setup
              try {
                  URL url = new URL(URLDIR);
                  URL[] urls = {url};
                  ml1 = new URLClassLoader(urls);
              } catch (MalformedURLException e) {
                  return "FAIL: MalformedURLException: " +
                          "parsing of URL failed: " + URLDIR;
              } catch (SecurityException se) {
                  return "Security Exception : " + se;
              }
          
              // Test case
              URL u = ml1.getResource("java/lang/");
          
              // Verification
              if (u == null) {
                  return "FAIL: getResource is null " +
                          "for class dir resource - via URLDIR";
              }
              if (!u.toString().endsWith("java/lang/")) {
                  return "FAIL: Could not get class dir resource - " +
                          "via URLDIR";
              } else {
                  return "OKAY";
              }
          }
      }
      =============================================================

      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              iris Iris Clark
              Reporter:
              serjsunw Serj Serj (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: