This compiles but should not. The 'protected' appears to be ignored.
interface SomeInterface
{
protected void method();
}
The description field as copied from bug report 1214648 follows:
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();
}
interface SomeInterface
{
protected void method();
}
The description field as copied from bug report 1214648 follows:
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();
}
- duplicates
-
JDK-1214648 Declaring a protected method in an interface
- Closed