--- a/jdk/test/java/lang/invoke/LoopCombinatorTest.java Fri Apr 22 13:36:22 2016 +0200
+++ b/jdk/test/java/lang/invoke/LoopCombinatorTest.java Fri Apr 22 15:05:26 2016 +0200
@@ -30,6 +30,7 @@
* @bug 8150957
* @bug 8152667
* @bug 8153637
+ * @bug 8154751
* @run testng/othervm -ea -esa test.java.lang.invoke.LoopCombinatorTest
*/
@@ -348,6 +349,23 @@
}
@Test
+ public static void testCountedLoopEmpty() throws Throwable {
+ // for (int i = 0; i < 5; ++i) { /* empty */ }
+ MethodHandle loop = MethodHandles.countedLoop(MethodHandles.constant(int.class, 5), null, null);
+ assertEquals(methodType(void.class), loop.type());
+ loop.invoke();
+ }
+
+ @Test
+ public static void testCountedRangeLoopEmpty() throws Throwable {
+ // for (int i = -5; i < 5; ++i) { /* empty */ }
+ MethodHandle loop = MethodHandles.countedLoop(MethodHandles.constant(int.class, -5),
+ MethodHandles.constant(int.class, 5), null, null);
+ assertEquals(methodType(void.class), loop.type());
+ loop.invoke();
+ }
+
+ @Test
public static void testIterateSum() throws Throwable {
// Integer[] a = new Integer[]{1,2,3,4,5,6}; int sum = 0; for (int e : a) { sum += e; } return sum; => 21
MethodHandle loop = MethodHandles.iteratedLoop(Iterate.MH_sumIterator, Iterate.MH_sumInit, Iterate.MH_sumStep);