JDK-4040517 : Bogus warning generated for "override" of inaccessible method
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 1.1
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • OS: solaris_2.5.1
  • CPU: sparc
  • Submitted: 1997-03-21
  • Updated: 1997-09-02
  • Resolved: 1997-09-02
Related Reports
Relates :  
Description
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");
    }
}

Comments
EVALUATION This warning is a bandage to warn people away from the broken spec as described in bug 4028226, and the solution to that bug will require fixing this warning as well. In the meantime, this warning is desirable, as it helps indicate that something is amiss. david.stoutamire@Eng 1997-09-02
02-09-1997