Bug 34214 - createPackageDeclaration on ICompilationUnit
Summary: createPackageDeclaration on ICompilationUnit
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 2.1 RC3   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-08 21:03 EST by Pascal Rapicault CLA
Modified: 2003-03-18 13:55 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 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(...).