< prev index next >

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

Print this page

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





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

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


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