Bug 25478 - Unresolvable import statements Problem Marker malfunctioning
Summary: Unresolvable import statements Problem Marker malfunctioning
Status: RESOLVED WORKSFORME
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 M4   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-28 19:02 EST by Andrew Morovati CLA
Modified: 2003-03-23 12:32 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 Andrew Morovati CLA 2002-10-28 19:02:58 EST
Compiler not catching an unresolvable import statement. Example: 
import javax.security.*;

or 

import org.apache.*;

compiler allows both.

My current settings:
1. Preferences -> Java -> Compiler ->Problem Markers -> Unresolvable Import 
Statements set to 'Error'

2. Compiler Compliance Level set to 1.4
3. Use default compliance settings is checked
Comment 1 Philipe Mulet CLA 2002-10-29 04:09:16 EST
Known issue with us considering intermediate empty folders as packages.
Comment 2 Kent Johnson CLA 2002-11-18 17:35:32 EST
In the R2.1 M3 build, unused imports are flagged as warnings.

Is it sufficient to flag these import statements as warnings?
Comment 3 Andrew Morovati CLA 2002-11-18 20:06:16 EST
I discovered the issue when trying to compile source with the unresolvable 
import. javac 1.4.1 would fail. So if it fails, I would say that eclipse 
should fail to compile it as well. I don't think a warning is sufficient.
Comment 4 Kent Johnson CLA 2002-11-19 11:27:46 EST
The last time we looked at this, we found that javac only reports an error in 
some cases.

We found some cases in which they didn't report a problem at all.
Comment 5 Kent Johnson CLA 2002-11-19 15:20:05 EST
'Uused imports' can be toggled to an error in the Window->Preferences->Java-
>Compiler page.
Comment 6 Andrew Morovati CLA 2002-11-19 15:37:01 EST
The problem is not with unused imports it is with invalid ones. Flagging 
unused imports as errors is a nice feature, but I'm saying that in Eclipse 
this trivial class compiles:

import javax.xml.*;
public class Test
{
}

but in javac it is an error. There is no package javax.xml there are only 
subpackages in j2sdk1.4.1. I think Eclipse should pick that up. What compiler 
is it using?
Comment 7 Kent Johnson CLA 2002-11-19 15:50:03 EST
When you create a new package 'p1.p2', when does it become a package from which 
you can import classes? Right away or after you've added the first type?

An unresolvable import statement references a package that does not exist. Not 
one that has yet to define its first type.
Comment 8 Andrew Morovati CLA 2002-11-19 16:00:56 EST
So the sun compiler is wrong?
Comment 9 Kent Johnson CLA 2002-11-19 16:17:24 EST
The politically correct answer is its inconsistent. In some cases, it considers 
importing 'resolveable empty' packages as errors... and in some other cases, it 
doesn't.

We would prefer to treat an unused import as a warning/error, depending on your 
preference.

The Sun supplied compiler test suite does not include any tests which expect 
this case to be treated as an error. We are not breaking compliance by 
considering this as a warning instead of an error by default.
Comment 10 Andrew Morovati CLA 2002-11-19 16:46:02 EST
I'll set my preferences accordingly
Comment 11 Kent Johnson CLA 2002-11-20 14:57:11 EST
Closing.