-
Enhancement
-
Resolution: Unresolved
-
P5
-
None
-
5.0, 6
-
generic
-
generic
From: ###@###.###
Date: Sat, 02 Apr 2005 19:53:14 -0800
If I try to compile this bogus program:
class Base {
public static String getName() { return "Base"; }
}
class Derived extends Base {
private static String getName() { return "Derived"; }
}
public class PrivateMatter {
public static void main(String[] args) {
System.out.println(new Derived().getName());
}
}
The compiler saith:
PrivateMatter.java:6: getName() in Derived cannot override getName()
in Base; attempting to assign weaker access privileges; was public
private static String getName() { return "Derived"; }
^
1 error
Of course the word "override" in the diagnostic should be replaced by
the word "hide," as these are static methods and only instance methods
can be overridden.
###@###.### 2005-04-03 04:48:40 GMT
Date: Sat, 02 Apr 2005 19:53:14 -0800
If I try to compile this bogus program:
class Base {
public static String getName() { return "Base"; }
}
class Derived extends Base {
private static String getName() { return "Derived"; }
}
public class PrivateMatter {
public static void main(String[] args) {
System.out.println(new Derived().getName());
}
}
The compiler saith:
PrivateMatter.java:6: getName() in Derived cannot override getName()
in Base; attempting to assign weaker access privileges; was public
private static String getName() { return "Derived"; }
^
1 error
Of course the word "override" in the diagnostic should be replaced by
the word "hide," as these are static methods and only instance methods
can be overridden.
###@###.### 2005-04-03 04:48:40 GMT
- duplicates
-
JDK-6558589 Wrong error message, should be "hidden", not "override"
- Closed
- relates to
-
JDK-6793555 method clash diagnostic does not distinguish between hiding and overriding
- Open