harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Dmitriev (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-3368) Unnecessary NPE creation and catching in ClassLoader.getResourceAsStream(String)
Date Mon, 12 Mar 2007 13:54:10 GMT
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: Classlib
            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