Bug 30407 - AST.parseCompilationUnit(IClassFile, boolean) should not throw an IllegalArgumentException no source is available
Summary: AST.parseCompilationUnit(IClassFile, boolean) should not throw an IllegalArgu...
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M5   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-28 12:35 EST by Dirk Baeumer CLA
Modified: 2003-03-23 12:38 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2003-01-28 12:35:45 EST
IMO it is not very client friendly to throw an runtime exception in this case. 
Wouldn't it be better to return null in this case indicating that no AST can be 
build ?
Comment 1 Olivier Thomann CLA 2003-01-28 13:35:42 EST
Why would you call this API on a classfile that has no source?
Comment 2 Philipe Mulet CLA 2003-01-29 09:25:20 EST
The closest thing we could do to match the spec (no null is expected) would be 
an empty unit, but then you would need to know that no source is associated.

An exception is a better way. I agree though that IllegalArgumentExceptions are 
not very helpful in this case... could improve the message at least.

Would it be enough ?
Comment 3 Dirk Baeumer CLA 2003-01-29 09:34:45 EST
I changed our code to check if the class file as source by checking the source 
range. The reason why I filed the PR was that I wanted to avoid calling 
getSource before calling the parse method since otherwise we would 
have "created" the source twice. 

No action required from JDT/UI anymore