Name: rmT116609 Date: 08/03/2004
FULL PRODUCT VERSION :
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows NT Version 4.0
A DESCRIPTION OF THE PROBLEM :
Namely, by modifying the old source I reached to a point where the accessibility of a member A#hello began to depend on the "character" of its subclasses.
The masking of some member by _dummy_ interfaces can't be an intended behaviour.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the sample code provided.
In the beginning it works just fine. But if you remove the commentary from line 15 so that the class B starts to implement dummy interfaces X, Y and Z, the javac fails.
After that you should modify A#hello's access modifier (please see the related bug's #5079756 description). If it's "public", everything succeeds. If it's "protected", the compiler complains that the member is inaccessible (specific to this report). If it's "package private" the compiler also fails but with a different message (specific to the aforementioned report/bug).
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I'd expect the source to compile in all 3 cases (A#hello's access is either "public", "protected" or "package private") no matter how much interfaces the class B implements.
ACTUAL -
*) Using modifier "protected":
Bug_003.java:7: hello() has protected access in Bug_003.A
(flag ? new B() : new C()).hello();
*) Using modifier "package private":
Bug_003.java:7: cannot find symbol
symbol: method hello()
(flag ? new B() : new C()).hello();
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Bug_003 {
public void test(boolean flag){
new A().hello(); // Always OK
new B().hello(); // Always OK
new C().hello(); // Always OK
(flag ? new B() : new C()).hello(); // Fails or succeeds depending on the content at line 15!
}
static class A {
protected void hello(){}
}
// Uncommenting this makes #hello inaccessible!?
static class B extends A implements Runnable /*, X, Y, Z*/ {
public void run(){}
}
static class C extends A implements Runnable, X, Y, Z {
public void run(){}
}
interface X {}
interface Y extends X {}
interface Z extends X {}
}
---------- END SOURCE ----------
(Incident Review ID: 295522)
======================================================================
- duplicates
-
JDK-5079756 Conditional operator misinterprets/mixes up access modifiers for polymorph
- Closed