8161212: Test times out: java/lang/invoke/LoopCombinatorLongSignatureTest.java
authormhaupt
Mon, 18 Jul 2016 14:06:50 +0200
changeset 39728 148dc636692d
parent 39727 4c68ece98c47
child 39729 ef2b0635618f
8161212: Test times out: java/lang/invoke/LoopCombinatorLongSignatureTest.java Reviewed-by: redestad
jdk/test/java/lang/invoke/LoopCombinatorLongSignatureTest.java
--- a/jdk/test/java/lang/invoke/LoopCombinatorLongSignatureTest.java	Mon Jul 18 13:13:52 2016 +0800
+++ b/jdk/test/java/lang/invoke/LoopCombinatorLongSignatureTest.java	Mon Jul 18 14:06:50 2016 +0200
@@ -39,6 +39,11 @@
  * If a loop with an excessive amount of clauses is created, so that the number of parameters to the resulting loop
  * handle exceeds the allowed maximum, an IAE must be signalled. The test is run first in LambdaForm interpretation mode
  * and then in default mode, wherein bytecode generation falls back to LFI mode due to excessively long methods.
+ * <p>
+ * By default, the test run only checks whether loop handle construction succeeds and fails. If executing the generated
+ * loops is desired, this should be indicated by setting the {@code java.lang.invoke.LoopCombinatorLongSignatureTest.RUN}
+ * environment variable to {@code true}. This is disabled by default as it considerably increases the time needed to run
+ * the test.
  */
 public class LoopCombinatorLongSignatureTest {
 
@@ -51,13 +56,15 @@
     static final int ARG_LIMIT = 254; // for internal reasons, this is the maximum allowed number of arguments
 
     public static void main(String[] args) {
+        boolean run = Boolean.parseBoolean(
+                System.getProperty("java.lang.invoke.LoopCombinatorLongSignatureTest.RUN", "false"));
         for (int loopArgs = 0; loopArgs < 2; ++loopArgs) {
-            testLongSignature(loopArgs, false);
-            testLongSignature(loopArgs, true);
+            testLongSignature(loopArgs, false, run);
+            testLongSignature(loopArgs, true, run);
         }
     }
 
-    static void testLongSignature(int loopArgs, boolean excessive) {
+    static void testLongSignature(int loopArgs, boolean excessive, boolean run) {
         int nClauses = ARG_LIMIT - loopArgs + (excessive ? 1 : 0);
 
         System.out.print((excessive ? "(EXCESSIVE)" : "(LONG     )") + " arguments: " + loopArgs + ", clauses: " + nClauses + " -> ");
@@ -78,7 +85,7 @@
             MethodHandle loop = MethodHandles.loop(clauses);
             if (excessive) {
                 throw new AssertionError("loop construction should have failed");
-            } else {
+            } else if (run) {
                 int r;
                 if (loopArgs == 0) {
                     r = (int) loop.invoke();
@@ -88,6 +95,8 @@
                     r = (int) loop.invokeWithArguments(args);
                 }
                 System.out.println("SUCCEEDED (OK) -> " + r);
+            } else {
+                System.out.println("SUCCEEDED (OK)");
             }
         } catch (IllegalArgumentException iae) {
             if (excessive) {