Details
Description
Why is the following program illegal?
icho@villa127: cat T1.java
public class T1 {
T1() {
class T2 {
T2() {
class T3 {};
T3 t = new T3();
}
}
}
}
icho@villa126: javac T1.java
T1.java:6: Class T1. 1$T3 not found in type declaration.
T3 t = new T3();
^
T1.java:6: Class T1. 1$T3 not found in type declaration.
T3 t = new T3();
^
2 errors
------------------------
While the following program compiles;
public class T1 {
T1() {
class T2 {
class T3 {};
T2() {
T3 t = new T3();
}
}
}
}
icho@villa127: cat T1.java
public class T1 {
T1() {
class T2 {
T2() {
class T3 {};
T3 t = new T3();
}
}
}
}
icho@villa126: javac T1.java
T1.java:6: Class T1. 1$T3 not found in type declaration.
T3 t = new T3();
^
T1.java:6: Class T1. 1$T3 not found in type declaration.
T3 t = new T3();
^
2 errors
------------------------
While the following program compiles;
public class T1 {
T1() {
class T2 {
class T3 {};
T2() {
T3 t = new T3();
}
}
}
}
Attachments
Issue Links
- duplicates
-
JDK-4046432 Compiler failed to lookup nested class in InnerClass
- Closed
-
JDK-4054523 no access to an inner class declared in a method of another innner class
- Closed