1 /*
2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3  *
4  * This code is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 2 only, as
6  * published by the Free Software Foundation.  Oracle designates this
7  * particular file as subject to the "Classpath" exception as provided
8  * by Oracle in the LICENSE file that accompanied this code.
9  *
10  * This code is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13  * version 2 for more details (a copy is included in the LICENSE file that
14  * accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License version
17  * 2 along with this work; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19  *
20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21  * or visit www.oracle.com if you need additional information or have any
22  * questions.
23  */
24 
25 /*
26  * This file is available under and governed by the GNU General Public
27  * License version 2 only, as published by the Free Software Foundation.
28  * However, the following notice accompanied the original version of this
29  * file:
30  *
31  * ASM: a very small and fast Java bytecode manipulation framework
32  * Copyright (c) 2000-2011 INRIA, France Telecom
33  * All rights reserved.
34  *
35  * Redistribution and use in source and binary forms, with or without
36  * modification, are permitted provided that the following conditions
37  * are met:
38  * 1. Redistributions of source code must retain the above copyright
39  *    notice, this list of conditions and the following disclaimer.
40  * 2. Redistributions in binary form must reproduce the above copyright
41  *    notice, this list of conditions and the following disclaimer in the
42  *    documentation and/or other materials provided with the distribution.
43  * 3. Neither the name of the copyright holders nor the names of its
44  *    contributors may be used to endorse or promote products derived from
45  *    this software without specific prior written permission.
46  *
47  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
51  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
52  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
53  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
54  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
55  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
56  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
57  * THE POSSIBILITY OF SUCH DAMAGE.
58  */
59 package jdk.internal.org.objectweb.asm;
60 
61 /**
62  * Defines additional JVM opcodes, access flags and constants which are not part of the ASM public
63  * API.
64  *
65  * @see <a href="https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-6.html">JVMS 6</a>
66  * @author Eric Bruneton
67  */
68 final class Constants implements Opcodes {
69 
70     // The ClassFile attribute names, in the order they are defined in
71     // https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-4.html#jvms-4.7-300.
72 
73     static final String CONSTANT_VALUE = "ConstantValue";
74     static final String CODE = "Code";
75     static final String STACK_MAP_TABLE = "StackMapTable";
76     static final String EXCEPTIONS = "Exceptions";
77     static final String INNER_CLASSES = "InnerClasses";
78     static final String ENCLOSING_METHOD = "EnclosingMethod";
79     static final String SYNTHETIC = "Synthetic";
80     static final String SIGNATURE = "Signature";
81     static final String SOURCE_FILE = "SourceFile";
82     static final String SOURCE_DEBUG_EXTENSION = "SourceDebugExtension";
83     static final String LINE_NUMBER_TABLE = "LineNumberTable";
84     static final String LOCAL_VARIABLE_TABLE = "LocalVariableTable";
85     static final String LOCAL_VARIABLE_TYPE_TABLE = "LocalVariableTypeTable";
86     static final String DEPRECATED = "Deprecated";
87     static final String RUNTIME_VISIBLE_ANNOTATIONS = "RuntimeVisibleAnnotations";
88     static final String RUNTIME_INVISIBLE_ANNOTATIONS = "RuntimeInvisibleAnnotations";
89     static final String RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS = "RuntimeVisibleParameterAnnotations";
90     static final String RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS =
91             "RuntimeInvisibleParameterAnnotations";
92     static final String RUNTIME_VISIBLE_TYPE_ANNOTATIONS = "RuntimeVisibleTypeAnnotations";
93     static final String RUNTIME_INVISIBLE_TYPE_ANNOTATIONS = "RuntimeInvisibleTypeAnnotations";
94     static final String ANNOTATION_DEFAULT = "AnnotationDefault";
95     static final String BOOTSTRAP_METHODS = "BootstrapMethods";
96     static final String METHOD_PARAMETERS = "MethodParameters";
97     static final String MODULE = "Module";
98     static final String MODULE_PACKAGES = "ModulePackages";
99     static final String MODULE_MAIN_CLASS = "ModuleMainClass";
100     static final String NEST_HOST = "NestHost";
101     static final String NEST_MEMBERS = "NestMembers";
102 
103     // ASM specific access flags.
104     // WARNING: the 16 least significant bits must NOT be used, to avoid conflicts with standard
105     // access flags, and also to make sure that these flags are automatically filtered out when
106     // written in class files (because access flags are stored using 16 bits only).
107 
108     static final int ACC_CONSTRUCTOR = 0x40000; // method access flag.
109 
110     // ASM specific stack map frame types, used in {@link ClassVisitor#visitFrame}.
111 
112     /**
113       * A frame inserted between already existing frames. This internal stack map frame type (in
114       * addition to the ones declared in {@link Opcodes}) can only be used if the frame content can be
115       * computed from the previous existing frame and from the instructions between this existing frame
116       * and the inserted one, without any knowledge of the type hierarchy. This kind of frame is only
117       * used when an unconditional jump is inserted in a method while expanding an ASM specific
118       * instruction. Keep in sync with Opcodes.java.
119       */
120     static final int F_INSERT = 256;
121 
122     // The JVM opcode values which are not part of the ASM public API.
123     // See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-6.html.
124 
125     static final int LDC_W = 19;
126     static final int LDC2_W = 20;
127     static final int ILOAD_0 = 26;
128     static final int ILOAD_1 = 27;
129     static final int ILOAD_2 = 28;
130     static final int ILOAD_3 = 29;
131     static final int LLOAD_0 = 30;
132     static final int LLOAD_1 = 31;
133     static final int LLOAD_2 = 32;
134     static final int LLOAD_3 = 33;
135     static final int FLOAD_0 = 34;
136     static final int FLOAD_1 = 35;
137     static final int FLOAD_2 = 36;
138     static final int FLOAD_3 = 37;
139     static final int DLOAD_0 = 38;
140     static final int DLOAD_1 = 39;
141     static final int DLOAD_2 = 40;
142     static final int DLOAD_3 = 41;
143     static final int ALOAD_0 = 42;
144     static final int ALOAD_1 = 43;
145     static final int ALOAD_2 = 44;
146     static final int ALOAD_3 = 45;
147     static final int ISTORE_0 = 59;
148     static final int ISTORE_1 = 60;
149     static final int ISTORE_2 = 61;
150     static final int ISTORE_3 = 62;
151     static final int LSTORE_0 = 63;
152     static final int LSTORE_1 = 64;
153     static final int LSTORE_2 = 65;
154     static final int LSTORE_3 = 66;
155     static final int FSTORE_0 = 67;
156     static final int FSTORE_1 = 68;
157     static final int FSTORE_2 = 69;
158     static final int FSTORE_3 = 70;
159     static final int DSTORE_0 = 71;
160     static final int DSTORE_1 = 72;
161     static final int DSTORE_2 = 73;
162     static final int DSTORE_3 = 74;
163     static final int ASTORE_0 = 75;
164     static final int ASTORE_1 = 76;
165     static final int ASTORE_2 = 77;
166     static final int ASTORE_3 = 78;
167     static final int WIDE = 196;
168     static final int GOTO_W = 200;
169     static final int JSR_W = 201;
170 
171     // Constants to convert between normal and wide jump instructions.
172 
173     // The delta between the GOTO_W and JSR_W opcodes and GOTO and JUMP.
174     static final int WIDE_JUMP_OPCODE_DELTA = GOTO_W - GOTO;
175 
176     // Constants to convert JVM opcodes to the equivalent ASM specific opcodes, and vice versa.
177 
178     // The delta between the ASM_IFEQ, ..., ASM_IF_ACMPNE, ASM_GOTO and ASM_JSR opcodes
179     // and IFEQ, ..., IF_ACMPNE, GOTO and JSR.
180     static final int ASM_OPCODE_DELTA = 49;
181 
182     // The delta between the ASM_IFNULL and ASM_IFNONNULL opcodes and IFNULL and IFNONNULL.
183     static final int ASM_IFNULL_OPCODE_DELTA = 20;
184 
185     // ASM specific opcodes, used for long forward jump instructions.
186 
187     static final int ASM_IFEQ = IFEQ + ASM_OPCODE_DELTA;
188     static final int ASM_IFNE = IFNE + ASM_OPCODE_DELTA;
189     static final int ASM_IFLT = IFLT + ASM_OPCODE_DELTA;
190     static final int ASM_IFGE = IFGE + ASM_OPCODE_DELTA;
191     static final int ASM_IFGT = IFGT + ASM_OPCODE_DELTA;
192     static final int ASM_IFLE = IFLE + ASM_OPCODE_DELTA;
193     static final int ASM_IF_ICMPEQ = IF_ICMPEQ + ASM_OPCODE_DELTA;
194     static final int ASM_IF_ICMPNE = IF_ICMPNE + ASM_OPCODE_DELTA;
195     static final int ASM_IF_ICMPLT = IF_ICMPLT + ASM_OPCODE_DELTA;
196     static final int ASM_IF_ICMPGE = IF_ICMPGE + ASM_OPCODE_DELTA;
197     static final int ASM_IF_ICMPGT = IF_ICMPGT + ASM_OPCODE_DELTA;
198     static final int ASM_IF_ICMPLE = IF_ICMPLE + ASM_OPCODE_DELTA;
199     static final int ASM_IF_ACMPEQ = IF_ACMPEQ + ASM_OPCODE_DELTA;
200     static final int ASM_IF_ACMPNE = IF_ACMPNE + ASM_OPCODE_DELTA;
201     static final int ASM_GOTO = GOTO + ASM_OPCODE_DELTA;
202     static final int ASM_JSR = JSR + ASM_OPCODE_DELTA;
203     static final int ASM_IFNULL = IFNULL + ASM_IFNULL_OPCODE_DELTA;
204     static final int ASM_IFNONNULL = IFNONNULL + ASM_IFNULL_OPCODE_DELTA;
205     static final int ASM_GOTO_W = 220;
206 
Constants()207     private Constants() {}
208 }
209