View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   *  Unless required by applicable law or agreed to in writing, software
12   *  distributed under the License is distributed on an "AS IS" BASIS,
13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   *  See the License for the specific language governing permissions and
15   *  limitations under the License.
16   */
17  package org.apache.bcel.generic;
18  
19  /**
20   * Contains shareable instruction objects.
21   * <p>
22   * In order to save memory you can use some instructions multiply, since they have an immutable state and are directly
23   * derived from Instruction. I.e. they have no instance fields that could be changed. Since some of these instructions
24   * like ICONST_0 occur very frequently this can save a lot of time and space. This feature is an adaptation of the
25   * FlyWeight design pattern, we just use an array instead of a factory.
26   * </p>
27   * <p>
28   * The Instructions can also accessed directly under their names, so it's possible to write
29   * il.append(Instruction.ICONST_0);
30   * </p>
31   *
32   * @deprecated (since 6.0) Do not use. Use {@link InstructionConst} instead.
33   */
34  @Deprecated
35  public interface InstructionConstants {
36  
37      /**
38       * Deprecated, consider private and ignore.
39       */
40      class Clinit {
41          // empty
42      }
43  
44      /*
45       * NOTE these are not currently immutable, because Instruction has mutable protected fields opcode and length.
46       */
47      Instruction NOP = InstructionConst.NOP;
48      Instruction ACONST_NULL = InstructionConst.ACONST_NULL;
49      Instruction ICONST_M1 = InstructionConst.ICONST_M1;
50      Instruction ICONST_0 = InstructionConst.ICONST_0;
51      Instruction ICONST_1 = InstructionConst.ICONST_1;
52      Instruction ICONST_2 = InstructionConst.ICONST_2;
53      Instruction ICONST_3 = InstructionConst.ICONST_3;
54      Instruction ICONST_4 = InstructionConst.ICONST_4;
55      Instruction ICONST_5 = InstructionConst.ICONST_5;
56      Instruction LCONST_0 = InstructionConst.LCONST_0;
57      Instruction LCONST_1 = InstructionConst.LCONST_1;
58      Instruction FCONST_0 = InstructionConst.FCONST_0;
59      Instruction FCONST_1 = InstructionConst.FCONST_1;
60      Instruction FCONST_2 = InstructionConst.FCONST_2;
61      Instruction DCONST_0 = InstructionConst.DCONST_0;
62      Instruction DCONST_1 = InstructionConst.DCONST_1;
63      ArrayInstruction IALOAD = InstructionConst.IALOAD;
64      ArrayInstruction LALOAD = InstructionConst.LALOAD;
65      ArrayInstruction FALOAD = InstructionConst.FALOAD;
66      ArrayInstruction DALOAD = InstructionConst.DALOAD;
67      ArrayInstruction AALOAD = InstructionConst.AALOAD;
68      ArrayInstruction BALOAD = InstructionConst.BALOAD;
69      ArrayInstruction CALOAD = InstructionConst.CALOAD;
70      ArrayInstruction SALOAD = InstructionConst.SALOAD;
71      ArrayInstruction IASTORE = InstructionConst.IASTORE;
72      ArrayInstruction LASTORE = InstructionConst.LASTORE;
73      ArrayInstruction FASTORE = InstructionConst.FASTORE;
74      ArrayInstruction DASTORE = InstructionConst.DASTORE;
75      ArrayInstruction AASTORE = InstructionConst.AASTORE;
76      ArrayInstruction BASTORE = InstructionConst.BASTORE;
77      ArrayInstruction CASTORE = InstructionConst.CASTORE;
78      ArrayInstruction SASTORE = InstructionConst.SASTORE;
79      StackInstruction POP = InstructionConst.POP;
80      StackInstruction POP2 = InstructionConst.POP2;
81      StackInstruction DUP = InstructionConst.DUP;
82      StackInstruction DUP_X1 = InstructionConst.DUP_X1;
83      StackInstruction DUP_X2 = InstructionConst.DUP_X2;
84      StackInstruction DUP2 = InstructionConst.DUP2;
85      StackInstruction DUP2_X1 = InstructionConst.DUP2_X1;
86      StackInstruction DUP2_X2 = InstructionConst.DUP2_X2;
87      StackInstruction SWAP = InstructionConst.SWAP;
88      ArithmeticInstruction IADD = InstructionConst.IADD;
89      ArithmeticInstruction LADD = InstructionConst.LADD;
90      ArithmeticInstruction FADD = InstructionConst.FADD;
91      ArithmeticInstruction DADD = InstructionConst.DADD;
92      ArithmeticInstruction ISUB = InstructionConst.ISUB;
93      ArithmeticInstruction LSUB = InstructionConst.LSUB;
94      ArithmeticInstruction FSUB = InstructionConst.FSUB;
95      ArithmeticInstruction DSUB = InstructionConst.DSUB;
96      ArithmeticInstruction IMUL = InstructionConst.IMUL;
97      ArithmeticInstruction LMUL = InstructionConst.LMUL;
98      ArithmeticInstruction FMUL = InstructionConst.FMUL;
99      ArithmeticInstruction DMUL = InstructionConst.DMUL;
100     ArithmeticInstruction IDIV = InstructionConst.IDIV;
101     ArithmeticInstruction LDIV = InstructionConst.LDIV;
102     ArithmeticInstruction FDIV = InstructionConst.FDIV;
103     ArithmeticInstruction DDIV = InstructionConst.DDIV;
104     ArithmeticInstruction IREM = InstructionConst.IREM;
105     ArithmeticInstruction LREM = InstructionConst.LREM;
106     ArithmeticInstruction FREM = InstructionConst.FREM;
107     ArithmeticInstruction DREM = InstructionConst.DREM;
108     ArithmeticInstruction INEG = InstructionConst.INEG;
109     ArithmeticInstruction LNEG = InstructionConst.LNEG;
110     ArithmeticInstruction FNEG = InstructionConst.FNEG;
111     ArithmeticInstruction DNEG = InstructionConst.DNEG;
112     ArithmeticInstruction ISHL = InstructionConst.ISHL;
113     ArithmeticInstruction LSHL = InstructionConst.LSHL;
114     ArithmeticInstruction ISHR = InstructionConst.ISHR;
115     ArithmeticInstruction LSHR = InstructionConst.LSHR;
116     ArithmeticInstruction IUSHR = InstructionConst.IUSHR;
117     ArithmeticInstruction LUSHR = InstructionConst.LUSHR;
118     ArithmeticInstruction IAND = InstructionConst.IAND;
119     ArithmeticInstruction LAND = InstructionConst.LAND;
120     ArithmeticInstruction IOR = InstructionConst.IOR;
121     ArithmeticInstruction LOR = InstructionConst.LOR;
122     ArithmeticInstruction IXOR = InstructionConst.IXOR;
123     ArithmeticInstruction LXOR = InstructionConst.LXOR;
124     ConversionInstruction I2L = InstructionConst.I2L;
125     ConversionInstruction I2F = InstructionConst.I2F;
126     ConversionInstruction I2D = InstructionConst.I2D;
127     ConversionInstruction L2I = InstructionConst.L2I;
128     ConversionInstruction L2F = InstructionConst.L2F;
129     ConversionInstruction L2D = InstructionConst.L2D;
130     ConversionInstruction F2I = InstructionConst.F2I;
131     ConversionInstruction F2L = InstructionConst.F2L;
132     ConversionInstruction F2D = InstructionConst.F2D;
133     ConversionInstruction D2I = InstructionConst.D2I;
134     ConversionInstruction D2L = InstructionConst.D2L;
135     ConversionInstruction D2F = InstructionConst.D2F;
136     ConversionInstruction I2B = InstructionConst.I2B;
137     ConversionInstruction I2C = InstructionConst.I2C;
138     ConversionInstruction I2S = InstructionConst.I2S;
139     Instruction LCMP = InstructionConst.LCMP;
140     Instruction FCMPL = InstructionConst.FCMPL;
141     Instruction FCMPG = InstructionConst.FCMPG;
142     Instruction DCMPL = InstructionConst.DCMPL;
143     Instruction DCMPG = InstructionConst.DCMPG;
144     ReturnInstruction IRETURN = InstructionConst.IRETURN;
145     ReturnInstruction LRETURN = InstructionConst.LRETURN;
146     ReturnInstruction FRETURN = InstructionConst.FRETURN;
147     ReturnInstruction DRETURN = InstructionConst.DRETURN;
148     ReturnInstruction ARETURN = InstructionConst.ARETURN;
149     ReturnInstruction RETURN = InstructionConst.RETURN;
150     Instruction ARRAYLENGTH = InstructionConst.ARRAYLENGTH;
151     Instruction ATHROW = InstructionConst.ATHROW;
152     Instruction MONITORENTER = InstructionConst.MONITORENTER;
153     Instruction MONITOREXIT = InstructionConst.MONITOREXIT;
154 
155     /**
156      * You can use these constants in multiple places safely, if you can guarantee that you will never alter their internal
157      * values, e.g. call setIndex().
158      */
159     LocalVariableInstruction THIS = InstructionConst.THIS;
160     LocalVariableInstruction ALOAD_0 = InstructionConst.ALOAD_0;
161     LocalVariableInstruction ALOAD_1 = InstructionConst.ALOAD_1;
162     LocalVariableInstruction ALOAD_2 = InstructionConst.ALOAD_2;
163     LocalVariableInstruction ILOAD_0 = InstructionConst.ILOAD_0;
164     LocalVariableInstruction ILOAD_1 = InstructionConst.ILOAD_1;
165     LocalVariableInstruction ILOAD_2 = InstructionConst.ILOAD_2;
166     LocalVariableInstruction ASTORE_0 = InstructionConst.ASTORE_0;
167     LocalVariableInstruction ASTORE_1 = InstructionConst.ASTORE_1;
168     LocalVariableInstruction ASTORE_2 = InstructionConst.ASTORE_2;
169     LocalVariableInstruction ISTORE_0 = InstructionConst.ISTORE_0;
170     LocalVariableInstruction ISTORE_1 = InstructionConst.ISTORE_1;
171     LocalVariableInstruction ISTORE_2 = InstructionConst.ISTORE_2;
172 
173     /**
174      * Gets object via its opcode, for immutable instructions like branch instructions entries are set to null.
175      */
176     Instruction[] INSTRUCTIONS = InstructionConst.INSTRUCTIONS;
177 
178     /**
179      * Interfaces may have no static initializers, so we simulate this with an inner class.
180      */
181     Clinit bla = new Clinit();
182 }