-
Bug
-
Resolution: Unresolved
-
P4
-
7u51, 8u101, 9
It should never be possible to refer to a local class or member class using a binary name, because that name is not in scope (JLS 6.3).
Compile this:
public class Declarations {
public static class Inner {}
static void m() {
class Local {}
}
}
Then compile this (with previously-generated classes on the class path):
public class Uses {
Declarations$Inner y;
Declarations$1Local x;
static class SubInner extends Declarations$Inner {}
static class SubLocal extends Declarations$1Local {}
Object o2 = new Declarations$Inner() {};
Object o1 = new Declarations$1Local() {};
}
I get 2 errors in 9 (b130), 2 errors in 8 (u101), and 4 errors in 7 (u51). There should be 6 errors.
If I try compiling any single line at a time (commenting out the rest), I get no error.
If I reorder the declarations, I get different behaviors, but never all the expected errors.
Compile this:
public class Declarations {
public static class Inner {}
static void m() {
class Local {}
}
}
Then compile this (with previously-generated classes on the class path):
public class Uses {
Declarations$Inner y;
Declarations$1Local x;
static class SubInner extends Declarations$Inner {}
static class SubLocal extends Declarations$1Local {}
Object o2 = new Declarations$Inner() {};
Object o1 = new Declarations$1Local() {};
}
I get 2 errors in 9 (b130), 2 errors in 8 (u101), and 4 errors in 7 (u51). There should be 6 errors.
If I try compiling any single line at a time (commenting out the rest), I get no error.
If I reorder the declarations, I get different behaviors, but never all the expected errors.
- relates to
-
JDK-8159667 No error on reference to anonymous class binary name
- Open