author | lmesnik |
Thu, 12 Jul 2018 13:32:45 -0700 | |
changeset 51048 | 5c58b4c10fbd |
parent 50169 | dd501973095c |
child 51283 | ac4f5ef0edd9 |
permissions | -rw-r--r-- |
50169
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
1 |
/* |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
2 |
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
4 |
* |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
8 |
* |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
13 |
* accompanied this code). |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
14 |
* |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
18 |
* |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
21 |
* questions. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
22 |
*/ |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
23 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
24 |
/* |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
25 |
* @test |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
26 |
* @key stress |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
27 |
* |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
28 |
* @summary converted from VM testbase nsk/stress/stack/stack018. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
29 |
* VM testbase keywords: [stress, diehard, stack, nonconcurrent, exclude] |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
30 |
* VM testbase comments: 8139875 |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
31 |
* VM testbase readme: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
32 |
* DESCRIPTION |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
33 |
* This test provokes multiple stack overflows by invocations via |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
34 |
* reflection -- repeatedly multiple times, and in multiple threads. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
35 |
* Recursive method is invoked for the given fixed depth of recursion |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
36 |
* (though, for a large depth). The test measures a number of recursive |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
37 |
* invocations until stack overflow, and then tries to reproduce similar |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
38 |
* stack overflows 10 times in each of 10 threads -- each time by trying |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
39 |
* to invoke the same recursive method for the given fixed depth |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
40 |
* of invocations (which is 10 times that crucial depth just measured). |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
41 |
* The test is deemed passed, if VM have not crashed, and |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
42 |
* if exception other than due to stack overflow was not |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
43 |
* thrown. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
44 |
* COMMENTS |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
45 |
* This test crashes HS versions 2.0, 1.3, and 1.4 on both |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
46 |
* Solaris and Win32 platforms. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
47 |
* See the bug: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
48 |
* 4366625 (P4/S4) multiple stack overflow causes HS crash |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
49 |
* |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
50 |
* @ignore 8139875 |
51048
5c58b4c10fbd
8139876: Exclude hanging nsk/stress/stack from execution with deoptimization enabled
lmesnik
parents:
50169
diff
changeset
|
51 |
* @requires vm.opt.DeoptimizeALot == null | vm.opt.DeoptimizeALot == false |
50169
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
52 |
* @run main/othervm nsk.stress.stack.stack018 -eager |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
53 |
*/ |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
54 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
55 |
package nsk.stress.stack; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
56 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
57 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
58 |
import nsk.share.Harakiri; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
59 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
60 |
import java.io.PrintStream; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
61 |
import java.lang.reflect.InvocationTargetException; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
62 |
import java.lang.reflect.Method; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
63 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
64 |
public class stack018 extends Thread { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
65 |
private final static int THREADS = 10; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
66 |
private final static int CYCLES = 10; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
67 |
private final static int STEP = 100; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
68 |
private final static int RESERVE = 100; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
69 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
70 |
public static void main(String[] args) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
71 |
int exitCode = run(args, System.out); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
72 |
System.exit(exitCode + 95); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
73 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
74 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
75 |
public static int run(String args[], PrintStream out) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
76 |
verbose = false; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
77 |
boolean eager = false; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
78 |
for (int i = 0; i < args.length; i++) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
79 |
if (args[i].toLowerCase().equals("-verbose")) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
80 |
verbose = true; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
81 |
else if (args[i].toLowerCase().equals("-eager")) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
82 |
eager = true; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
83 |
if (!eager) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
84 |
Harakiri.appoint(Harakiri.parseAppointment(args)); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
85 |
stack018.out = out; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
86 |
stack018 test = new stack018(); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
87 |
return test.doRun(); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
88 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
89 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
90 |
private static boolean verbose; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
91 |
private static PrintStream out; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
92 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
93 |
private void display(Object message) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
94 |
if (!verbose) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
95 |
return; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
96 |
synchronized (out) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
97 |
out.println(message.toString()); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
98 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
99 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
100 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
101 |
private int doRun() { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
102 |
// |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
103 |
// Measure maximal recursion depth until stack overflow: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
104 |
// |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
105 |
int maxDepth = 0; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
106 |
for (depthToTry = 0; ; depthToTry += STEP) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
107 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
108 |
invokeRecurse(depthToTry); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
109 |
maxDepth = depthToTry; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
110 |
} catch (Throwable exception) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
111 |
Throwable target = getTargetException(exception); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
112 |
if ((target instanceof StackOverflowError) || |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
113 |
(target instanceof OutOfMemoryError)) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
114 |
break; // OK. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
115 |
target.printStackTrace(out); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
116 |
if (target instanceof ThreadDeath) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
117 |
throw (ThreadDeath) target; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
118 |
return 2; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
119 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
120 |
out.println("Maximal recursion depth: " + maxDepth); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
121 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
122 |
// |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
123 |
// Run the tested threads: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
124 |
// |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
125 |
stack018 threads[] = new stack018[THREADS]; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
126 |
for (int i = 0; i < threads.length; i++) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
127 |
threads[i] = new stack018(); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
128 |
threads[i].setName("Thread: " + (i + 1) + "/" + THREADS); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
129 |
threads[i].depthToTry = RESERVE * maxDepth; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
130 |
threads[i].start(); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
131 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
132 |
for (int i = 0; i < threads.length; i++) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
133 |
if (threads[i].isAlive()) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
134 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
135 |
threads[i].join(); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
136 |
} catch (InterruptedException exception) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
137 |
exception.printStackTrace(out); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
138 |
return 2; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
139 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
140 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
141 |
// |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
142 |
// Check if unexpected exceptions were thrown: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
143 |
// |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
144 |
int exitCode = 0; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
145 |
for (int i = 0; i < threads.length; i++) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
146 |
if (threads[i].thrown != null) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
147 |
out.println("# " + threads[i].getName() |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
148 |
+ ": " + threads[i].thrown); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
149 |
exitCode = 2; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
150 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
151 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
152 |
if (exitCode != 0) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
153 |
out.println("# TEST FAILED"); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
154 |
return exitCode; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
155 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
156 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
157 |
private int depthToTry = 0; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
158 |
private Throwable thrown = null; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
159 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
160 |
public void run() { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
161 |
String threadName = Thread.currentThread().getName(); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
162 |
for (int i = 1; i <= CYCLES; i++) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
163 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
164 |
display(threadName + ", iteration: " + i + "/" + CYCLES); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
165 |
invokeRecurse(depthToTry); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
166 |
throw new Error("TEST_RFE: try deeper invocations!"); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
167 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
168 |
} catch (Throwable exception) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
169 |
Throwable target = getTargetException(exception); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
170 |
if ((target instanceof StackOverflowError) || |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
171 |
(target instanceof OutOfMemoryError)) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
172 |
continue; // OK. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
173 |
if (target instanceof ThreadDeath) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
174 |
throw (ThreadDeath) target; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
175 |
thrown = target; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
176 |
break; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
177 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
178 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
179 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
180 |
private static Throwable getTargetException(Throwable exception) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
181 |
Throwable target; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
182 |
// |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
183 |
// Unwrap deep chain of exceptions to find StackOverflowError: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
184 |
// |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
185 |
for ( |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
186 |
target = exception; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
187 |
target instanceof InvocationTargetException; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
188 |
target = ((InvocationTargetException) target).getTargetException() |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
189 |
) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
190 |
; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
191 |
return target; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
192 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
193 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
194 |
private Method method = null; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
195 |
private Object params[] = null; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
196 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
197 |
private void invokeRecurse(int depth) throws Exception { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
198 |
if (method == null) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
199 |
// |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
200 |
// Optimization trick: allocate once, use everywhere. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
201 |
// |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
202 |
method = stack018.class.getMethod("recurse"); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
203 |
params = new Object[]{}; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
204 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
205 |
this.depth = depth; // actual parameter |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
206 |
method.invoke(this, params); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
207 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
208 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
209 |
private int depth = 0; // actual parameter for recurse() |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
210 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
211 |
public void recurse() throws Exception { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
212 |
if (depth > 0) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
213 |
// |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
214 |
// Self-invoke via reflection: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
215 |
// |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
216 |
invokeRecurse(depth - 1); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
217 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
218 |
} |