Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack009.java
41159 views
1
/*
2
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
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
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @key stress
27
*
28
* @summary converted from VM testbase nsk/stress/stack/stack009.
29
* VM testbase keywords: [stress, quick, stack, nonconcurrent]
30
* VM testbase readme:
31
* DESCRIPTION
32
* The test provokes second stack overflow from within the
33
* stack overflow handler.
34
* This test measures a number of recursive invocations until
35
* StackOverflowError, and then tries to make an invocation
36
* for the fixed invocations depth from within the "catch"
37
* block just caught the 1st stack overflow. The depth of new
38
* invocations is 10 times that depth seen at the 1st stack
39
* overflow; so that another stack overflow occurs.
40
* The test is deemed passed, if VM have not crashed, and
41
* if there is no exception thrown other than due to stack
42
* overflow.
43
* COMMENTS
44
* This test crashes HS versions 2.0, 1.3, and 1.4 on Win32
45
* and Solaris platforms.
46
* See the bug:
47
* 4366625 (P4/S4) multiple stack overflow causes HS crash
48
*
49
* @requires vm.opt.DeoptimizeALot != true
50
* @run main/othervm/timeout=900 nsk.stress.stack.stack009
51
*/
52
53
package nsk.stress.stack;
54
55
56
import java.io.PrintStream;
57
58
public class stack009 {
59
public static void main(String[] args) {
60
int exitCode = run(args, System.out);
61
System.exit(exitCode + 95);
62
}
63
64
public static int run(String args[], PrintStream out) {
65
for (int depth = 100; ; depth += 100)
66
try {
67
recurse(depth);
68
} catch (Error error1) {
69
if (!(error1 instanceof StackOverflowError) &&
70
!(error1 instanceof OutOfMemoryError))
71
throw error1;
72
73
out.println("Max. depth: " + depth);
74
75
try {
76
recurse(10 * depth);
77
out.println("?");
78
} catch (Error error2) {
79
if (!(error2 instanceof StackOverflowError) &&
80
!(error2 instanceof OutOfMemoryError))
81
throw error2;
82
83
// Stack overflow is OK here.
84
}
85
86
break;
87
}
88
return 0;
89
}
90
91
static void recurse(int depth) {
92
if (depth > 0)
93
recurse(depth - 1);
94
}
95
}
96
97