Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/jit/Robert/Robert.java
40948 views
1
/*
2
* Copyright (c) 2008, 2020, 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
*
27
* @summary converted from VM Testbase jit/Robert.
28
* VM Testbase keywords: [jit, quick]
29
*
30
* @library /vmTestbase
31
* /test/lib
32
* @run main/othervm jit.Robert.Robert
33
*/
34
35
package jit.Robert;
36
37
import java.io.*;
38
import nsk.share.TestFailure;
39
40
public class Robert
41
{
42
Robert()
43
throws Exception
44
{
45
try{
46
testSoftwareException();
47
}
48
catch (Exception e)
49
{
50
throw e;
51
}
52
}
53
54
static void
55
testHardwareException()
56
throws Exception
57
{
58
int i = 1; int j = 0; int k = i / j;
59
System.out.println(k);
60
}
61
62
static void
63
testSoftwareException()
64
throws Exception
65
{
66
Float f = Float.valueOf("abc");
67
System.out.println(f);
68
}
69
70
static void
71
testUserException()
72
throws Exception
73
{
74
throw new IOException();
75
}
76
77
static void
78
testRethrownException()
79
throws Exception
80
{
81
new Robert();
82
}
83
84
static void
85
trouble(int choice)
86
throws Exception
87
{
88
if (choice == 2) testSoftwareException();
89
if (choice == 3) testUserException();
90
if (choice == 4) testRethrownException();
91
}
92
93
public static void main(String args[])
94
throws Exception
95
{
96
boolean failed = false;
97
System.out.println("Robert");
98
for (int i = 2; i <= 4; ++i)
99
{
100
System.out.println("test " + i);
101
try{
102
trouble(i);
103
}
104
catch (Exception e)
105
{
106
System.out.println("caught " + e);
107
e.printStackTrace(System.out);
108
continue;
109
}
110
failed = true;
111
}
112
if (failed)
113
throw new TestFailure("Test failed.");
114
else
115
System.out.println("Test passed.");
116
117
}
118
}
119
120