Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/jlink/optimplugin/optim/ForNameTestCase.java
41153 views
1
/*
2
* Copyright (c) 2015, 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
package optim;
25
26
public class ForNameTestCase {
27
private static final String EXPECTED = "expected";
28
public static Class<?> forName() {
29
try {
30
Class<?> cl = Class.forName("java.lang.String");
31
return cl;
32
} catch (ClassNotFoundException |
33
IllegalArgumentException |
34
ClassCastException x) {
35
throw new InternalError(x);
36
}
37
}
38
39
public static Class<?> forName0() throws ClassNotFoundException {
40
return Class.forName("java.lang.String");
41
}
42
43
public static Class<?> forName1() throws Exception {
44
Class<?> clazz = null;
45
try {
46
clazz = Class.forName("java.lang.String");
47
} catch (ClassNotFoundException e) {
48
return null;
49
}
50
return clazz;
51
}
52
53
public static void forNameException() throws Exception {
54
try {
55
Class.forName("java.lang.String");
56
throw new Exception(EXPECTED);
57
} catch (ClassNotFoundException e) {
58
return;
59
} catch (RuntimeException e) {
60
return;
61
}
62
}
63
64
public static Class<?> forName2() throws Exception {
65
Class<?> clazz = null;
66
try {
67
clazz = Class.forName("java.lang.String");
68
try {
69
throw new Exception("das");
70
} catch (Exception ex) {
71
}
72
} catch (ClassNotFoundException e) {
73
return null;
74
}
75
return clazz;
76
}
77
78
public static Class<?> forName3() throws Exception {
79
Class<?> clazz = null;
80
try {
81
return clazz = Class.forName("java.lang.String");
82
} catch (ClassNotFoundException e) {
83
return null;
84
}
85
}
86
87
public static Class<?> forName4() throws Exception {
88
Class<?> clazz = null;
89
try {
90
clazz = Class.forName("java.lang.String");
91
} catch (ClassNotFoundException e) {
92
return null;
93
} catch (RuntimeException e) {
94
return null;
95
}
96
return clazz;
97
}
98
99
public static Class<?> forName5() {
100
Class<?> clazz = null;
101
try {
102
clazz = Class.forName("java.lang.String");
103
} catch (ClassNotFoundException e) {
104
}
105
int i;
106
try {
107
i = 0;
108
} catch (Exception e) {
109
}
110
return clazz;
111
}
112
113
public static Class<?> forName6() {
114
Class<?> clazz = null;
115
try {
116
return Class.forName("java.lang.String");
117
} catch (ClassNotFoundException e) {
118
}
119
120
try {
121
// This one is removed because no more reachable when
122
// Class.forName is removed
123
int k = 0;
124
} catch (RuntimeException e) {
125
}
126
127
int i;
128
try {
129
// This one is removed because no more reachable when
130
// Class.forName is removed
131
return Class.forName("TOTO");
132
} catch (ClassNotFoundException e) {
133
}
134
try {
135
// This one is removed because no more reachable when
136
// Class.forName is removed
137
return Class.forName("TOTO");
138
} catch (ClassNotFoundException e) {
139
}
140
try {
141
// This one is removed because no more reachable when
142
// Class.forName is removed
143
return Class.forName("TOTO");
144
} catch (ClassNotFoundException e) {
145
}
146
try {
147
// This one is removed because no more reachable when
148
// Class.forName is removed
149
return Class.forName("TOTO");
150
} catch (ClassNotFoundException e) {
151
}
152
return clazz;
153
}
154
155
public static Class<?> forName7() {
156
Class<?> clazz = null;
157
try {
158
clazz = Class.forName("optim.AType");
159
} catch (ClassNotFoundException e) {
160
}
161
return clazz;
162
}
163
164
public static Class<?> negativeforName() {
165
Class<?> clazz = null;
166
try {
167
clazz = Class.forName("jdk.internal.jimage.BasicImageReader");
168
} catch (ClassNotFoundException e) {
169
}
170
return clazz;
171
}
172
}
173
174