Bug 39770 - ClassParser.parse() throws NullPointerException if class does not exist and ClassParser(String) constructor is used
Summary: ClassParser.parse() throws NullPointerException if class does not exist and C...
Status: RESOLVED FIXED
Alias: None
Product: BCEL - Now in Jira
Classification: Unclassified
Component: Main (show other bugs)
Version: unspecified
Hardware: All All
: P2 regression
Target Milestone: ---
Assignee: issues@commons.apache.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-09 21:23 UTC by Alex Kinneer
Modified: 2007-03-10 06:55 UTC (History)
0 users



Attachments
Patch to resolve error. (465 bytes, patch)
2006-06-09 21:24 UTC, Alex Kinneer
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Kinneer 2006-06-09 21:23:47 UTC
Reproduce:

ClassParser cp = new ClassParser("does/not/exist/Classfile.class");
JavaClass jc = cp.parse();
--> throws NullPointerException instead of FileNotFoundException

The problem is that when the constructor that accepts a string is used, the
fileOwned flag is set and parse() attempts to close the file in the finally
block. The guarded region for the finally block includes the attempt to open the
input stream, which may fail, but the finally block itself erroneously assumes
the input stream object has been created.

Previously this situation caused the method to correctly throw a
FileNotFoundException.
Comment 1 Alex Kinneer 2006-06-09 21:24:42 UTC
Created attachment 18440 [details]
Patch to resolve error.
Comment 2 Torsten Curdt 2007-03-10 06:55:10 UTC
Thanks for the patch!