javac accepts the following program if both classes are compiled from source, but rejects it if B is compiled from source and A is on the classpath. I expected the two cases to be consistent.
I reproduced with 9-ea+165, but it affects all versions I tried back to 1.6.0-b105.
=== A.java
import java.util.Map;
abstract class A {
interface I<X extends String> {}
abstract void f(Map<String, I<?>> i);
}
=== B.java
import java.util.Map;
public class B {
void f(A a, Map<String, A.I<? extends String>> x) {
a.f(x);
}
}
===
$ javac -sourcepath : A.java B.java
... OK
$ javac -sourcepath : B.java
B.java:4: error: incompatible types: Map<String,I<? extends String>> cannot be converted to Map<String,I<?>>
a.f(x);
^
I reproduced with 9-ea+165, but it affects all versions I tried back to 1.6.0-b105.
=== A.java
import java.util.Map;
abstract class A {
interface I<X extends String> {}
abstract void f(Map<String, I<?>> i);
}
=== B.java
import java.util.Map;
public class B {
void f(A a, Map<String, A.I<? extends String>> x) {
a.f(x);
}
}
===
$ javac -sourcepath : A.java B.java
... OK
$ javac -sourcepath : B.java
B.java:4: error: incompatible types: Map<String,I<? extends String>> cannot be converted to Map<String,I<?>>
a.f(x);
^
- duplicates
-
JDK-8332507 compilation result depends on compilation order
- Resolved