-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.1.4
-
generic
-
generic
allan.jacobs@Eng 1997-10-19
A local, inner class cannot be instantiated inside a block in the
same method in which the inner class is declared.
algol% which java
/usr/java/bin/java
algol% java -fullversion
java full version "1.1.4n:1997.10.16"
algol% setenv CLASSPATH .
algol% cat X.java
class X {
int a;
X() {
a = 1;
}
void func() {
X ox ;
{ // Block
ox = new X();
System.out.println("ox.a="+ox.a+" (expect 1)");
}
{ // Block
class Y { // Local class declaration
public int x;
{
x = 4;
}
}
{ // Block
Y oy = new Y();
System.out.println("oy.x="+oy.x+" (expect 4)");
}
}
}
public static void main(String[] argv)
{
new X(). func();
System.exit(0);
}
}
algol% javac -d . X.java
X.java:21: Class Y not found in type declaration.
Y oy = new Y();
^
X.java:21: Class Y not found in type declaration.
Y oy = new Y();
^
2 errors
- duplicates
-
JDK-4037577 A block scoped class isn't seen by a reference from a nested block
-
- Closed
-