Inner classes whitepaper says,
"Nested classes of all sorts (top-level or inner) can
be imported by either kind of import statement. Class
names in import statements must be fully package qualified,
and be resolvable without reference to inheritance relations.
As in Java 1.0 it is illegal for a class and a package of the
same name to co-exist".
Since the context of the statement compraises any kind of nested
classes (inner and top-level), we conclude the piece of Java code
below ought to make compiler report an error. However, jdk12beta2
(build JDK12U) compiler does not report any error messages, during
compiling the following program:
package P;
class A {
static class P {}
}
"Nested classes of all sorts (top-level or inner) can
be imported by either kind of import statement. Class
names in import statements must be fully package qualified,
and be resolvable without reference to inheritance relations.
As in Java 1.0 it is illegal for a class and a package of the
same name to co-exist".
Since the context of the statement compraises any kind of nested
classes (inner and top-level), we conclude the piece of Java code
below ought to make compiler report an error. However, jdk12beta2
(build JDK12U) compiler does not report any error messages, during
compiling the following program:
package P;
class A {
static class P {}
}
- relates to
-
JDK-4095556 Compiler doesn't allow an inner class and a package of the same name to co-exist
- Closed