Bug 34214

Summary: createPackageDeclaration on ICompilationUnit
Product: [Eclipse Project] JDT Reporter: Pascal Rapicault <pascal>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3    
Version: 2.1   
Target Milestone: 2.1 RC3   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Pascal Rapicault CLA 2003-03-08 21:03:38 EST
Why does the createPackageDeclaration on an ICompilationUnit
throws an error when the package name given as a parameter is "".
Comment 1 Philipe Mulet CLA 2003-03-09 05:39:47 EST
What would you expect ? This is a bogus situation...

Comment 2 Olivier Thomann CLA 2003-03-10 09:03:09 EST
Do you get a JavaModelException? I think this is perfectly normal according to
the specs.
Comment 3 Pascal Rapicault CLA 2003-03-10 09:08:46 EST
I would expect it to return the default package.
Comment 4 Olivier Thomann CLA 2003-03-10 09:10:39 EST
There is no reason to create a package declaration for the default package, 
because the default package means that you DON'T have a package declaration. 
The API states that you need to provide a valid package name and "" is not a 
valid package name.
Comment 5 Olivier Thomann CLA 2003-03-10 13:17:57 EST
For me the problem comes from the getPackageDeclaration(String) method. This
method returns the default package declaration when called with an empty string.
getPackageDeclarations() returns an empty list in case the compilation unit is
in the default package.
getPackageDeclaration(String) should throw a JavaModelException in case it is
called with a name which is not a valid package name.
Comment 6 Olivier Thomann CLA 2003-03-18 13:55:09 EST
This is not a bug. We follow the specs.
"" is not a valid package name and therefore should not be used by 
createPackageDeclaration(...).