Community
Participate
Working Groups
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
Known issue with us considering intermediate empty folders as packages.
In the R2.1 M3 build, unused imports are flagged as warnings. Is it sufficient to flag these import statements as warnings?
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.
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.
'Uused imports' can be toggled to an error in the Window->Preferences->Java- >Compiler page.
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?
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.
So the sun compiler is wrong?
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.
I'll set my preferences accordingly
Closing.