The following well-formed program is rejected by javac-ea:
package othello;
public class H extends I
{
public static void main (final String[] args)
{
q.f();
}
}
class I
{
void f () { System.out.println("I.f()"); }
private static I q;
}
class q
{
static void f () { System.out.println("q.f()"); }
}
It complains that "q" is private, i.e. it is resolving the simple name "q"
in H.main() to the private static field of H's superclass, rather than to
the package-scope type q, even though private members are not inherited.
[from Roly]
william.maddox@Eng 1999-06-23
package othello;
public class H extends I
{
public static void main (final String[] args)
{
q.f();
}
}
class I
{
void f () { System.out.println("I.f()"); }
private static I q;
}
class q
{
static void f () { System.out.println("q.f()"); }
}
It complains that "q" is private, i.e. it is resolving the simple name "q"
in H.main() to the private static field of H's superclass, rather than to
the package-scope type q, even though private members are not inherited.
[from Roly]
william.maddox@Eng 1999-06-23
- duplicates
-
JDK-4240480 name00705.html: JLS6.3 private members should not be inherited from superclasses
- Closed