-
Bug
-
Resolution: Fixed
-
P3
-
5.0, 6
-
b67
-
generic, x86
-
linux, solaris_8
-
Verified
I believe the process by which we compute a performing a wildcard capture
conversion should include the formal type parameter's bounds in the result,
using glb(). The following example shows why. In this case we have an example
of G1<? extends I2> being a subtype of G1<?>, yet an operation that succeeds on
the latter will fail on the former.
==========$ cat -n T.java
1 interface I1 {
2 void i1();
3 }
4
5 class G1<T extends I1> {
6 T get() { return null; }
7 }
8
9 interface I2 {
10 void i2();
11 }
12
13 class Main {
14 void f1(G1<?> g1) {
15 g1.get().i1();
16 }
17 void f2(G1<? extends I2> g1) {
18 g1.get().i1(); // oops!
19 g1.get().i2();
20 }
21 }
==========$ javac T.java
T.java:18: cannot find symbol
symbol : method i1()
location: interface I2
g1.get().i1(); // oops!
^
1 error
==========$
conversion should include the formal type parameter's bounds in the result,
using glb(). The following example shows why. In this case we have an example
of G1<? extends I2> being a subtype of G1<?>, yet an operation that succeeds on
the latter will fail on the former.
==========$ cat -n T.java
1 interface I1 {
2 void i1();
3 }
4
5 class G1<T extends I1> {
6 T get() { return null; }
7 }
8
9 interface I2 {
10 void i2();
11 }
12
13 class Main {
14 void f1(G1<?> g1) {
15 g1.get().i1();
16 }
17 void f2(G1<? extends I2> g1) {
18 g1.get().i1(); // oops!
19 g1.get().i2();
20 }
21 }
==========$ javac T.java
T.java:18: cannot find symbol
symbol : method i1()
location: interface I2
g1.get().i1(); // oops!
^
1 error
==========$
- duplicates
-
JDK-6207912 Wildcard capture reported incompatible with wildcard use
- Closed
- relates to
-
JDK-5049523 Inference should compute glb of type arguments
- Closed
-
JDK-6180021 REGRESSION: javac throws exception: CompletionFailure during TypeTrans
- Closed
-
JDK-6268476 Arrays and super wildcards broken
- Closed
-
JDK-5003431 java.lang.Object cannot be dereferenced
- Closed