-
Bug
-
Resolution: Fixed
-
P3
-
9
-
b61
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8085482 | emb-9 | Dan Smith | P3 | Resolved | Fixed | team |
JDK-8086998 | 8u65 | Dan Smith | P3 | Resolved | Fixed | b01 |
JDK-8077913 | 8u60 | Dan Smith | P3 | Resolved | Fixed | b14 |
JDK-8138431 | emb-8u65 | Unassigned | P3 | Resolved | Fixed | b01 |
JDK-8080035 | emb-8u60 | Dan Smith | P3 | Resolved | Fixed | team |
---
public class Test {
private static <T> void test(Class<? extends T> clazz, T...
instances) {}
public static void main(String[] args) {
Object obj = null;
test(obj.getClass());
}
}
---
Compiling this on:
$ javac -fullversion
javac full version "1.9.0-ea-b54"
Leads to:
---
$ javac -source 6 -bootclasspath <path-to-JDK6-rt.jar> Test.java
warning: [options] source value 1.6 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
Test.java:7: error: method test in class Test cannot be applied to given types;
Test.test(obj.getClass());
^
required: Class<? extends T>,T[]
found: Class<CAP#1>
reason: formal varargs element type CAP#1 is not accessible from class Test
where T is a type-variable:
T extends Object declared in method <T>test(Class<? extends T>,T...)
where CAP#1 is a fresh type-variable:
CAP#1 extends Object from capture of ? extends Object
1 error
2 warnings
---
Workaround is to specify the method's parameter explicitly:
Test.<Object>test(obj.getClass());
This may be caused by the fix for:
It seems it is caused by the fix for:
https://bugs.openjdk.java.net/browse/JDK-8039214
http://hg.openjdk.java.net/jdk9/dev/langtools/rev/414b82835861
- backported by
-
JDK-8077913 Varargs access check mishandles capture variables
- Resolved
-
JDK-8080035 Varargs access check mishandles capture variables
- Resolved
-
JDK-8085482 Varargs access check mishandles capture variables
- Resolved
-
JDK-8086998 Varargs access check mishandles capture variables
- Resolved
-
JDK-8138431 Varargs access check mishandles capture variables
- Resolved
- relates to
-
JDK-8049075 javac, wildcards and generic vararg method invocation not accepted
- Closed
-
JDK-8077786 Check varargs access against inferred signature
- Closed
-
JDK-8078175 Calling vararg method when inferred parameter type not accessible doesn't cause compilation error
- Closed
-
JDK-8039214 Inference should not map capture variables to their upper bounds
- Closed