forked from soot-oss/soot
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathKind.java
More file actions
273 lines (235 loc) · 6.89 KB
/
Kind.java
File metadata and controls
273 lines (235 loc) · 6.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
package soot;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2003 Ondrej Lhotak
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.util.Numberable;
/**
* Enumeration type representing the kind of a call graph edge.
*
* @author Ondrej Lhotak
*/
public final class Kind implements Numberable {
public static final Kind INVALID = new Kind("INVALID");
/**
* Due to explicit invokestatic instruction.
*/
public static final Kind STATIC = new Kind("STATIC");
/**
* Due to explicit invokevirtual instruction.
*/
public static final Kind VIRTUAL = new Kind("VIRTUAL");
/**
* Due to explicit invokeinterface instruction.
*/
public static final Kind INTERFACE = new Kind("INTERFACE");
/**
* Due to explicit invokespecial instruction.
*/
public static final Kind SPECIAL = new Kind("SPECIAL");
/**
* Implicit call to static initializer.
*/
public static final Kind CLINIT = new Kind("CLINIT");
/**
* Fake edges from our generic callback model.
*/
public static final Kind GENERIC_FAKE = new Kind("GENERIC_FAKE");
/**
* Implicit call to Thread.run() due to Thread.start() call.
*/
public static final Kind THREAD = new Kind("THREAD");
/**
* Implicit call to java.lang.Runnable.run() due to Executor.execute() call.
*/
public static final Kind EXECUTOR = new Kind("EXECUTOR");
/**
* Implicit call to AsyncTask.doInBackground() due to AsyncTask.execute() call.
*/
public static final Kind ASYNCTASK = new Kind("ASYNCTASK");
/**
* Implicit call to java.lang.ref.Finalizer.register from new bytecode.
*/
public static final Kind FINALIZE = new Kind("FINALIZE");
/**
* Implicit call to Handler.handleMessage(android.os.Message) due to Handler.sendxxxxMessagexxxx() call.
*/
public static final Kind HANDLER = new Kind("HANDLER");
/**
* Implicit call to finalize() from java.lang.ref.Finalizer.invokeFinalizeMethod().
*/
public static final Kind INVOKE_FINALIZE = new Kind("INVOKE_FINALIZE");
/**
* Implicit call to run() through AccessController.doPrivileged().
*/
public static final Kind PRIVILEGED = new Kind("PRIVILEGED");
/**
* Implicit call to constructor from java.lang.Class.newInstance().
*/
public static final Kind NEWINSTANCE = new Kind("NEWINSTANCE");
/**
* Due to call to Method.invoke(..).
*/
public static final Kind REFL_INVOKE = new Kind("REFL_METHOD_INVOKE");
/**
* Due to call to Constructor.newInstance(..).
*/
public static final Kind REFL_CONSTR_NEWINSTANCE = new Kind("REFL_CONSTRUCTOR_NEWINSTANCE");
/**
* Due to call to Class.newInstance(..) when reflection log is enabled.
*/
public static final Kind REFL_CLASS_NEWINSTANCE = new Kind("REFL_CLASS_NEWINSTANCE");
private final String name;
private int num;
private Kind(String name) {
this.name = name;
}
public String name() {
return name;
}
@Override
public int getNumber() {
return num;
}
@Override
public void setNumber(int num) {
this.num = num;
}
@Override
public String toString() {
return name();
}
public boolean passesParameters() {
return passesParameters(this);
}
public boolean isFake() {
return isFake(this);
}
/**
* Returns true if the call is due to an explicit invoke statement.
*/
public boolean isExplicit() {
return isExplicit(this);
}
/**
* Returns true if the call is due to an explicit instance invoke statement.
*/
public boolean isInstance() {
return isInstance(this);
}
/**
* Returns true if the call is due to an explicit virtual invoke statement.
*/
public boolean isVirtual() {
return isVirtual(this);
}
public boolean isSpecial() {
return isSpecial(this);
}
/**
* Returns true if the call is to static initializer.
*/
public boolean isClinit() {
return isClinit(this);
}
/**
* Returns true if the call is due to an explicit static invoke statement.
*/
public boolean isStatic() {
return isStatic(this);
}
public boolean isThread() {
return isThread(this);
}
public boolean isExecutor() {
return isExecutor(this);
}
public boolean isAsyncTask() {
return isAsyncTask(this);
}
public boolean isPrivileged() {
return isPrivileged(this);
}
public boolean isReflection() {
return isReflection(this);
}
public boolean isReflInvoke() {
return isReflInvoke(this);
}
public static boolean passesParameters(Kind k) {
return isExplicit(k) || k == THREAD || k == EXECUTOR || k == ASYNCTASK || k == FINALIZE || k == PRIVILEGED
|| k == NEWINSTANCE || k == INVOKE_FINALIZE || k == REFL_INVOKE || k == REFL_CONSTR_NEWINSTANCE
|| k == REFL_CLASS_NEWINSTANCE;
}
public static boolean isFake(Kind k) {
return k == THREAD || k == EXECUTOR || k == ASYNCTASK || k == PRIVILEGED || k == HANDLER || k == GENERIC_FAKE;
}
/**
* Returns true if the call is due to an explicit invoke statement.
*/
public static boolean isExplicit(Kind k) {
return isInstance(k) || isStatic(k);
}
/**
* Returns true if the call is due to an explicit instance invoke statement.
*/
public static boolean isInstance(Kind k) {
return k == VIRTUAL || k == INTERFACE || k == SPECIAL;
}
/**
* Returns true if the call is due to an explicit virtual invoke statement.
*/
public static boolean isVirtual(Kind k) {
return k == VIRTUAL;
}
public static boolean isSpecial(Kind k) {
return k == SPECIAL;
}
/**
* Returns true if the call is to static initializer.
*/
public static boolean isClinit(Kind k) {
return k == CLINIT;
}
/**
* Returns true if the call is due to an explicit static invoke statement.
*/
public static boolean isStatic(Kind k) {
return k == STATIC;
}
public static boolean isThread(Kind k) {
return k == THREAD;
}
public static boolean isExecutor(Kind k) {
return k == EXECUTOR;
}
public static boolean isAsyncTask(Kind k) {
return k == ASYNCTASK;
}
public static boolean isPrivileged(Kind k) {
return k == PRIVILEGED;
}
public static boolean isReflection(Kind k) {
return k == REFL_CLASS_NEWINSTANCE || k == REFL_CONSTR_NEWINSTANCE || k == REFL_INVOKE;
}
public static boolean isReflInvoke(Kind k) {
return k == REFL_INVOKE;
}
}