RFR(M): 8150635: j.l.i.MethodHandles.loop(...) throws IndexOutOfBoundsException

Michael Haupt michael.haupt at oracle.com
Mon Feb 29 13:39:57 UTC 2016

Hi Paul,

thank you for your comments. BTW I filed a CCC request in the meantime, as this change also affects the details of when exceptions are thrown. Answers below ...

> Am 29.02.2016 um 12:23 schrieb Paul Sandoz <paul.sandoz at oracle.com>:
> MethodHandles.java
> ...
> You can use List.of() (or before that method was added Collections.emptyList()) for the empty list as the returned lists will be unmodifiable (that returned from MethodType.parameterList is).

Right, thanks.

> We also know in the second case that the stream can never be empty so arguably a get is sufficient, but that is just a trivial comment (really we want to assert, and the second best thing there would be a orElseThrow, but it looks odd in this context perhaps).

Indeed the list cannot be empty, and the stream will always produce a result, so get() it is. Thanks!

>> * @apiNote Example:
>> * <blockquote><pre>{@code
>> * // iterative implementation of the factorial function as a loop handle
>> * static int one(int k) { return 1; }
>> * int inc(int i, int acc, int k) { return i + 1; }
>> ...
> Do you need to update this example since it is referring to virtual methods? since you need to permute the arguments.

I've updated it to use static methods only, which was the intent, and which is what JavaDocExamplesTest covers. A test for using virtual methods was added anyway.

> T8139885.java
> Could we rename that test to say “LoopCombinatorTest” ?

With more and more bugs being covered by this test, that clearly makes sense. :-) I like the suggestion to split the test in several ones you made in http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-February/039138.html - I've filed the RFE here: https://bugs.openjdk.java.net/browse/JDK-8150832

A new webrev with the above changes (save the renaming) is at http://cr.openjdk.java.net/~mhaupt/8150635/webrev.01




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

More information about the core-libs-dev mailing list