Bug 30407

Summary: AST.parseCompilationUnit(IClassFile, boolean) should not throw an IllegalArgumentException no source is available
Product: [Eclipse Project] JDT Reporter: Dirk Baeumer <dirk_baeumer>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3    
Version: 2.1   
Target Milestone: 2.1 M5   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

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