1/*
2 * Copyright (c) 2004, 2019, 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26#ifndef CLASSFILE_CONSTANTS_H
27#define CLASSFILE_CONSTANTS_H
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33/* Classfile version number for this information */
34#define JVM_CLASSFILE_MAJOR_VERSION 57
35#define JVM_CLASSFILE_MINOR_VERSION 0
36
37/* Flags */
38
39enum {
40 JVM_ACC_PUBLIC = 0x0001,
41 JVM_ACC_PRIVATE = 0x0002,
42 JVM_ACC_PROTECTED = 0x0004,
43 JVM_ACC_STATIC = 0x0008,
44 JVM_ACC_FINAL = 0x0010,
45 JVM_ACC_SYNCHRONIZED = 0x0020,
46 JVM_ACC_SUPER = 0x0020,
47 JVM_ACC_VOLATILE = 0x0040,
48 JVM_ACC_BRIDGE = 0x0040,
49 JVM_ACC_TRANSIENT = 0x0080,
50 JVM_ACC_VARARGS = 0x0080,
51 JVM_ACC_NATIVE = 0x0100,
52 JVM_ACC_INTERFACE = 0x0200,
53 JVM_ACC_ABSTRACT = 0x0400,
54 JVM_ACC_STRICT = 0x0800,
55 JVM_ACC_SYNTHETIC = 0x1000,
56 JVM_ACC_ANNOTATION = 0x2000,
57 JVM_ACC_ENUM = 0x4000,
58 JVM_ACC_MODULE = 0x8000
59};
60
61#define JVM_ACC_PUBLIC_BIT 0
62#define JVM_ACC_PRIVATE_BIT 1
63#define JVM_ACC_PROTECTED_BIT 2
64#define JVM_ACC_STATIC_BIT 3
65#define JVM_ACC_FINAL_BIT 4
66#define JVM_ACC_SYNCHRONIZED_BIT 5
67#define JVM_ACC_SUPER_BIT 5
68#define JVM_ACC_VOLATILE_BIT 6
69#define JVM_ACC_BRIDGE_BIT 6
70#define JVM_ACC_TRANSIENT_BIT 7
71#define JVM_ACC_VARARGS_BIT 7
72#define JVM_ACC_NATIVE_BIT 8
73#define JVM_ACC_INTERFACE_BIT 9
74#define JVM_ACC_ABSTRACT_BIT 10
75#define JVM_ACC_STRICT_BIT 11
76#define JVM_ACC_SYNTHETIC_BIT 12
77#define JVM_ACC_ANNOTATION_BIT 13
78#define JVM_ACC_ENUM_BIT 14
79
80/* Used in newarray instruction. */
81
82enum {
83 JVM_T_BOOLEAN = 4,
84 JVM_T_CHAR = 5,
85 JVM_T_FLOAT = 6,
86 JVM_T_DOUBLE = 7,
87 JVM_T_BYTE = 8,
88 JVM_T_SHORT = 9,
89 JVM_T_INT = 10,
90 JVM_T_LONG = 11
91};
92
93/* Constant Pool Entries */
94
95enum {
96 JVM_CONSTANT_Utf8 = 1,
97 JVM_CONSTANT_Unicode = 2, /* unused */
98 JVM_CONSTANT_Integer = 3,
99 JVM_CONSTANT_Float = 4,
100 JVM_CONSTANT_Long = 5,
101 JVM_CONSTANT_Double = 6,
102 JVM_CONSTANT_Class = 7,
103 JVM_CONSTANT_String = 8,
104 JVM_CONSTANT_Fieldref = 9,
105 JVM_CONSTANT_Methodref = 10,
106 JVM_CONSTANT_InterfaceMethodref = 11,
107 JVM_CONSTANT_NameAndType = 12,
108 JVM_CONSTANT_MethodHandle = 15, // JSR 292
109 JVM_CONSTANT_MethodType = 16, // JSR 292
110 JVM_CONSTANT_Dynamic = 17,
111 JVM_CONSTANT_InvokeDynamic = 18,
112 JVM_CONSTANT_Module = 19,
113 JVM_CONSTANT_Package = 20,
114 JVM_CONSTANT_ExternalMax = 20
115};
116
117/* JVM_CONSTANT_MethodHandle subtypes */
118enum {
119 JVM_REF_getField = 1,
120 JVM_REF_getStatic = 2,
121 JVM_REF_putField = 3,
122 JVM_REF_putStatic = 4,
123 JVM_REF_invokeVirtual = 5,
124 JVM_REF_invokeStatic = 6,
125 JVM_REF_invokeSpecial = 7,
126 JVM_REF_newInvokeSpecial = 8,
127 JVM_REF_invokeInterface = 9
128};
129
130/* StackMapTable type item numbers */
131
132enum {
133 JVM_ITEM_Top = 0,
134 JVM_ITEM_Integer = 1,
135 JVM_ITEM_Float = 2,
136 JVM_ITEM_Double = 3,
137 JVM_ITEM_Long = 4,
138 JVM_ITEM_Null = 5,
139 JVM_ITEM_UninitializedThis = 6,
140 JVM_ITEM_Object = 7,
141 JVM_ITEM_Uninitialized = 8
142};
143
144/* Type signatures */
145
146enum {
147 JVM_SIGNATURE_ARRAY = '[',
148 JVM_SIGNATURE_BYTE = 'B',
149 JVM_SIGNATURE_CHAR = 'C',
150 JVM_SIGNATURE_CLASS = 'L',
151 JVM_SIGNATURE_ENDCLASS = ';',
152 JVM_SIGNATURE_ENUM = 'E',
153 JVM_SIGNATURE_FLOAT = 'F',
154 JVM_SIGNATURE_DOUBLE = 'D',
155 JVM_SIGNATURE_FUNC = '(',
156 JVM_SIGNATURE_ENDFUNC = ')',
157 JVM_SIGNATURE_INT = 'I',
158 JVM_SIGNATURE_LONG = 'J',
159 JVM_SIGNATURE_SHORT = 'S',
160 JVM_SIGNATURE_VOID = 'V',
161 JVM_SIGNATURE_BOOLEAN = 'Z'
162};
163
164/* Opcodes */
165
166enum {
167 JVM_OPC_nop = 0,
168 JVM_OPC_aconst_null = 1,
169 JVM_OPC_iconst_m1 = 2,
170 JVM_OPC_iconst_0 = 3,
171 JVM_OPC_iconst_1 = 4,
172 JVM_OPC_iconst_2 = 5,
173 JVM_OPC_iconst_3 = 6,
174 JVM_OPC_iconst_4 = 7,
175 JVM_OPC_iconst_5 = 8,
176 JVM_OPC_lconst_0 = 9,
177 JVM_OPC_lconst_1 = 10,
178 JVM_OPC_fconst_0 = 11,
179 JVM_OPC_fconst_1 = 12,
180 JVM_OPC_fconst_2 = 13,
181 JVM_OPC_dconst_0 = 14,
182 JVM_OPC_dconst_1 = 15,
183 JVM_OPC_bipush = 16,
184 JVM_OPC_sipush = 17,
185 JVM_OPC_ldc = 18,
186 JVM_OPC_ldc_w = 19,
187 JVM_OPC_ldc2_w = 20,
188 JVM_OPC_iload = 21,
189 JVM_OPC_lload = 22,
190 JVM_OPC_fload = 23,
191 JVM_OPC_dload = 24,
192 JVM_OPC_aload = 25,
193 JVM_OPC_iload_0 = 26,
194 JVM_OPC_iload_1 = 27,
195 JVM_OPC_iload_2 = 28,
196 JVM_OPC_iload_3 = 29,
197 JVM_OPC_lload_0 = 30,
198 JVM_OPC_lload_1 = 31,
199 JVM_OPC_lload_2 = 32,
200 JVM_OPC_lload_3 = 33,
201 JVM_OPC_fload_0 = 34,
202 JVM_OPC_fload_1 = 35,
203 JVM_OPC_fload_2 = 36,
204 JVM_OPC_fload_3 = 37,
205 JVM_OPC_dload_0 = 38,
206 JVM_OPC_dload_1 = 39,
207 JVM_OPC_dload_2 = 40,
208 JVM_OPC_dload_3 = 41,
209 JVM_OPC_aload_0 = 42,
210 JVM_OPC_aload_1 = 43,
211 JVM_OPC_aload_2 = 44,
212 JVM_OPC_aload_3 = 45,
213 JVM_OPC_iaload = 46,
214 JVM_OPC_laload = 47,
215 JVM_OPC_faload = 48,
216 JVM_OPC_daload = 49,
217 JVM_OPC_aaload = 50,
218 JVM_OPC_baload = 51,
219 JVM_OPC_caload = 52,
220 JVM_OPC_saload = 53,
221 JVM_OPC_istore = 54,
222 JVM_OPC_lstore = 55,
223 JVM_OPC_fstore = 56,
224 JVM_OPC_dstore = 57,
225 JVM_OPC_astore = 58,
226 JVM_OPC_istore_0 = 59,
227 JVM_OPC_istore_1 = 60,
228 JVM_OPC_istore_2 = 61,
229 JVM_OPC_istore_3 = 62,
230 JVM_OPC_lstore_0 = 63,
231 JVM_OPC_lstore_1 = 64,
232 JVM_OPC_lstore_2 = 65,
233 JVM_OPC_lstore_3 = 66,
234 JVM_OPC_fstore_0 = 67,
235 JVM_OPC_fstore_1 = 68,
236 JVM_OPC_fstore_2 = 69,
237 JVM_OPC_fstore_3 = 70,
238 JVM_OPC_dstore_0 = 71,
239 JVM_OPC_dstore_1 = 72,
240 JVM_OPC_dstore_2 = 73,
241 JVM_OPC_dstore_3 = 74,
242 JVM_OPC_astore_0 = 75,
243 JVM_OPC_astore_1 = 76,
244 JVM_OPC_astore_2 = 77,
245 JVM_OPC_astore_3 = 78,
246 JVM_OPC_iastore = 79,
247 JVM_OPC_lastore = 80,
248 JVM_OPC_fastore = 81,
249 JVM_OPC_dastore = 82,
250 JVM_OPC_aastore = 83,
251 JVM_OPC_bastore = 84,
252 JVM_OPC_castore = 85,
253 JVM_OPC_sastore = 86,
254 JVM_OPC_pop = 87,
255 JVM_OPC_pop2 = 88,
256 JVM_OPC_dup = 89,
257 JVM_OPC_dup_x1 = 90,
258 JVM_OPC_dup_x2 = 91,
259 JVM_OPC_dup2 = 92,
260 JVM_OPC_dup2_x1 = 93,
261 JVM_OPC_dup2_x2 = 94,
262 JVM_OPC_swap = 95,
263 JVM_OPC_iadd = 96,
264 JVM_OPC_ladd = 97,
265 JVM_OPC_fadd = 98,
266 JVM_OPC_dadd = 99,
267 JVM_OPC_isub = 100,
268 JVM_OPC_lsub = 101,
269 JVM_OPC_fsub = 102,
270 JVM_OPC_dsub = 103,
271 JVM_OPC_imul = 104,
272 JVM_OPC_lmul = 105,
273 JVM_OPC_fmul = 106,
274 JVM_OPC_dmul = 107,
275 JVM_OPC_idiv = 108,
276 JVM_OPC_ldiv = 109,
277 JVM_OPC_fdiv = 110,
278 JVM_OPC_ddiv = 111,
279 JVM_OPC_irem = 112,
280 JVM_OPC_lrem = 113,
281 JVM_OPC_frem = 114,
282 JVM_OPC_drem = 115,
283 JVM_OPC_ineg = 116,
284 JVM_OPC_lneg = 117,
285 JVM_OPC_fneg = 118,
286 JVM_OPC_dneg = 119,
287 JVM_OPC_ishl = 120,
288 JVM_OPC_lshl = 121,
289 JVM_OPC_ishr = 122,
290 JVM_OPC_lshr = 123,
291 JVM_OPC_iushr = 124,
292 JVM_OPC_lushr = 125,
293 JVM_OPC_iand = 126,
294 JVM_OPC_land = 127,
295 JVM_OPC_ior = 128,
296 JVM_OPC_lor = 129,
297 JVM_OPC_ixor = 130,
298 JVM_OPC_lxor = 131,
299 JVM_OPC_iinc = 132,
300 JVM_OPC_i2l = 133,
301 JVM_OPC_i2f = 134,
302 JVM_OPC_i2d = 135,
303 JVM_OPC_l2i = 136,
304 JVM_OPC_l2f = 137,
305 JVM_OPC_l2d = 138,
306 JVM_OPC_f2i = 139,
307 JVM_OPC_f2l = 140,
308 JVM_OPC_f2d = 141,
309 JVM_OPC_d2i = 142,
310 JVM_OPC_d2l = 143,
311 JVM_OPC_d2f = 144,
312 JVM_OPC_i2b = 145,
313 JVM_OPC_i2c = 146,
314 JVM_OPC_i2s = 147,
315 JVM_OPC_lcmp = 148,
316 JVM_OPC_fcmpl = 149,
317 JVM_OPC_fcmpg = 150,
318 JVM_OPC_dcmpl = 151,
319 JVM_OPC_dcmpg = 152,
320 JVM_OPC_ifeq = 153,
321 JVM_OPC_ifne = 154,
322 JVM_OPC_iflt = 155,
323 JVM_OPC_ifge = 156,
324 JVM_OPC_ifgt = 157,
325 JVM_OPC_ifle = 158,
326 JVM_OPC_if_icmpeq = 159,
327 JVM_OPC_if_icmpne = 160,
328 JVM_OPC_if_icmplt = 161,
329 JVM_OPC_if_icmpge = 162,
330 JVM_OPC_if_icmpgt = 163,
331 JVM_OPC_if_icmple = 164,
332 JVM_OPC_if_acmpeq = 165,
333 JVM_OPC_if_acmpne = 166,
334 JVM_OPC_goto = 167,
335 JVM_OPC_jsr = 168,
336 JVM_OPC_ret = 169,
337 JVM_OPC_tableswitch = 170,
338 JVM_OPC_lookupswitch = 171,
339 JVM_OPC_ireturn = 172,
340 JVM_OPC_lreturn = 173,
341 JVM_OPC_freturn = 174,
342 JVM_OPC_dreturn = 175,
343 JVM_OPC_areturn = 176,
344 JVM_OPC_return = 177,
345 JVM_OPC_getstatic = 178,
346 JVM_OPC_putstatic = 179,
347 JVM_OPC_getfield = 180,
348 JVM_OPC_putfield = 181,
349 JVM_OPC_invokevirtual = 182,
350 JVM_OPC_invokespecial = 183,
351 JVM_OPC_invokestatic = 184,
352 JVM_OPC_invokeinterface = 185,
353 JVM_OPC_invokedynamic = 186,
354 JVM_OPC_new = 187,
355 JVM_OPC_newarray = 188,
356 JVM_OPC_anewarray = 189,
357 JVM_OPC_arraylength = 190,
358 JVM_OPC_athrow = 191,
359 JVM_OPC_checkcast = 192,
360 JVM_OPC_instanceof = 193,
361 JVM_OPC_monitorenter = 194,
362 JVM_OPC_monitorexit = 195,
363 JVM_OPC_wide = 196,
364 JVM_OPC_multianewarray = 197,
365 JVM_OPC_ifnull = 198,
366 JVM_OPC_ifnonnull = 199,
367 JVM_OPC_goto_w = 200,
368 JVM_OPC_jsr_w = 201,
369 JVM_OPC_MAX = 201
370};
371
372/* Opcode length initializer, use with something like:
373 * unsigned char opcode_length[JVM_OPC_MAX+1] = JVM_OPCODE_LENGTH_INITIALIZER;
374 */
375#define JVM_OPCODE_LENGTH_INITIALIZER { \
376 1, /* nop */ \
377 1, /* aconst_null */ \
378 1, /* iconst_m1 */ \
379 1, /* iconst_0 */ \
380 1, /* iconst_1 */ \
381 1, /* iconst_2 */ \
382 1, /* iconst_3 */ \
383 1, /* iconst_4 */ \
384 1, /* iconst_5 */ \
385 1, /* lconst_0 */ \
386 1, /* lconst_1 */ \
387 1, /* fconst_0 */ \
388 1, /* fconst_1 */ \
389 1, /* fconst_2 */ \
390 1, /* dconst_0 */ \
391 1, /* dconst_1 */ \
392 2, /* bipush */ \
393 3, /* sipush */ \
394 2, /* ldc */ \
395 3, /* ldc_w */ \
396 3, /* ldc2_w */ \
397 2, /* iload */ \
398 2, /* lload */ \
399 2, /* fload */ \
400 2, /* dload */ \
401 2, /* aload */ \
402 1, /* iload_0 */ \
403 1, /* iload_1 */ \
404 1, /* iload_2 */ \
405 1, /* iload_3 */ \
406 1, /* lload_0 */ \
407 1, /* lload_1 */ \
408 1, /* lload_2 */ \
409 1, /* lload_3 */ \
410 1, /* fload_0 */ \
411 1, /* fload_1 */ \
412 1, /* fload_2 */ \
413 1, /* fload_3 */ \
414 1, /* dload_0 */ \
415 1, /* dload_1 */ \
416 1, /* dload_2 */ \
417 1, /* dload_3 */ \
418 1, /* aload_0 */ \
419 1, /* aload_1 */ \
420 1, /* aload_2 */ \
421 1, /* aload_3 */ \
422 1, /* iaload */ \
423 1, /* laload */ \
424 1, /* faload */ \
425 1, /* daload */ \
426 1, /* aaload */ \
427 1, /* baload */ \
428 1, /* caload */ \
429 1, /* saload */ \
430 2, /* istore */ \
431 2, /* lstore */ \
432 2, /* fstore */ \
433 2, /* dstore */ \
434 2, /* astore */ \
435 1, /* istore_0 */ \
436 1, /* istore_1 */ \
437 1, /* istore_2 */ \
438 1, /* istore_3 */ \
439 1, /* lstore_0 */ \
440 1, /* lstore_1 */ \
441 1, /* lstore_2 */ \
442 1, /* lstore_3 */ \
443 1, /* fstore_0 */ \
444 1, /* fstore_1 */ \
445 1, /* fstore_2 */ \
446 1, /* fstore_3 */ \
447 1, /* dstore_0 */ \
448 1, /* dstore_1 */ \
449 1, /* dstore_2 */ \
450 1, /* dstore_3 */ \
451 1, /* astore_0 */ \
452 1, /* astore_1 */ \
453 1, /* astore_2 */ \
454 1, /* astore_3 */ \
455 1, /* iastore */ \
456 1, /* lastore */ \
457 1, /* fastore */ \
458 1, /* dastore */ \
459 1, /* aastore */ \
460 1, /* bastore */ \
461 1, /* castore */ \
462 1, /* sastore */ \
463 1, /* pop */ \
464 1, /* pop2 */ \
465 1, /* dup */ \
466 1, /* dup_x1 */ \
467 1, /* dup_x2 */ \
468 1, /* dup2 */ \
469 1, /* dup2_x1 */ \
470 1, /* dup2_x2 */ \
471 1, /* swap */ \
472 1, /* iadd */ \
473 1, /* ladd */ \
474 1, /* fadd */ \
475 1, /* dadd */ \
476 1, /* isub */ \
477 1, /* lsub */ \
478 1, /* fsub */ \
479 1, /* dsub */ \
480 1, /* imul */ \
481 1, /* lmul */ \
482 1, /* fmul */ \
483 1, /* dmul */ \
484 1, /* idiv */ \
485 1, /* ldiv */ \
486 1, /* fdiv */ \
487 1, /* ddiv */ \
488 1, /* irem */ \
489 1, /* lrem */ \
490 1, /* frem */ \
491 1, /* drem */ \
492 1, /* ineg */ \
493 1, /* lneg */ \
494 1, /* fneg */ \
495 1, /* dneg */ \
496 1, /* ishl */ \
497 1, /* lshl */ \
498 1, /* ishr */ \
499 1, /* lshr */ \
500 1, /* iushr */ \
501 1, /* lushr */ \
502 1, /* iand */ \
503 1, /* land */ \
504 1, /* ior */ \
505 1, /* lor */ \
506 1, /* ixor */ \
507 1, /* lxor */ \
508 3, /* iinc */ \
509 1, /* i2l */ \
510 1, /* i2f */ \
511 1, /* i2d */ \
512 1, /* l2i */ \
513 1, /* l2f */ \
514 1, /* l2d */ \
515 1, /* f2i */ \
516 1, /* f2l */ \
517 1, /* f2d */ \
518 1, /* d2i */ \
519 1, /* d2l */ \
520 1, /* d2f */ \
521 1, /* i2b */ \
522 1, /* i2c */ \
523 1, /* i2s */ \
524 1, /* lcmp */ \
525 1, /* fcmpl */ \
526 1, /* fcmpg */ \
527 1, /* dcmpl */ \
528 1, /* dcmpg */ \
529 3, /* ifeq */ \
530 3, /* ifne */ \
531 3, /* iflt */ \
532 3, /* ifge */ \
533 3, /* ifgt */ \
534 3, /* ifle */ \
535 3, /* if_icmpeq */ \
536 3, /* if_icmpne */ \
537 3, /* if_icmplt */ \
538 3, /* if_icmpge */ \
539 3, /* if_icmpgt */ \
540 3, /* if_icmple */ \
541 3, /* if_acmpeq */ \
542 3, /* if_acmpne */ \
543 3, /* goto */ \
544 3, /* jsr */ \
545 2, /* ret */ \
546 99, /* tableswitch */ \
547 99, /* lookupswitch */ \
548 1, /* ireturn */ \
549 1, /* lreturn */ \
550 1, /* freturn */ \
551 1, /* dreturn */ \
552 1, /* areturn */ \
553 1, /* return */ \
554 3, /* getstatic */ \
555 3, /* putstatic */ \
556 3, /* getfield */ \
557 3, /* putfield */ \
558 3, /* invokevirtual */ \
559 3, /* invokespecial */ \
560 3, /* invokestatic */ \
561 5, /* invokeinterface */ \
562 5, /* invokedynamic */ \
563 3, /* new */ \
564 2, /* newarray */ \
565 3, /* anewarray */ \
566 1, /* arraylength */ \
567 1, /* athrow */ \
568 3, /* checkcast */ \
569 3, /* instanceof */ \
570 1, /* monitorenter */ \
571 1, /* monitorexit */ \
572 0, /* wide */ \
573 4, /* multianewarray */ \
574 3, /* ifnull */ \
575 3, /* ifnonnull */ \
576 5, /* goto_w */ \
577 5 /* jsr_w */ \
578}
579
580#ifdef __cplusplus
581} /* extern "C" */
582#endif /* __cplusplus */
583
584#endif /* CLASSFILE_CONSTANTS */
585