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