harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jimmy, Jing Lv (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-2237) [classlib][luni]URLClassLoader should not throw NullPointerException in special cases.
Date Mon, 20 Nov 2006 05:49:02 GMT
[classlib][luni]URLClassLoader should not throw NullPointerException in special cases.
--------------------------------------------------------------------------------------

                 Key: HARMONY-2237
                 URL: http://issues.apache.org/jira/browse/HARMONY-2237
             Project: Harmony
          Issue Type: Bug
            Reporter: Jimmy, Jing Lv


Hi,
     URLClassLoader should not throw NullPointerException in a special case, testcase:
public class TestURLClassLoader extends TestCase {
    public void test_getResource() throws Exception {
        String classPath = System.getProperty("java.class.path");
        URL url = new URL("file:"
                + new StringTokenizer(classPath, File.pathSeparator)
                        .nextToken() + Support_Resources.RESOURCE_PACKAGE
                + "subfolder/");
        ClassLoader URLLoader = new URLClassLoader(new URL[]{url}, null);
        URLLoader = getURLClassLoader();
        URLLoader.getResource("XXX");
    }
    
    static URLClassLoader getURLClassLoader() {
        String classPath = System.getProperty("java.class.path");
        StringTokenizer tok = new StringTokenizer(classPath, File.pathSeparator);
        Vector urlVec = new Vector();
        String resPackage = Support_Resources.RESOURCE_PACKAGE;
        try {
            while (tok.hasMoreTokens()) {
                String path = (String) tok.nextToken();
                String url;
                if (new File(path).isDirectory())
                    url = "file:" + path + resPackage + "subfolder/";
                else
                    url = "jar:file:" + path + "!" + resPackage + "subfolder/";
                urlVec.addElement(new URL(url));
            }
        } catch (MalformedURLException e) {
        }
        URL[] urls = new URL[urlVec.size()];
        for (int i = 0; i < urlVec.size(); i++)
            urls[i] = (URL) urlVec.elementAt(i);
        URLClassLoader loader = new URLClassLoader(urls, null);
        return loader;
    }
}

      RI passes, and Harmony throws a NPE. 



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message