Other |
---|
1.4.0 betaFixed |
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
--- Top.java --- public class Top { public class Inner {} } --- Bottom1.java --- import Top; public class Bottom1 {} --- Bottom2.java --- import Top.*; public class Bottom2 { } --- Bottom3.java --- import Top.Inner; public class Bottom3 { } --------------------- % javac Bottom.* Bottom2.java:1: package Top does not exist import Top.*; ^ Bottom3.java:1: cannot resolve symbol symbol : class Inner location: package Top import Top.Inner; ^ 2 errors ----------------------- According to JLS2e 6.3, the scope of the declaration of class Top is all type declarations in the package to which it belongs, in this case, an unnamed package including Bottom1, Bottom2, and Bottom3 as well. As a result, Bottom1.java is in error, as the declaration 'import Top;' cannot be resolved. The compiler fails to report this error. In Bottom2.java, an analogous error is detected properly. In Bottom3.java, it appears that the compiler correctly assumes that the qualified name must begin with a package name, as a type name cannot be resolved as the first component. However, the diagnostic given is quite confusing, as it points to the claimed nonexistence of a package member when in fact it is the package itself that is missing. Note that 1.3.0 reports no errors for any of these examples. The problem here is that recent fixes in the Merlin development builds aimed at addressing conformance issues with import declarations are incomplete and/or erroneous. william.maddox@Eng 2000-08-10
|