I'm doing a stupid little program to try to find a bug in applet loading.
I needed my Applet subclass A to implement a protocol, so I declared a
protocol D that just has init() in it.
The compiler doesn't like having a protected
method in a protocol. Isn't it a valid thing to do?
If not, at least the error message should say so.
Instead, the compiler seems to ignore the "protected"
(substituting "public") in the interface.
Here's the error message I get:
yojimbo% javac A.java
A.java:6: Methods can't be overridden to be more private. Method void init() is public in interface D.
protected void init() {
^
1 error
-------------- A.java --------------
import browser.Applet;
class A extends Applet implements D {
B myB;
protected void init() {
myB = new B();
System.out.println("B is: " + myB);
}
}
-------------- D.java --------------
interface D {
protected void init();
}
I needed my Applet subclass A to implement a protocol, so I declared a
protocol D that just has init() in it.
The compiler doesn't like having a protected
method in a protocol. Isn't it a valid thing to do?
If not, at least the error message should say so.
Instead, the compiler seems to ignore the "protected"
(substituting "public") in the interface.
Here's the error message I get:
yojimbo% javac A.java
A.java:6: Methods can't be overridden to be more private. Method void init() is public in interface D.
protected void init() {
^
1 error
-------------- A.java --------------
import browser.Applet;
class A extends Applet implements D {
B myB;
protected void init() {
myB = new B();
System.out.println("B is: " + myB);
}
}
-------------- D.java --------------
interface D {
protected void init();
}
- duplicates
-
JDK-1228503 protected methods permitted in interfaces
-
- Closed
-