[ https://issues.apache.org/jira/browse/HARMONY-3368?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Alexey Varlamov resolved HARMONY-3368.
--------------------------------------
Resolution: Fixed
Well, really trivial to fix - done at r518614.
> [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
> Assigned To: Alexey Varlamov
>
> 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.
|