Proposed API for JEP 259: Stack-Walking API
Remi Forax
forax at univ-mlv.fr
Wed Nov 4 13:00:57 UTC 2015
----- Mail original -----
> De: "Paul Sandoz" <paul.sandoz at oracle.com>
> Cc: core-libs-dev at openjdk.java.net
> Envoyé: Mercredi 4 Novembre 2015 10:57:41
> Objet: Re: Proposed API for JEP 259: Stack-Walking API
>
>
> > On 4 Nov 2015, at 10:03, Remi Forax <forax at univ-mlv.fr> wrote:
> >
> > Hi Paul,
> >
> > The use of BaseStream was just an example, here is another one that works
> > only if the function first parameter type is declared as '? super
> > Stream<StackWalker.StackFrame>'.
> >
> > static Function<Stream<?>, Integer> counter() {
> > return stream::count;
> > }
> >
> > ...
> > StackWalker walker = ...
> > int count = walker.walk(counter());
> >
>
> Good point. Damn, i don’t like wildcards :-)
>
> The following works fine:
>
> static <T> Function<Stream<T>, Long> counter() {
> return Stream::count;
> }
>
> But there could also cases where one is stuck using a wildcard:
>
> Function<Stream<?>, Long> f = Stream::count;
Wildcards are not that complex, but because they are use-side annotations, it's really easy to forget them,
and IDEs do not help here :(
I really hope that the JEP about declaration site variance [1] will be implemented at the beginning of jdk 10,
it will remove the need of wildcards for functional interfaces.
>
> Paul.
>
Rémi
[1] http://openjdk.java.net/jeps/8043488
More information about the core-libs-dev
mailing list