harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexey Varlamov (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HARMONY-3368) [drlvm][kernel] Unnecessary NPE creation and catching in ClassLoader.getResourceAsStream(String)
Date Tue, 13 Mar 2007 07:17:09 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-3368?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Alexey Varlamov updated HARMONY-3368:
-------------------------------------

    Component/s:     (was: Classlib)
                 DRLVM
        Summary: [drlvm][kernel] Unnecessary NPE creation and catching in ClassLoader.getResourceAsStream(String)
 (was: Unnecessary NPE creation and catching in ClassLoader.getResourceAsStream(String))

> [drlvm][kernel] Unnecessary NPE creation and catching in ClassLoader.getResourceAsStream(String)
> ------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-3368
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3368
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Sergey Dmitriev
>
> As per 516732 revision VM class ClassLoader's method getResourceAsStream(String) creates
and catches NullPointerException in case of needed resource absence.
> -- ClassLoader.java --
>    221      /**
>    222       * @com.intel.drl.spec_ref 
>    223       */
>    224      public InputStream getResourceAsStream(String name) {
>    225          URL foundResource = getResource(name);
>    226          try {
>    227              return foundResource.openStream();
>    228          } catch (IOException e) {
>    229          } catch (NullPointerException e) {
>    230          }
>    231          return null;
>    232      }
> It is worthy to replace "catch NullPointerException" with "if (foundResource == null)"
-- thus we can avoind useless creation of NPE's objects.
> I didn't make deep analysis here, but - for example - starting up Eclipse with simple
HelloWorld project auto-open shows about a hundled of such NPE creations in ClassLoader.getResourceAsStream(String).
Just for your information.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message