Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/com/sun/jdi/CatchPatternTest.java
41152 views
1
/*
2
* Copyright (c) 2002, 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
* @bug 4671838
27
* @summary TTY: surprising ExceptionSpec.resolveEventRequest() wildcard results
28
* @comment converted from test/jdk/com/sun/jdi/CatchPatternTest.sh
29
*
30
* @library /test/lib
31
* @build CatchPatternTest
32
* @run main/othervm CatchPatternTest
33
*/
34
35
import jdk.test.lib.process.OutputAnalyzer;
36
import lib.jdb.JdbCommand;
37
import lib.jdb.JdbTest;
38
39
class CatchPatternTestTarg {
40
public void bark(int i) {
41
System.out.println(" bark: " + i);
42
switch (i) {
43
case 0:
44
throw new IllegalArgumentException("IllegalArgumentException");
45
case 1:
46
throw new ArithmeticException("ArithmeticException");
47
case 2:
48
throw new IllegalMonitorStateException("IllegalMonitorStateException");
49
case 3:
50
throw new IndexOutOfBoundsException("IndexOutOfBoundsException");
51
default:
52
throw new Error("should not happen");
53
}
54
}
55
public void loop(int max) {
56
for (int i = 0; i <= max; i++) {
57
try {
58
bark(i);
59
} catch(RuntimeException re) {
60
System.out.println(" loop: " + re.getMessage() +
61
" caught and ignored.");
62
}
63
}
64
}
65
public void partOne() {
66
loop(2);
67
System.out.println("partOne completed");
68
}
69
public void partTwo() {
70
loop(3);
71
System.out.println("partTwo completed");
72
}
73
public static void main(String[] args) {
74
System.out.println("Howdy!");
75
CatchPatternTestTarg my = new CatchPatternTestTarg();
76
my.partOne();
77
my.partTwo();
78
System.out.println("Goodbye from CatchPatternTestTarg!");
79
}
80
}
81
82
public class CatchPatternTest extends JdbTest {
83
public static void main(String argv[]) {
84
new CatchPatternTest().run();
85
}
86
87
private CatchPatternTest() {
88
super(DEBUGGEE_CLASS);
89
}
90
91
private static final String DEBUGGEE_CLASS = CatchPatternTestTarg.class.getName();
92
93
@Override
94
protected void runCases() {
95
jdb.command(JdbCommand.stopIn(DEBUGGEE_CLASS, "main"));
96
jdb.command(JdbCommand.stopIn(DEBUGGEE_CLASS, "partTwo"));
97
jdb.command(JdbCommand.run());
98
99
jdb.command(JdbCommand.ignore(JdbCommand.ExType.uncaught, "java.lang.Throwable"));
100
// Instead of matching java.lang.I* we use two more specific
101
// patterns here. The reason is to avoid matching IncompatibleClassChangeError
102
// (or the subclass NoSuchMethodError) thrown by the
103
// java.lang.invoke infrastructure.
104
jdb.command(JdbCommand.catch_(JdbCommand.ExType.all, "java.lang.Il*"));
105
jdb.command(JdbCommand.catch_(JdbCommand.ExType.all, "java.lang.Ind*"));
106
jdb.command(JdbCommand.cont());
107
jdb.command(JdbCommand.cont());
108
jdb.command(JdbCommand.cont());
109
jdb.command(JdbCommand.ignore(JdbCommand.ExType.all, "java.lang.Ind*"));
110
jdb.command(JdbCommand.ignore(JdbCommand.ExType.all, "java.lang.Il*"));
111
112
jdb.contToExit(1);
113
114
new OutputAnalyzer(getJdbOutput())
115
.shouldContain("Exception occurred: java.lang.IllegalArgumentException")
116
.shouldContain("Exception occurred: java.lang.IllegalMonitorStateException")
117
.shouldNotContain("Exception occurred: ArithmeticException")
118
.shouldNotContain("Exception occurred: IndexOutOfBoundsException")
119
.shouldNotContain("Exception occurred: IllegalStateException")
120
.shouldNotContain("should not happen");
121
new OutputAnalyzer(getDebuggeeOutput())
122
.shouldContain("partOne completed")
123
.shouldContain("partTwo completed");
124
}
125
126
}
127
128