Details
-
Bug
-
Resolution: Fixed
-
P3
-
9
-
b157
-
Verified
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8175674 | 10 | Maurizio Cimadamore | P3 | Resolved | Fixed | b02 |
Description
This code stopped compiling after the fix for JDK-8078093:
import java.util.ArrayList;
import java.util.Collection;
public class Foo {
static <T> T foo(Class<T> c, Collection<? super T> baz) {
return null;
}
static void bar(String c) {
}
@SuppressWarnings("unchecked")
public static void main(String[] args) {
// this works
bar(foo(String.class, new ArrayList<String>()));
// this works with a warning
String s = foo(String.class, new ArrayList());
bar(s);
// this causes an error on JDK9
bar(foo(String.class, new ArrayList()));
}
}
Moreover, the error issued is weird-looking:
Foo.java:23: error: method bar in class Foo cannot be applied to given types;
bar(foo(String.class, new ArrayList()));
^
required: String
found: String
reason: argument mismatch; Object cannot be converted to String
1 error
import java.util.ArrayList;
import java.util.Collection;
public class Foo {
static <T> T foo(Class<T> c, Collection<? super T> baz) {
return null;
}
static void bar(String c) {
}
@SuppressWarnings("unchecked")
public static void main(String[] args) {
// this works
bar(foo(String.class, new ArrayList<String>()));
// this works with a warning
String s = foo(String.class, new ArrayList());
bar(s);
// this causes an error on JDK9
bar(foo(String.class, new ArrayList()));
}
}
Moreover, the error issued is weird-looking:
Foo.java:23: error: method bar in class Foo cannot be applied to given types;
bar(foo(String.class, new ArrayList()));
^
required: String
found: String
reason: argument mismatch; Object cannot be converted to String
1 error
Attachments
Issue Links
- backported by
-
JDK-8175674 Regression in generic method unchecked calls
- Resolved
- relates to
-
JDK-8135087 Erasure for unchecked invocation happens after inference
- Open
-
JDK-8078093 Severe compiler performance regression Java 7 to 8 for nested method invocations
- Closed
-
JDK-8176534 Missing check against target-type during applicability inference
- Closed
-
JDK-8176534 Missing check against target-type during applicability inference
- Closed