JDK-8150956 : j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang.invoke
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2016-03-01
  • Updated: 2017-05-17
  • Resolved: 2016-04-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b116Fixed
Related Reports
Blocks :  
Description
According to documentation j.l.i.MethodHandles.whileLoop(MethodHandle, MethodHandle, MethodHandle), 'init' might be void:

Passing void init function will make the loop's result type void.

Attached code provides example which throw IllegalArgumentException; 'java.lang.IllegalArgumentException: parameter type cannot be void'


Was found on jdk9b107, tests are in development, tck_red label will be added after tests development completion.
Comments
For a similar iteratedLoop test case that passes an iterator and has a void init, the same error as with whileLoop is observable.
14-04-2016

[~asolodkaya], the additional example around iteratedLoop() does not address the same issue. It breaks because the iterator handle, which is supposed to return an Iterator, has a void return type. I agree that this should be checked and an appropriate error message raised, and will cover this in the context of this issue.
13-04-2016

Please, check one more case (to be sure it is fixed too). Here is 'iterator' is void, MethodHandles.iteratedLoop(...)
24-03-2016

The same problem exists in MethodHandles.doWhileLoop(), .countedLoop(), and .iteratedLoop(). Once JDK-8150829 is resolved, the new convenience API it introduces will allow for an easy fix.
01-03-2016