1 /* |
1 /* |
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
20 * or visit www.oracle.com if you need additional information or have any |
20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 |
23 |
24 /* |
24 /* |
25 * @test Test8004741.java |
25 * @test |
26 * @bug 8004741 |
26 * @bug 8004741 |
27 * @summary Missing compiled exception handle table entry for multidimensional array allocation |
27 * @summary Missing compiled exception handle table entry for multidimensional array allocation |
28 * |
28 * |
29 * @requires !vm.graal.enabled |
29 * @requires !vm.graal.enabled |
|
30 * @library /test/lib |
|
31 * |
|
32 * @build sun.hotspot.WhiteBox |
|
33 * @run driver ClassFileInstaller sun.hotspot.WhiteBox |
|
34 * sun.hotspot.WhiteBox$WhiteBoxPermission |
|
35 * |
30 * @run main/othervm -Xmx128m -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions |
36 * @run main/othervm -Xmx128m -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions |
31 * -XX:-TieredCompilation -XX:+StressCompiledExceptionHandlers |
37 * -XX:-TieredCompilation -XX:+StressCompiledExceptionHandlers |
32 * -XX:+SafepointALot -XX:GuaranteedSafepointInterval=100 |
38 * -XX:+SafepointALot -XX:GuaranteedSafepointInterval=100 |
|
39 * -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI |
33 * compiler.c2.Test8004741 |
40 * compiler.c2.Test8004741 |
|
41 * |
34 * @run main/othervm -Xmx128m -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions |
42 * @run main/othervm -Xmx128m -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions |
35 * -XX:-TieredCompilation -XX:+StressCompiledExceptionHandlers |
43 * -XX:-TieredCompilation -XX:+StressCompiledExceptionHandlers |
|
44 * -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI |
36 * compiler.c2.Test8004741 |
45 * compiler.c2.Test8004741 |
37 */ |
46 */ |
38 |
47 |
39 package compiler.c2; |
48 package compiler.c2; |
|
49 |
|
50 import sun.hotspot.WhiteBox; |
40 |
51 |
41 public class Test8004741 extends Thread { |
52 public class Test8004741 extends Thread { |
42 |
53 |
43 static int passed = 0; |
54 static int passed = 0; |
44 |
55 |
82 synchronized (progressLock) { |
93 synchronized (progressLock) { |
83 while (progressState < state) { |
94 while (progressState < state) { |
84 try { |
95 try { |
85 progressLock.wait(); |
96 progressLock.wait(); |
86 } catch (InterruptedException e) { |
97 } catch (InterruptedException e) { |
87 e.printStackTrace(); |
98 throw new Error("unexpected InterruptedException", e); |
88 System.out.println("unexpected InterruptedException"); |
|
89 fail(); |
|
90 } |
99 } |
91 } |
100 } |
92 if (progressState > state) { |
101 if (progressState > state) { |
93 System.out.println("unexpected test state change, expected " + |
102 throw new Error("unexpected test state change, state = " + state + ", progressState = " + progressState); |
94 state + " but saw " + progressState); |
|
95 fail(); |
|
96 } |
103 } |
97 } |
104 } |
98 } |
105 } |
99 |
106 |
100 /** |
107 /** |
142 // t will never be started. |
147 // t will never be started. |
143 for (int n = 0; n < 11000; n++) { |
148 for (int n = 0; n < 11000; n++) { |
144 test(2, 100); |
149 test(2, 100); |
145 } |
150 } |
146 |
151 |
147 // Will this sleep help ensure that the compiler is run? |
152 var method = Test8004741.class.getDeclaredMethod("test", int.class, int.class); |
148 Thread.sleep(500); |
153 if (!WhiteBox.getWhiteBox().isMethodCompiled(method)) { |
149 passed = 0; |
154 throw new Error("test method didn't get compiled"); |
|
155 } |
150 |
156 |
151 try { |
157 try { |
152 test(-1, 100); |
158 test(-1, 100); |
153 System.out.println("Missing NegativeArraySizeException #1"); |
159 throw new AssertionError("Missing NegativeArraySizeException"); |
154 fail(); |
160 } catch (NegativeArraySizeException e) { |
155 } catch ( java.lang.NegativeArraySizeException e ) { |
|
156 System.out.println("Saw expected NegativeArraySizeException #1"); |
161 System.out.println("Saw expected NegativeArraySizeException #1"); |
157 } |
162 } |
158 |
163 |
159 try { |
164 try { |
160 test(100, -1); |
165 test(100, -1); |
161 fail(); |
166 throw new AssertionError("Missing NegativeArraySizeException"); |
162 System.out.println("Missing NegativeArraySizeException #2"); |
167 } catch (NegativeArraySizeException e) { |
163 fail(); |
|
164 } catch ( java.lang.NegativeArraySizeException e ) { |
|
165 System.out.println("Saw expected NegativeArraySizeException #2"); |
168 System.out.println("Saw expected NegativeArraySizeException #2"); |
166 } |
169 } |
167 |
170 |
168 /* Test repetitions. If the test succeeds-mostly, it succeeds, |
171 /* Test repetitions. If the test succeeds-mostly, it succeeds, |
169 * as long as it does not crash (the outcome if the exception range |
172 * as long as it does not crash (the outcome if the exception range |
170 * table entry for the array allocation is missing). |
173 * table entry for the array allocation is missing). |
171 */ |
174 */ |
172 int N = 12; |
175 passed = 0; |
173 for (int n = 0; n < N; n++) { |
176 int limit = 6; |
|
177 while (passed != limit) { |
174 threadTest(); |
178 threadTest(); |
175 } |
179 } |
176 |
|
177 if (passed > N/2) { |
|
178 System.out.println("Saw " + passed + " out of " + N + " possible ThreadDeath hits"); |
|
179 System.out.println("PASSED"); |
|
180 } else { |
|
181 System.out.println("Too few ThreadDeath hits; expected at least " + N/2 + |
|
182 " but saw only " + passed); |
|
183 fail(); |
|
184 } |
|
185 } |
180 } |
186 |
181 } |
187 static void fail() { |
|
188 System.out.println("FAILED"); |
|
189 System.exit(97); |
|
190 } |
|
191 }; |
|