You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Ruth Cao (JIRA)" <ji...@apache.org> on 2007/02/02 07:09:05 UTC

[jira] Commented: (HARMONY-2237) [classlib][luni]URLClassLoader should not throw NullPointerException in special cases.

    [ https://issues.apache.org/jira/browse/HARMONY-2237?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12469673 ] 

Ruth Cao commented on HARMONY-2237:
-----------------------------------

It works fine. Thank you very much, Richard.



> [classlib][luni]URLClassLoader should not throw NullPointerException in special cases.
> --------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2237
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2237
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Jimmy, Jing Lv
>         Assigned To: Richard Liang
>         Attachments: Harmony-2237.diff
>
>
> 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.
-
You can reply to this email to add a comment to the issue online.