< prev index next >

src/java.base/share/classes/jdk/internal/org/objectweb/asm/Constants.java

Print this page

167     static final int DSTORE_1 = 72;
168     static final int DSTORE_2 = 73;
169     static final int DSTORE_3 = 74;
170     static final int ASTORE_0 = 75;
171     static final int ASTORE_1 = 76;
172     static final int ASTORE_2 = 77;
173     static final int ASTORE_3 = 78;
174     static final int WIDE = 196;
175     static final int GOTO_W = 200;
176     static final int JSR_W = 201;
177 
178     // Constants to convert between normal and wide jump instructions.
179 
180     // The delta between the GOTO_W and JSR_W opcodes and GOTO and JUMP.
181     static final int WIDE_JUMP_OPCODE_DELTA = GOTO_W - Opcodes.GOTO;
182 
183     // Constants to convert JVM opcodes to the equivalent ASM specific opcodes, and vice versa.
184 
185     // The delta between the ASM_IFEQ, ..., ASM_IF_ACMPNE, ASM_GOTO and ASM_JSR opcodes
186     // and IFEQ, ..., IF_ACMPNE, GOTO and JSR.
187     static final int ASM_OPCODE_DELTA = 49;
188 
189     // The delta between the ASM_IFNULL and ASM_IFNONNULL opcodes and IFNULL and IFNONNULL.
190     static final int ASM_IFNULL_OPCODE_DELTA = 20;
191 
192     // ASM specific opcodes, used for long forward jump instructions.
193 
194     static final int ASM_IFEQ = Opcodes.IFEQ + ASM_OPCODE_DELTA;
195     static final int ASM_IFNE = Opcodes.IFNE + ASM_OPCODE_DELTA;
196     static final int ASM_IFLT = Opcodes.IFLT + ASM_OPCODE_DELTA;
197     static final int ASM_IFGE = Opcodes.IFGE + ASM_OPCODE_DELTA;
198     static final int ASM_IFGT = Opcodes.IFGT + ASM_OPCODE_DELTA;
199     static final int ASM_IFLE = Opcodes.IFLE + ASM_OPCODE_DELTA;
200     static final int ASM_IF_ICMPEQ = Opcodes.IF_ICMPEQ + ASM_OPCODE_DELTA;
201     static final int ASM_IF_ICMPNE = Opcodes.IF_ICMPNE + ASM_OPCODE_DELTA;
202     static final int ASM_IF_ICMPLT = Opcodes.IF_ICMPLT + ASM_OPCODE_DELTA;
203     static final int ASM_IF_ICMPGE = Opcodes.IF_ICMPGE + ASM_OPCODE_DELTA;
204     static final int ASM_IF_ICMPGT = Opcodes.IF_ICMPGT + ASM_OPCODE_DELTA;
205     static final int ASM_IF_ICMPLE = Opcodes.IF_ICMPLE + ASM_OPCODE_DELTA;
206     static final int ASM_IF_ACMPEQ = Opcodes.IF_ACMPEQ + ASM_OPCODE_DELTA;
207     static final int ASM_IF_ACMPNE = Opcodes.IF_ACMPNE + ASM_OPCODE_DELTA;
208     static final int ASM_GOTO = Opcodes.GOTO + ASM_OPCODE_DELTA;
209     static final int ASM_JSR = Opcodes.JSR + ASM_OPCODE_DELTA;





210     static final int ASM_IFNULL = Opcodes.IFNULL + ASM_IFNULL_OPCODE_DELTA;
211     static final int ASM_IFNONNULL = Opcodes.IFNONNULL + ASM_IFNULL_OPCODE_DELTA;
212     static final int ASM_GOTO_W = 220;
213 
214     private Constants() {}
215 
216     static void checkAsmExperimental(final Object caller) {
217         Class<?> callerClass = caller.getClass();
218         String internalName = callerClass.getName().replace('.', '/');
219         if (!isWhitelisted(internalName)) {
220             checkIsPreview(callerClass.getClassLoader().getResourceAsStream(internalName + ".class"));
221         }
222     }
223 
224     static boolean isWhitelisted(final String internalName) {
225         if (!internalName.startsWith("jdk/internal/org/objectweb/asm/")) {
226             return false;
227         }
228         String member = "(Annotation|Class|Field|Method|Module|RecordComponent|Signature)";
229         return internalName.contains("Test$")
230                 || Pattern.matches(
231                         "jdk/internal/org/objectweb/asm/util/Trace" + member + "Visitor(\\$.*)?", internalName)
232                 || Pattern.matches(

167     static final int DSTORE_1 = 72;
168     static final int DSTORE_2 = 73;
169     static final int DSTORE_3 = 74;
170     static final int ASTORE_0 = 75;
171     static final int ASTORE_1 = 76;
172     static final int ASTORE_2 = 77;
173     static final int ASTORE_3 = 78;
174     static final int WIDE = 196;
175     static final int GOTO_W = 200;
176     static final int JSR_W = 201;
177 
178     // Constants to convert between normal and wide jump instructions.
179 
180     // The delta between the GOTO_W and JSR_W opcodes and GOTO and JUMP.
181     static final int WIDE_JUMP_OPCODE_DELTA = GOTO_W - Opcodes.GOTO;
182 
183     // Constants to convert JVM opcodes to the equivalent ASM specific opcodes, and vice versa.
184 
185     // The delta between the ASM_IFEQ, ..., ASM_IF_ACMPNE, ASM_GOTO and ASM_JSR opcodes
186     // and IFEQ, ..., IF_ACMPNE, GOTO and JSR.
187     // Offset to next available opcode after WITHFIELD from IFEQ
188     static final int ASM_OPCODE_DELTA = (Opcodes.WITHFIELD + 1) - Opcodes.IFEQ;


189 
190     // ASM specific opcodes, used for long forward jump instructions.
191 
192     static final int ASM_IFEQ = Opcodes.IFEQ + ASM_OPCODE_DELTA;
193     static final int ASM_IFNE = Opcodes.IFNE + ASM_OPCODE_DELTA;
194     static final int ASM_IFLT = Opcodes.IFLT + ASM_OPCODE_DELTA;
195     static final int ASM_IFGE = Opcodes.IFGE + ASM_OPCODE_DELTA;
196     static final int ASM_IFGT = Opcodes.IFGT + ASM_OPCODE_DELTA;
197     static final int ASM_IFLE = Opcodes.IFLE + ASM_OPCODE_DELTA;
198     static final int ASM_IF_ICMPEQ = Opcodes.IF_ICMPEQ + ASM_OPCODE_DELTA;
199     static final int ASM_IF_ICMPNE = Opcodes.IF_ICMPNE + ASM_OPCODE_DELTA;
200     static final int ASM_IF_ICMPLT = Opcodes.IF_ICMPLT + ASM_OPCODE_DELTA;
201     static final int ASM_IF_ICMPGE = Opcodes.IF_ICMPGE + ASM_OPCODE_DELTA;
202     static final int ASM_IF_ICMPGT = Opcodes.IF_ICMPGT + ASM_OPCODE_DELTA;
203     static final int ASM_IF_ICMPLE = Opcodes.IF_ICMPLE + ASM_OPCODE_DELTA;
204     static final int ASM_IF_ACMPEQ = Opcodes.IF_ACMPEQ + ASM_OPCODE_DELTA;
205     static final int ASM_IF_ACMPNE = Opcodes.IF_ACMPNE + ASM_OPCODE_DELTA;
206     static final int ASM_GOTO = Opcodes.GOTO + ASM_OPCODE_DELTA;
207     static final int ASM_JSR = Opcodes.JSR + ASM_OPCODE_DELTA;
208 
209     // The delta between the ASM_IFNULL and ASM_IFNONNULL opcodes and IFNULL and IFNONNULL.
210     // Offset to next available opcode after ASM_JSR from IFNULL.
211     static final int ASM_IFNULL_OPCODE_DELTA = (ASM_JSR + 1) - Opcodes.IFNULL;
212 
213     static final int ASM_IFNULL = Opcodes.IFNULL + ASM_IFNULL_OPCODE_DELTA;
214     static final int ASM_IFNONNULL = Opcodes.IFNONNULL + ASM_IFNULL_OPCODE_DELTA;
215     static final int ASM_GOTO_W = GOTO_W + ASM_IFNULL_OPCODE_DELTA;
216 
217     private Constants() {}
218 
219     static void checkAsmExperimental(final Object caller) {
220         Class<?> callerClass = caller.getClass();
221         String internalName = callerClass.getName().replace('.', '/');
222         if (!isWhitelisted(internalName)) {
223             checkIsPreview(callerClass.getClassLoader().getResourceAsStream(internalName + ".class"));
224         }
225     }
226 
227     static boolean isWhitelisted(final String internalName) {
228         if (!internalName.startsWith("jdk/internal/org/objectweb/asm/")) {
229             return false;
230         }
231         String member = "(Annotation|Class|Field|Method|Module|RecordComponent|Signature)";
232         return internalName.contains("Test$")
233                 || Pattern.matches(
234                         "jdk/internal/org/objectweb/asm/util/Trace" + member + "Visitor(\\$.*)?", internalName)
235                 || Pattern.matches(
< prev index next >