This is a javac bug. A type variable should not "inherit" any private members. This follows from 4.4 and 4.9.
-Neal
On 1/11/07, ... wrote:
Section 4.4 describes the members of type variables and the access to
them, including an example on page 50. Based on that description, I
would expect an access error on the reference to E.i, but this is
accepted by javac.
Did I overlook something in the JLS? If not, is this a JLS error or
a javac bug?
class X<E extends X<E>> {
private static int i;
int f() {
return E.i;
}
}