Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/interpreter/BytecodeNewArray.java
41161 views
1
/*
2
* Copyright (c) 2002, 2021, 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
package sun.jvm.hotspot.interpreter;
26
27
import sun.jvm.hotspot.oops.*;
28
import sun.jvm.hotspot.utilities.*;
29
30
public class BytecodeNewArray extends Bytecode {
31
BytecodeNewArray(Method method, int bci) {
32
super(method, bci);
33
}
34
35
public int getType() {
36
return (int) javaByteAt(1);
37
}
38
39
public void verify() {
40
if (Assert.ASSERTS_ENABLED) {
41
Assert.that(isValid(), "check newarray");
42
}
43
}
44
45
public boolean isValid() {
46
boolean result = javaCode() == Bytecodes._newarray;
47
if (result == false) return false;
48
switch (getType()) {
49
case TypeArrayKlass.T_BOOLEAN:
50
case TypeArrayKlass.T_CHAR:
51
case TypeArrayKlass.T_FLOAT:
52
case TypeArrayKlass.T_DOUBLE:
53
case TypeArrayKlass.T_BYTE:
54
case TypeArrayKlass.T_SHORT:
55
case TypeArrayKlass.T_INT:
56
case TypeArrayKlass.T_LONG:
57
break;
58
default:
59
return false;
60
}
61
62
return true;
63
}
64
65
public String getTypeName() {
66
String result;
67
switch (getType()) {
68
case TypeArrayKlass.T_BOOLEAN:
69
result = "boolean";
70
break;
71
72
case TypeArrayKlass.T_CHAR:
73
result = "char";
74
break;
75
76
case TypeArrayKlass.T_FLOAT:
77
result = "float";
78
break;
79
80
case TypeArrayKlass.T_DOUBLE:
81
result = "double";
82
break;
83
84
case TypeArrayKlass.T_BYTE:
85
result = "byte";
86
break;
87
88
case TypeArrayKlass.T_SHORT:
89
result = "short";
90
break;
91
92
case TypeArrayKlass.T_INT:
93
result = "int";
94
break;
95
96
case TypeArrayKlass.T_LONG:
97
result = "long";
98
break;
99
100
default: // should not happen
101
result = "<invalid>";
102
break;
103
}
104
105
return result;
106
}
107
108
public static BytecodeNewArray at(Method method, int bci) {
109
BytecodeNewArray b = new BytecodeNewArray(method, bci);
110
if (Assert.ASSERTS_ENABLED) {
111
b.verify();
112
}
113
return b;
114
}
115
116
/** Like at, but returns null if the BCI is not at newarray */
117
public static BytecodeNewArray atCheck(Method method, int bci) {
118
BytecodeNewArray b = new BytecodeNewArray(method, bci);
119
return (b.isValid() ? b : null);
120
}
121
122
public static BytecodeNewArray at(BytecodeStream bcs) {
123
return new BytecodeNewArray(bcs.method(), bcs.bci());
124
}
125
126
public String toString() {
127
StringBuilder buf = new StringBuilder();
128
buf.append("newarray");
129
buf.append(spaces);
130
buf.append(getTypeName());
131
return buf.toString();
132
}
133
}
134
135