RFR 8167974 MethodHandles.iteratedLoop(...) fails with CCE in the case of iterating over array
claes.redestad at oracle.com
Mon Oct 31 23:19:36 UTC 2016
On 2016-10-31 22:47, Paul Sandoz wrote:
> And… 8167966 MethodHandles.iteratedLoop fails with IAE in the case of correct arguments.
> The two issues are closely intertwined in terms of the fix. Please review:
I think this imposes a reasonable restriction and nicely cleans up the
current specification. +1
I guess the if (!Iterable.class.isAssignableFrom(iterableType)) could
be moved inside the preceding else without losing readability.
> This is cleaning up previous specification and implementation assumptions when a null iterator method handle is passed to MethodHandles.iteratedLoop.
> The specification states that an Iterator type *or* array type is supported. Originally I think the intention was to support the equivalent of Java for-each loops, but the implementation only supports Iterator. We can revisit this in the next release if necessary.
> The implementation checking the constraints on the iterator loop method handles required some reorgnaization to clearly differentiate the checks performed if the iterator method handle is non-null or null, since it currently does not fully differentiate between the two cases leading to incorrect exceptions when the handle is non-null.
More information about the core-libs-dev