Bug 80218 - Classes in default package not resolvable
Summary: Classes in default package not resolvable
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 81782 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-12-05 07:21 EST by John Donald CLA
Modified: 2005-06-23 16:20 EDT (History)
1 user (show)

See Also:


Attachments
archive of broken project (2.54 KB, application/x-zip-compressed)
2005-06-23 14:30 EDT, Nitin Dahyabhai CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Donald CLA 2004-12-05 07:21:51 EST
Apparently the java compiler does not allow the explicit import of classes in 
the default package. Instead the compiler automatically finds the classes in 
the default package without the import statement. Eclipse has a problem here.

I have two Classes:

X.java:
public class X { }

a/Y.java:
package a;

public class Y { X mX; }

I get the following error message:
X cannot be resolved to a type	Y.java	test/a	line 2

If I try to import X explicitly as follows I get another error:

a/Y.java:
package a;
import X;
public class Y { X mX; }

The import X cannot be resolved	Y.java	test/a	line 2

I know the use of the default package is discouraged,
but some legacy code still hangs around.
Comment 1 Philipe Mulet CLA 2004-12-05 08:27:43 EST
From 1.4 on, the language spec has evolved to explicitly disallow importing from
the default package. If you want to still use this feature, you have to manually
set the compliance level back to 1.3 (see under Java compiler preferences).
Comment 2 Frederic Fusier CLA 2004-12-22 09:41:02 EST
*** Bug 81782 has been marked as a duplicate of this bug. ***
Comment 3 Nitin Dahyabhai CLA 2005-06-23 14:29:52 EDT
In 3.1RC3, setting the Compiler compilance level to 1.3 with the default
compliance settings, this is still a problem.  I ran into this while trying to
verify bug 8722.
Comment 4 Nitin Dahyabhai CLA 2005-06-23 14:30:39 EDT
Created attachment 23883 [details]
archive of broken project
Comment 5 Olivier Thomann CLA 2005-06-23 16:20:55 EDT
3.1 RC3 works perfectly fine.
In compliance 1.3, you can import from the default package. In your test case, I
don't see an import for the Util class. This means the compiler tries to find
Util in the current package, i.e. com.nitin.
You need to add:
import Util;

And then it will work fine.
Closing as INVALID.