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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
//macro_rules! def {
// ($type:ty;
// $($name:ident = $val:expr;)+
// ) => {
// $(pub const $name: $type = $val;)+
// };
//}
// ASM API versions.
//const ASM4: u8 = 4 << 16 | 0 << 8;
//const ASM5: u8 = 5 << 16 | 0 << 8;
//const ASM6: u8 = 6 << 16 | 0 << 8;
//const ASM7: u8 = 7 << 16 | 0 << 8;
// Java ClassFile versions (the minor version is stored in the 16 most
// significant bits, and the
// major version in the 16 least significant bits).
pub const V1_1: u32 = 3 << 16 | 45;
pub const V1_2: u32 = 0 << 16 | 45;
pub const V1_3: u32 = 0 << 16 | 47;
pub const V1_4: u32 = 0 << 16 | 48;
pub const V1_5: u32 = 0 << 16 | 49;
pub const V1_6: u32 = 0 << 16 | 50;
pub const V1_7: u32 = 0 << 16 | 51;
pub const V1_8: u32 = 0 << 16 | 52;
pub const V9: u32 = 0 << 16 | 53;
pub const V10: u32 = 0 << 16 | 54;
pub const V11: u32 = 0 << 16 | 55;
pub const V12: u32 = 0 << 16 | 56;
// Version flag indicating that the class is using 'preview' features.
//
// `version & V_PREVIEW == V_PREVIEW` tests if a version is flagged with `V_PREVIEW`
//pub const V_PREVIEW: u8 = 0xFFFF0000;
// Access flags values, defined in
// - https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.1-200-E.1
// - https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.5-200-A.1
// - https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.6-200-A.1
// - https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.25
// @formatter:off
pub const PUBLIC: u16 = 0x0001; // class, field, method
pub const PRIVATE: u16 = 0x0002; // class, field, method
pub const PROTECTED: u16 = 0x0004; // class, field, method
pub const STATIC: u16 = 0x0008; // field, method
pub const FINAL: u16 = 0x0010; // class, field, method, parameter
pub const SUPER: u16 = 0x0020; // class
pub const SYNCHRONIZED: u16 = 0x0020; // method
pub const OPEN: u16 = 0x0020; // module
pub const TRANSITIVE: u16 = 0x0020; // module requires
pub const VOLATILE: u16 = 0x0040; // field
pub const BRIDGE: u16 = 0x0040; // method
pub const STATIC_PHASE: u16 = 0x0040; // module requires
pub const VARARGS: u16 = 0x0080; // method
pub const TRANSIENT: u16 = 0x0080; // field
pub const NATIVE: u16 = 0x0100; // method
pub const INTERFACE: u16 = 0x0200; // class
pub const ABSTRACT: u16 = 0x0400; // class, method
pub const STRICT: u16 = 0x0800; // method
pub const SYNTHETIC: u16 = 0x1000; // class, field, method, parameter, module *
pub const ANNOTATION: u16 = 0x2000; // class
pub const ENUM: u16 = 0x4000; // class(?) field inner
pub const MANDATED: u16 = 0x8000; // parameter, module, module *
pub const MODULE: u16 = 0x8000; // class
// @formatter:on
// ASM specific access flags.
// WARNING: the 16 least significant bits must NOT be used, to avoid conflicts with standard
// access flags, and also to make sure that these flags are automatically filtered out when
// written in class files (because access flags are stored using 16 bits only).
// @formatter:off
pub const DEPRECATED: u32 = 0x20000; // class, field, method
// @formatter:on
// Possible values for the type operand of the NEWARRAY instruction.
// See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-6.html#jvms-6.5.newarray.
pub const T_BOOLEAN: u8 = 4;
pub const T_CHAR: u8 = 5;
pub const T_FLOAT: u8 = 6;
pub const T_DOUBLE: u8 = 7;
pub const T_BYTE: u8 = 8;
pub const T_SHORT: u8 = 9;
pub const T_CONST: u8 = 10;
pub const T_LONG: u8 = 11;
// Possible values for the reference_kind field of CONSTANT_MethodHandle_info structures.
// See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.4.8.
pub const H_GETFIELD: u8 = 1;
pub const H_GETSTATIC: u8 = 2;
pub const H_PUTFIELD: u8 = 3;
pub const H_PUTSTATIC: u8 = 4;
pub const H_INVOKEVIRTUAL: u8 = 5;
pub const H_INVOKESTATIC: u8 = 6;
pub const H_INVOKESPECIAL: u8 = 7;
pub const H_NEWINVOKESPECIAL: u8 = 8;
pub const H_INVOKEINTERFACE: u8 = 9;
// ASM specific stack map frame types, used in {@link ClassVisitor#visitFrame}.
/// An expanded frame. See {@link ClassReader#EXPAND_FRAMES}.
pub const F_NEW: i8 = -1;
/// A compressed frame with complete frame data.
pub const F_FULL: i8 = 0;
/// A compressed frame where locals are the same as the locals in the previous frame, except that
/// additional 1-3 locals are defined, and with an empty stack.
pub const F_APPEND: i8 = 1;
/// A compressed frame where locals are the same as the locals in the previous frame, except that
/// the last 1-3 locals are absent and with an empty stack.
pub const F_CHOP: i8 = 2;
/// A compressed frame with exactly the same locals as the previous frame and with an empty stack.
pub const F_SAME: i8 = 3;
/// A compressed frame with exactly the same locals as the previous frame and with a single value on the stack.
pub const F_SAME1: i8 = 4;
// Standard stack map frame element types, used in {@link ClassVisitor#visitFrame}.
// const TOP: u8 = Frame.ITEM_TOP;
// const INTEGER: u8 = Frame.ITEM_INTEGER;
// const FLOAT: u8 = Frame.ITEM_FLOAT;
// const DOUBLE: u8 = Frame.ITEM_DOUBLE;
// const LONG: u8 = Frame.ITEM_LONG;
// const NULL: u8 = Frame.ITEM_NULL;
// const UNINITIALIZED_THIS: u8 = Frame.ITEM_UNINITIALIZED_THIS;
// The JVM opcode values (with the MethodVisitor method name used to visit them in comment, and
// where '-' means 'same method name as on the previous line').
// See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-6.html.
// @formatter:off
pub const NOP: u8 = 0; // visitInsn
pub const ACONST_NULL: u8 = 1; // -
pub const ICONST_M1: u8 = 2; // -
pub const ICONST_0: u8 = 3; // -
pub const ICONST_1: u8 = 4; // -
pub const ICONST_2: u8 = 5; // -
pub const ICONST_3: u8 = 6; // -
pub const ICONST_4: u8 = 7; // -
pub const ICONST_5: u8 = 8; // -
pub const LCONST_0: u8 = 9; // -
pub const LCONST_1: u8 = 10; // -
pub const FCONST_0: u8 = 11; // -
pub const FCONST_1: u8 = 12; // -
pub const FCONST_2: u8 = 13; // -
pub const DCONST_0: u8 = 14; // -
pub const DCONST_1: u8 = 15; // -
pub const BIPUSH: u8 = 16; // visitIntInsn
pub const SIPUSH: u8 = 17; // -
pub const LDC: u8 = 18; // visitLdcInsn
pub const ILOAD: u8 = 21; // visitVarInsn
pub const LLOAD: u8 = 22; // -
pub const FLOAD: u8 = 23; // -
pub const DLOAD: u8 = 24; // -
pub const ALOAD: u8 = 25; // -
pub const IALOAD: u8 = 46; // visitInsn
pub const LALOAD: u8 = 47; // -
pub const FALOAD: u8 = 48; // -
pub const DALOAD: u8 = 49; // -
pub const AALOAD: u8 = 50; // -
pub const BALOAD: u8 = 51; // -
pub const CALOAD: u8 = 52; // -
pub const SALOAD: u8 = 53; // -
pub const ISTORE: u8 = 54; // visitVarInsn
pub const LSTORE: u8 = 55; // -
pub const FSTORE: u8 = 56; // -
pub const DSTORE: u8 = 57; // -
pub const ASTORE: u8 = 58; // -
pub const IASTORE: u8 = 79; // visitInsn
pub const LASTORE: u8 = 80; // -
pub const FASTORE: u8 = 81; // -
pub const DASTORE: u8 = 82; // -
pub const AASTORE: u8 = 83; // -
pub const BASTORE: u8 = 84; // -
pub const CASTORE: u8 = 85; // -
pub const SASTORE: u8 = 86; // -
pub const POP: u8 = 87; // -
pub const POP2: u8 = 88; // -
pub const DUP: u8 = 89; // -
pub const DUP_X1: u8 = 90; // -
pub const DUP_X2: u8 = 91; // -
pub const DUP2: u8 = 92; // -
pub const DUP2_X1: u8 = 93; // -
pub const DUP2_X2: u8 = 94; // -
pub const SWAP: u8 = 95; // -
pub const IADD: u8 = 96; // -
pub const LADD: u8 = 97; // -
pub const FADD: u8 = 98; // -
pub const DADD: u8 = 99; // -
pub const ISUB: u8 = 100; // -
pub const LSUB: u8 = 101; // -
pub const FSUB: u8 = 102; // -
pub const DSUB: u8 = 103; // -
pub const IMUL: u8 = 104; // -
pub const LMUL: u8 = 105; // -
pub const FMUL: u8 = 106; // -
pub const DMUL: u8 = 107; // -
pub const IDIV: u8 = 108; // -
pub const LDIV: u8 = 109; // -
pub const FDIV: u8 = 110; // -
pub const DDIV: u8 = 111; // -
pub const IREM: u8 = 112; // -
pub const LREM: u8 = 113; // -
pub const FREM: u8 = 114; // -
pub const DREM: u8 = 115; // -
pub const INEG: u8 = 116; // -
pub const LNEG: u8 = 117; // -
pub const FNEG: u8 = 118; // -
pub const DNEG: u8 = 119; // -
pub const ISHL: u8 = 120; // -
pub const LSHL: u8 = 121; // -
pub const ISHR: u8 = 122; // -
pub const LSHR: u8 = 123; // -
pub const IUSHR: u8 = 124; // -
pub const LUSHR: u8 = 125; // -
pub const IAND: u8 = 126; // -
pub const LAND: u8 = 127; // -
pub const IOR: u8 = 128; // -
pub const LOR: u8 = 129; // -
pub const IXOR: u8 = 130; // -
pub const LXOR: u8 = 131; // -
pub const IINC: u8 = 132; // visitIincInsn
pub const I2L: u8 = 133; // visitInsn
pub const I2F: u8 = 134; // -
pub const I2D: u8 = 135; // -
pub const L2I: u8 = 136; // -
pub const L2F: u8 = 137; // -
pub const L2D: u8 = 138; // -
pub const F2I: u8 = 139; // -
pub const F2L: u8 = 140; // -
pub const F2D: u8 = 141; // -
pub const D2I: u8 = 142; // -
pub const D2L: u8 = 143; // -
pub const D2F: u8 = 144; // -
pub const I2B: u8 = 145; // -
pub const I2C: u8 = 146; // -
pub const I2S: u8 = 147; // -
pub const LCMP: u8 = 148; // -
pub const FCMPL: u8 = 149; // -
pub const FCMPG: u8 = 150; // -
pub const DCMPL: u8 = 151; // -
pub const DCMPG: u8 = 152; // -
pub const IFEQ: u8 = 153; // visitJumpInsn
pub const IFNE: u8 = 154; // -
pub const IFLT: u8 = 155; // -
pub const IFGE: u8 = 156; // -
pub const IFGT: u8 = 157; // -
pub const IFLE: u8 = 158; // -
pub const IF_ICMPEQ: u8 = 159; // -
pub const IF_ICMPNE: u8 = 160; // -
pub const IF_ICMPLT: u8 = 161; // -
pub const IF_ICMPGE: u8 = 162; // -
pub const IF_ICMPGT: u8 = 163; // -
pub const IF_ICMPLE: u8 = 164; // -
pub const IF_ACMPEQ: u8 = 165; // -
pub const IF_ACMPNE: u8 = 166; // -
pub const GOTO: u8 = 167; // -
pub const JSR: u8 = 168; // -
pub const RET: u8 = 169; // visitVarInsn
pub const TABLESWITCH: u8 = 170; // visiTableSwitchInsn
pub const LOOKUPSWITCH: u8 = 171; // visitLookupSwitch
pub const IRETURN: u8 = 172; // visitInsn
pub const LRETURN: u8 = 173; // -
pub const FRETURN: u8 = 174; // -
pub const DRETURN: u8 = 175; // -
pub const ARETURN: u8 = 176; // -
pub const RETURN: u8 = 177; // -
pub const GETSTATIC: u8 = 178; // visitFieldInsn
pub const PUTSTATIC: u8 = 179; // -
pub const GETFIELD: u8 = 180; // -
pub const PUTFIELD: u8 = 181; // -
pub const INVOKEVIRTUAL: u8 = 182; // visitMethodInsn
pub const INVOKESPECIAL: u8 = 183; // -
pub const INVOKESTATIC: u8 = 184; // -
pub const INVOKEINTERFACE: u8 = 185; // -
pub const INVOKEDYNAMIC: u8 = 186; // visitInvokeDynamicInsn
pub const NEW: u8 = 187; // visitTypeInsn
pub const NEWARRAY: u8 = 188; // visitIntInsn
pub const ANEWARRAY: u8 = 189; // visitTypeInsn
pub const ARRAYLENGTH: u8 = 190; // visitInsn
pub const ATHROW: u8 = 191; // -
pub const CHECKCAST: u8 = 192; // visitTypeInsn
pub const INSTANCEOF: u8 = 193; // -
pub const MONITORENTER: u8 = 194; // visitInsn
pub const MONITOREXIT: u8 = 195; // -
pub const MULTIANEWARRAY: u8 = 197; // visitMultiANewArrayInsn
pub const IFNULL: u8 = 198; // visitJumpInsn
pub const IFNONNULL: u8 = 199; // -
// @formatter:on
// Tag values for the constant pool entries (using the same order as in the JVMS).
/// The tag value of CONSTANT_Class_info JVMS structures.
pub const CONSTANT_CLASS_TAG: u8 = 7;
/// The tag value of CONSTANT_Fieldref_info JVMS structures.
pub const CONSTANT_FIELDREF_TAG: u8 = 9;
/// The tag value of CONSTANT_Methodref_info JVMS structures.
pub const CONSTANT_METHODREF_TAG: u8 = 10;
/// The tag value of CONSTANT_InterfaceMethodref_info JVMS structures.
pub const CONSTANT_INTERFACE_METHODREF_TAG: u8 = 11;
/// The tag value of CONSTANT_String_info JVMS structures.
pub const CONSTANT_STRING_TAG: u8 = 8;
/// The tag value of CONSTANT_Integer_info JVMS structures.
pub const CONSTANT_INTEGER_TAG: u8 = 3;
/// The tag value of CONSTANT_Float_info JVMS structures.
pub const CONSTANT_FLOAT_TAG: u8 = 4;
/// The tag value of CONSTANT_Long_info JVMS structures.
pub const CONSTANT_LONG_TAG: u8 = 5;
/// The tag value of CONSTANT_Double_info JVMS structures.
pub const CONSTANT_DOUBLE_TAG: u8 = 6;
/// The tag value of CONSTANT_NameAndType_info JVMS structures.
pub const CONSTANT_NAME_AND_TYPE_TAG: u8 = 12;
/// The tag value of CONSTANT_Utf8_info JVMS structures.
pub const CONSTANT_UTF8_TAG: u8 = 1;
/// The tag value of CONSTANT_MethodHandle_info JVMS structures.
pub const CONSTANT_METHOD_HANDLE_TAG: u8 = 15;
/// The tag value of CONSTANT_MethodType_info JVMS structures.
pub const CONSTANT_METHOD_TYPE_TAG: u8 = 16;
/// The tag value of CONSTANT_Dynamic_info JVMS structures.
pub const CONSTANT_DYNAMIC_TAG: u8 = 17;
/// The tag value of CONSTANT_InvokeDynamic_info JVMS structures.
pub const CONSTANT_INVOKE_DYNAMIC_TAG: u8 = 18;
/// The tag value of CONSTANT_Module_info JVMS structures.
pub const CONSTANT_MODULE_TAG: u8 = 19;
/// The tag value of CONSTANT_Package_info JVMS structures.
pub const CONSTANT_PACKAGE_TAG: u8 = 20;