Name: ouC59006 Date: 05/11/98
JDK-1.2beta4-E fails to pass new JCK test icls05992m8.
Inner Classes specification says:
"A new expression may define an anonymous class by specifying its body.
Independently, the type of a new expression may specified as the
simple name of an inner class, if an instance of the immediately
enclosing class is given as a qualifying expression before the keyword
new. The qualifying instance becomes the enclosing instance of the new
object."
Since static (top-level) inner classes can't have enclosing instance,
it is illegal to qualify 'new' keyword to create instance of static
inner class.
In concise form of the test (see source code below), compiler
allows to qualify 'new' keyword to create instance of static
inner class:
> java -fullversion
java full version "JDK1.1.6N"
> javac a.java
> jdk12e
> java -fullversion
java full version "JDK-1.2beta4-E"
> javaÓ a.java
>
--------------------a.java----------------------
class A {
static class B {}
A a = new A();
A.B b = a.new B();
}
--------------------------------------------------------------------------------
======================================================================
- duplicates
-
JDK-4225105 Odd inner class code construct causes the compiler to abort.
-
- Closed
-
-
JDK-4295650 Qualified new of static classes allowed in contradiction of the spec
-
- Closed
-