[otj-users] peculiarities of default package?
Stephan Herrmann
stephan at cs.tu-berlin.de
Mon Oct 17 19:49:03 CEST 2005
> I just realized that a class in a package cannot inherit a class in the
> default package. I.e.
>
> class p.Foo cannot inherit class Bar.
>
> Any idea why this is so?
I don't think, Java would allow "import Bar;" either, importing needs
an explicit package.
> As we're using the very same resolving mechanism for
> connecting the base class, a baseclass in the default package isn't possible
> either.
Hm, I wasn't aware of that.
> Do we want to support this? Or is the default package doomed to be a
> second-class citizen?
(The new-class-wizard warns you, if you create a class in the default package..)
Here is an quote from a discussion regarding an assumed bug I reported
at the Eclipse site:
"Types in the default package are special. They are only visible to other types
in the default package."
(The issue I raise back then was that the compiler accepts a toplevel
package and a type in the default package having the same name,
which in other cases would trigger a compile error
"The type {0} collides with a package")
I'm not even sure "the default package" is correct, I seem to remember that
multiple default packages my coexist in different locations, each forming
a separate name-space! Correct me if I'm right ;-)
No, lets not try to repair Java's semantics of the default package.
It seems to be just a broken concept to begin with..
Stephan
More information about the otj-users
mailing list