Trouble with wildcards

Paul Sandoz paul.sandoz at oracle.com
Tue Dec 17 03:56:14 PST 2013


On Dec 17, 2013, at 12:10 AM, Zhong Yu <zhong.j.yu at gmail.com> wrote:

> Not exactly sure what you guys are talking about... but I guess it's a
> complaint about the signature of Predicate.and()?
> 
> It might be changed to be more receptive, like
> 
>    <S extends T> Predicate<S> and(Predicate<? super S> other)
> 
> then the previous examples could be compiled, as well as this one
> 
>    Predicate<Serializable> p1 = null;
>    Predicate<CharSequence> p2 = null;
>    Predicate<String> p3 = p1.and(p2);
> 

Thanks, we used a similar trick with Comparator.thenComparing but removed it [1] and i can no longer recall why, perhaps Henry can though.

Paul.

[1] http://hg.openjdk.java.net/lambda/lambda/jdk/rev/20b3fd9c7d36

-    default <S extends T> Comparator<S> thenComparing(Comparator<? super S> other) {
+    default Comparator<T> thenComparing(Comparator<? super T> other) {


More information about the lambda-dev mailing list