javac generics bug (review-id 2356418)
Chris Dennis
cdennis at terracottatech.com
Mon Oct 8 07:39:23 PDT 2012
Hi,
I just stumbled across a javac generics issue whereby the following class fails to compile:
public class GenericTest {
public Object foo(Callable<? extends Object[]> foo) throws Exception {
return foo.call()[0];
}
}
with:
GenericTest.java:6: error: array required, but CAP#1 found
return foo.call()[0];
^
where CAP#1 is a fresh type-variable:
CAP#1 extends Object[] from capture of ? extends Object[]
1 error
You can however access .length on the ? extends Object[] typed return without any problems.
I've filed this on bugs.sun.com (2356418), but figured I would raise the issue here too since it looks like a regression that happened in 1.6 and I have a very simple reproducible test case.
Regards,
Chris Dennis
More information about the compiler-dev
mailing list