# HG changeset patch # User iignatyev # Date 1573856544 28800 # Node ID 8e7f29b1ad4a291ff6e32f714c6525aab2b335f6 # Parent a129f10e1b9a92800158cda57783ccb73c74d129 8214904: Test8004741.java failed due to "Too few ThreadDeath hits; expected at least 6 but saw only 5" Reviewed-by: kvn, epavlova diff -r a129f10e1b9a -r 8e7f29b1ad4a test/hotspot/jtreg/ProblemList.txt --- a/test/hotspot/jtreg/ProblemList.txt Fri Nov 15 16:58:29 2019 -0500 +++ b/test/hotspot/jtreg/ProblemList.txt Fri Nov 15 14:22:24 2019 -0800 @@ -54,7 +54,6 @@ compiler/types/correctness/OffTest.java 8225620 solaris-sparcv9 compiler/c2/Test6852078.java 8194310 generic-all -compiler/c2/Test8004741.java 8214904 generic-all compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java 8190680 generic-all diff -r a129f10e1b9a -r 8e7f29b1ad4a test/hotspot/jtreg/compiler/c2/Test8004741.java --- a/test/hotspot/jtreg/compiler/c2/Test8004741.java Fri Nov 15 16:58:29 2019 -0500 +++ b/test/hotspot/jtreg/compiler/c2/Test8004741.java Fri Nov 15 14:22:24 2019 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,22 +22,33 @@ */ /* - * @test Test8004741.java + * @test * @bug 8004741 * @summary Missing compiled exception handle table entry for multidimensional array allocation * * @requires !vm.graal.enabled + * @library /test/lib + * + * @build sun.hotspot.WhiteBox + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * * @run main/othervm -Xmx128m -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions * -XX:-TieredCompilation -XX:+StressCompiledExceptionHandlers * -XX:+SafepointALot -XX:GuaranteedSafepointInterval=100 + * -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * compiler.c2.Test8004741 + * * @run main/othervm -Xmx128m -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions * -XX:-TieredCompilation -XX:+StressCompiledExceptionHandlers + * -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * compiler.c2.Test8004741 */ package compiler.c2; +import sun.hotspot.WhiteBox; + public class Test8004741 extends Thread { static int passed = 0; @@ -58,7 +69,7 @@ } catch (ThreadDeath e) { System.out.println("test got ThreadDeath"); passed++; - throw(e); + throw e; } return ar; } @@ -84,15 +95,11 @@ try { progressLock.wait(); } catch (InterruptedException e) { - e.printStackTrace(); - System.out.println("unexpected InterruptedException"); - fail(); + throw new Error("unexpected InterruptedException", e); } } if (progressState > state) { - System.out.println("unexpected test state change, expected " + - state + " but saw " + progressState); - fail(); + throw new Error("unexpected test state change, state = " + state + ", progressState = " + progressState); } } } @@ -114,9 +121,7 @@ } catch (ThreadDeath e) { // nothing to say, passing was incremented by the test. } catch (Throwable e) { - e.printStackTrace(); - System.out.println("unexpected Throwable " + e); - fail(); + throw new Error("unexpected Throwable " + e, e); } toState(STOPPING); } @@ -144,24 +149,22 @@ test(2, 100); } - // Will this sleep help ensure that the compiler is run? - Thread.sleep(500); - passed = 0; + var method = Test8004741.class.getDeclaredMethod("test", int.class, int.class); + if (!WhiteBox.getWhiteBox().isMethodCompiled(method)) { + throw new Error("test method didn't get compiled"); + } try { test(-1, 100); - System.out.println("Missing NegativeArraySizeException #1"); - fail(); - } catch ( java.lang.NegativeArraySizeException e ) { + throw new AssertionError("Missing NegativeArraySizeException"); + } catch (NegativeArraySizeException e) { System.out.println("Saw expected NegativeArraySizeException #1"); } try { test(100, -1); - fail(); - System.out.println("Missing NegativeArraySizeException #2"); - fail(); - } catch ( java.lang.NegativeArraySizeException e ) { + throw new AssertionError("Missing NegativeArraySizeException"); + } catch (NegativeArraySizeException e) { System.out.println("Saw expected NegativeArraySizeException #2"); } @@ -169,23 +172,10 @@ * as long as it does not crash (the outcome if the exception range * table entry for the array allocation is missing). */ - int N = 12; - for (int n = 0; n < N; n++) { + passed = 0; + int limit = 6; + while (passed != limit) { threadTest(); } - - if (passed > N/2) { - System.out.println("Saw " + passed + " out of " + N + " possible ThreadDeath hits"); - System.out.println("PASSED"); - } else { - System.out.println("Too few ThreadDeath hits; expected at least " + N/2 + - " but saw only " + passed); - fail(); - } } - - static void fail() { - System.out.println("FAILED"); - System.exit(97); - } -}; +}