-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.2, 5.0
Name: jl125535 Date: 07/28/2004
FULL PRODUCT VERSION :
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 :
If I modify this sample source by relaxing X#hello's access to "package
private", the 2 lines marked as "Never OK" will pass. Nevertheless, the
compiler keeps rejecting my conditional expression.
I have to admit that expecting to access X's "private" member(s) through
its subtypes is indeed incorrect. However, I still can't figure out why
the "package private" member(s) are missing (all classes reside in the
same compilation unit which implies the same package). According to the
JLS, the members with default access are subject to inheritance.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the updated sample code.
EXPECTED BEHAVIOR :
The compile should succeed with 3 looser modifiers ("public", "protected", "package private") and fail only with the
strictest one ("private"). Currently this isn't so.
ACTUAL BEHAVIOR :
Test.java:7: cannot find symbol
symbol: method hello()
(flag ? new A() : new B()).hello();
^
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test {
public void test(boolean flag){
new X().hello(); // Always OK
new A().hello();
new B().hello();
(flag ? new A() : new B()).hello();
}
static class X {
void hello(){}
}
static class A extends X implements Runnable {
public void run(){}
}
static class B extends X implements Runnable {
public void run(){}
}
}
---------- END SOURCE ----------
(Incident Review ID: 290026)
======================================================================
###@###.### 2005-03-07 18:45:14 GMT
- duplicates
-
JDK-5082278 ConditionalExpression - flawing type inference mechanism
- Closed
-
JDK-5073060 Package private members not found for intersection types
- Closed
- relates to
-
JDK-5080917 lub computes strange compound types
- Closed