Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/exceptions/CatchInlineExceptions.java
41152 views
1
/*
2
* Copyright (c) 2014, 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 8059299
27
* @summary assert(adr_type != NULL) failed: expecting TypeKlassPtr
28
*
29
* @run main/othervm -Xbatch compiler.exceptions.CatchInlineExceptions
30
*/
31
32
package compiler.exceptions;
33
34
public class CatchInlineExceptions {
35
static class Exception1 extends Exception {};
36
static class Exception2 extends Exception {};
37
private static int counter0;
38
private static int counter1;
39
private static int counter2;
40
private static int counter;
41
42
static void foo(int i) throws Exception {
43
if ((i & 1023) == 2) {
44
counter0++;
45
throw new Exception2();
46
}
47
}
48
49
static void test(int i) throws Exception {
50
try {
51
foo(i);
52
}
53
catch (Exception e) {
54
if (e instanceof Exception1) {
55
counter1++;
56
} else if (e instanceof Exception2) {
57
counter2++;
58
}
59
counter++;
60
throw e;
61
}
62
}
63
64
public static void main(String[] args) throws Throwable {
65
for (int i = 0; i < 15000; i++) {
66
try {
67
test(i);
68
} catch (Exception e) {
69
// expected
70
}
71
}
72
if (counter1 != 0) {
73
throw new RuntimeException("Failed: counter1(" + counter1 + ") != 0");
74
}
75
if (counter2 != counter0) {
76
throw new RuntimeException("Failed: counter2(" + counter2 + ") != counter0(" + counter0 + ")");
77
}
78
if (counter2 != counter) {
79
throw new RuntimeException("Failed: counter2(" + counter2 + ") != counter(" + counter + ")");
80
}
81
System.out.println("TEST PASSED");
82
}
83
}
84
85