Bug: NullPointerException in type inferencer

Thomas Jung thomas.andreas.jung at googlemail.com
Sat Aug 7 12:12:55 PDT 2010


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