you can try this. private static Function<?,?> CASTING_IDENTITY = i -> i;
@SuppressWarnings("unchecked") private static <I, R> Function<I, R> castingIdentity() { return (Function<I, R>) CASTING_IDENTITY; } On Sat, Aug 24, 2013 at 2:10 AM, Mike Duigou <mike.dui...@oracle.com> wrote: > I considered that as well but since the types are generics you'd have to > cast anyway. > > The only viable declaration is: > > private static Function<?,?> CASTING_IDENTITY = i -> i; > > On usage you'd have to add (Function<I,R>) CASTING_IDENTITY > > (Which assumes the compiler would even accept this heinous cast, I haven't > tried it) > > Mike > > On Aug 23 2013, at 14:18 , Ali Ebrahimi wrote: > > > Why not to make castingIdentity method a constant? > > > > > > On Fri, Aug 23, 2013 at 11:47 PM, Henry Jen <henry....@oracle.com> > wrote: > > > >> Hi, > >> > >> Please kindly review the fix for eliminate some warnings in > >> java.util.stream package. > >> > >> Chained Sink is an internal implementation detail, add the type for > >> downstream is more precise but verbose. > >> > >> Included is also a couple other warnings cleanup. > >> > >> http://cr.openjdk.java.net/~henryjen/tl/8023681.0/webrev/ > >> > >> Cheers, > >> Henry > >> > >> > >