Bug: NullPointerException in type inferencer
Thomas Jung
thomas.andreas.jung at googlemail.com
Sat Aug 7 12:50:23 PDT 2010
Predicate<? extends Integer> k = Predicates.and(#(i){i > 0},#(i){i % 2
== 0}) has the same result. And it's not terrible useful. Maybe I've
misunderstood you.
Thomas
On 7 August 2010 21:33, Neal Gafter <neal at gafter.com> wrote:
> Try using Predicate<? extends Integer> as the target type.
>
> On Saturday, August 7, 2010, Thomas Jung
> <thomas.andreas.jung at googlemail.com> wrote:
>> Hi,
>>
>> converting :
>>
>> Predicate<Integer> i = #(i){i > 0};
>> Predicate<Integer> j = #(i){i % 2 == 0};
>> Predicate<Integer> k = Predicates.and(i,j);
>>
>> with http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/base/Predicate.html
>>
>> to:
>>
>> Predicate<Integer> k = Predicates.and(#(i){i > 0},#(i){i % 2 == 0});
>>
>> results in an NullPointerException:
>>
>> java.lang.NullPointerException
>> at com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:417)
>> at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:348)
>> at com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:597)
>> at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:809)
>> at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:773)
>> at com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:1392)
>>
>> Actually, I wanted to see if type inference works from one parameter to another:
>>
>> Collections2.filter(
>> Arrays.asList(-2,-1,0,1,2,3,4),
>> Predicates.and(#(i){i > 0},#(i){i % 2 == 0});
>>
>> Thomas
>>
>>
>
More information about the lambda-dev
mailing list