Bug 132576 - Default package has no subpackages
Summary: Default package has no subpackages
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 RC4   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 125486
  Show dependency tree
 
Reported: 2006-03-20 13:38 EST by Markus Keller CLA
Modified: 2007-06-21 12:12 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2006-03-20 13:38:01 EST
I20060315-1200

The IPackageFragment of a default package should always answer false to #hasSubpackages(). See JLS3 7.4.2: "Note that an unnamed package cannot have subpackages, since the syntax of a package declaration always includes a reference to a named top level package."

Currently, it returns true if the package fragment root has packages other than the default.
Comment 1 Jerome Lanneluc CLA 2007-06-21 11:44:55 EDT
Unfortunately, the spec for IPackageFragment#hasSubpackages() is slightly different. It says that it "returns whether this package fragment's name is a prefix of other package fragments in this package fragment's root".
Since the name of the default package fragment is "", it is always a prefix of any other package fragment's name (if any).
This cannot be changed without breaking the IPackageFragment's spec.
Comment 2 Victor Toni CLA 2007-06-21 12:03:35 EDT
(In reply to comment #1)
> Since the name of the default package fragment is "", it is always a prefix of
> any other package fragment's name (if any).

I disagree since packages have a separator which is ".". If other packages should be treated as subpackages of "" their names should be something like ".my.own.subpackage" which is not a valid package name.
Comment 3 Jerome Lanneluc CLA 2007-06-21 12:12:34 EDT
(In reply to comment #2)
> I disagree since packages have a separator which is ".". If other packages
> should be treated as subpackages of "" their names should be something like
> ".my.own.subpackage" which is not a valid package name.
Yes, this is what JLS3 7.4.2 says. However IPackageFragment#hasSubpackages() is not compatible with JLS3 7.4.2 (since it is using the word 'prefix' and an empty string is always a prefix of any string).
So if you wish, you can enter a feature request to ask for a new API that corresponds to JLS3 7.4.2.