If you compile the following two classes, class X will get a warning of the form:
x/X.java:6: Note: Method void foo() in class x.X does not override the corresponding method in class a.A, which is private to a different package.
void foo() {
^
1 warning
This is bogus. If A.foo() were private, no warning would be generated.
This is a situation where the compiler should be silent. I should be
able to add a new package-accessible method to my classes without worrying
that I may generate warnings to every user about something that doesn't matter
to them (that I have an inaccessible member of the same name).
Here's the source
package a;
import x.X;
public class A {
void foo() { }
public static void main(String[] args) {
X xref = new X();
xref.foo();
}
}
package x;
import a.*;
public class X extends A {
void foo() {
System.out.println("X's foo");
}
}
x/X.java:6: Note: Method void foo() in class x.X does not override the corresponding method in class a.A, which is private to a different package.
void foo() {
^
1 warning
This is bogus. If A.foo() were private, no warning would be generated.
This is a situation where the compiler should be silent. I should be
able to add a new package-accessible method to my classes without worrying
that I may generate warnings to every user about something that doesn't matter
to them (that I have an inaccessible member of the same name).
Here's the source
package a;
import x.X;
public class A {
void foo() { }
public static void main(String[] args) {
X xref = new X();
xref.foo();
}
}
package x;
import a.*;
public class X extends A {
void foo() {
System.out.println("X's foo");
}
}
- relates to
-
JDK-4028226 in JDK 1.1 beta3 the correction of compiler bug 4023931 is not correct!
-
- Closed
-