-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
8
-
None
-
unknown
-
generic
The following program doesn't compile:
The behavior is very counter-intuitive, but the compiler is behaving correctly - the underlying problem can be understood by looking at this simpler program (w/o enums):
class A {
private int a = 1;
static class B extends A {
void test() { Object o = a; }
}
}
However the following does:
class A {
private int a = 1;
static class B extends A {
void test() { Object o = super.a; }
}
}
This is counter-intuitive: if A.a can be referenced through super, why is A.a discarder during field resolution (I guess on the basis that 'a' is not a member of B) ?
The behavior is very counter-intuitive, but the compiler is behaving correctly - the underlying problem can be understood by looking at this simpler program (w/o enums):
class A {
private int a = 1;
static class B extends A {
void test() { Object o = a; }
}
}
However the following does:
class A {
private int a = 1;
static class B extends A {
void test() { Object o = super.a; }
}
}
This is counter-intuitive: if A.a can be referenced through super, why is A.a discarder during field resolution (I guess on the basis that 'a' is not a member of B) ?
- relates to
-
JDK-7119746 Nested enum class cannot access a private field of its enum.
- Closed
-
JDK-7122416 super field access and accessibility
- Closed