From 22e95f995a6189eefae99123c4d49801b4b4b47a Mon Sep 17 00:00:00 2001 From: Michael Haupt Date: Fri, 19 Aug 2016 10:03:43 +0200 Subject: [PATCH] 8164102: MethodHandles.countedLoop/4 works incorrect for start/end = Integer.MAX_VALUE Reviewed-by: redestad --- .../java/lang/invoke/MethodHandleImpl.java | 2 +- .../java/lang/invoke/MethodHandles.java | 11 +-- .../CountedLoopIterationCountsTest.java | 90 +++++++++++++++++++ 3 files changed, 97 insertions(+), 6 deletions(-) create mode 100644 jdk/test/java/lang/invoke/CountedLoopIterationCountsTest.java diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java index a0561589beb..d17f0c53f83 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java @@ -1934,7 +1934,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; * @return whether the counter has reached the limit. */ static boolean countedLoopPredicate(int counter, int limit) { - return counter <= limit; + return counter < limit; } /** diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java index 81dedf3090d..a02e2f18b23 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java @@ -4583,7 +4583,8 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum")); * // assume MH_decrement is a handle to x-1 of type int * MethodHandle[] * indexVar = {start, MH_increment}, // i = start; i = i+1 - * loopLimit = {end, null, MH_lessThan, returnVar }, // i