MethodHandle loop body parameters and Stream.reduce accumulator parameters are not in the same order

Michael Haupt michael.haupt at oracle.com
Tue Sep 20 13:19:54 UTC 2016


Hi Rémi,

I think you can stay tuned for the fix to JDK-8151179; part of what it addresses is just this. The changes are currently in the CCC loop but should come up for public re-review soon.

Best,

Michael

> Am 14.09.2016 um 15:19 schrieb Remi Forax <forax at univ-mlv.fr>:
> 
> Hi everybody,
> i've just found that the parameters of the body (a MethodHandle) of MethodHandles.countedLoop (both overloads) and iteratedLoop are not in the same order as the accumulator in methods Stream.reduce, given that they conceptually represent the same thing, i think the first two parameters of body should be swapped in countedLoop and iteratedLoop.
> 
> in Stream:
> <U> U reduce(U identity,
>             BiFunction<U,? super T,U> accumulator,
>             BinaryOperator<U> combiner)
> so this is equivalent to value = accumulator(value, element)
> 
> In MethodHandles:
>   MethodHandle iteratedLoop(MethodHandle iterator,
>                             MethodHandle init,
>                             MethodHandle body)
>  with value = body(element, value, iterable)
> it should be
>  value = body(value, element, iterable).
> 
> Same things for 
>   MethodHandle countedLoop(MethodHandle start,
>                            MethodHandle end,
>                            MethodHandle init,
>                            MethodHandle body)  
>  it should be
>    value = body(value, index, array); 
>  instead of
>    value = body(index, value, array);
> 
> the other loop combinators do not be to be changed.
> 
> cheers,
> Rémi
> _______________________________________________
> mlvm-dev mailing list
> mlvm-dev at openjdk.java.net
> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev

-- 

 <http://www.oracle.com/>
Dr. Michael Haupt | Principal Member of Technical Staff
Phone: +49 331 200 7277 | Fax: +49 331 200 7561
Oracle Java Platform Group | LangTools Team | Nashorn
Oracle Deutschland B.V. & Co. KG | Schiffbauergasse 14 | 14467 Potsdam, Germany

ORACLE Deutschland B.V. & Co. KG | Hauptverwaltung: Riesstraße 25, D-80992 München
Registergericht: Amtsgericht München, HRA 95603

Komplementärin: ORACLE Deutschland Verwaltung B.V. | Hertogswetering 163/167, 3543 AS Utrecht, Niederlande
Handelsregister der Handelskammer Midden-Nederland, Nr. 30143697
Geschäftsführer: Alexander van der Ven, Jan Schultheiss, Val Maher
 <http://www.oracle.com/commitment>	Oracle is committed to developing practices and products that help protect the environment

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20160920/9458dc05/attachment.html>


More information about the mlvm-dev mailing list