Javac Bug/Specification Question

Richard Warburton richard.warburton at gmail.com
Wed Apr 6 16:22:26 PDT 2011


Hello,

I hope this is an acceptable place to ask about this issue.  I would
report a bug, except that I'm not entirely sure it is a bug, and I've
seen similar issues discussed on here before.  Essentially I have a
program that compiles fine in Eclipse, but doesn't using javac.  I
suspect this is due to a generics/inference bug.  The problem is that
when inferring a type of Foo<? super T> that is passed a instance some
concrete type javac infers the type Foo<Object>.  I have put a
testcase online at:

https://github.com/RichardWarburton/Compiler-Question

This contains a 'build.sh' script that for me provides the following error:

src/JavacFail.java:18:
filter(java.util.List<java.lang.Integer>,Predicate<java.lang.Integer>)
in JavacFail cannot be applied to
(java.util.List<java.lang.Integer>,Predicate<java.lang.Object>)
                System.out.println(filter(asList(1, 2, 3), or(gt(2), lt(2))));
                                   ^
Note: src/JavacFail.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

I've also committed in the eclipse project files (in spite of usual
practice) in an effort to make it easier to test that it works under
ecj.

I've tested under both javac 1.6.0_13 and javac 1.6.0_20, the version
of eclipse that I'm using is Helios Service Release 1, build-id:
20100917-0705.

If it helps in the detection of the bug it is possible to work around
the issue by assigning the function to a seperate variable with the
type, 'Predicate<Integer>', however I consider this a bit of an
inferior solution.

regards,

  Richard



More information about the compiler-dev mailing list