Java Code Examples for jdk.internal.org.objectweb.asm.Opcodes#ASM7
The following examples show how to use
jdk.internal.org.objectweb.asm.Opcodes#ASM7 .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClassNode.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Constructs a new {@link ClassNode}. <i>Subclasses must not use this constructor</i>. Instead, * they must use the {@link #ClassNode(int)} version. * * @throws IllegalStateException If a subclass calls this constructor. */ public ClassNode() { this(Opcodes.ASM7); if (getClass() != ClassNode.class) { throw new IllegalStateException(); } }
Example 2
Source File: SignatureVisitor.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Constructs a new {@link SignatureVisitor}. * * @param api the ASM API version implemented by this visitor. Must be one of {@link * Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}. */ public SignatureVisitor(final int api) { if (api != Opcodes.ASM6 && api != Opcodes.ASM5 && api != Opcodes.ASM4 && api != Opcodes.ASM7) { throw new IllegalArgumentException(); } this.api = api; }
Example 3
Source File: InstructionAdapter.java From Bytecoder with Apache License 2.0 | 5 votes |
@Override public void visitLdcInsn(final Object value) { if (api < Opcodes.ASM5 && (value instanceof Handle || (value instanceof Type && ((Type) value).getSort() == Type.METHOD))) { throw new UnsupportedOperationException("This feature requires ASM5"); } if (api != Opcodes.ASM7 && value instanceof ConstantDynamic) { throw new UnsupportedOperationException("This feature requires ASM7"); } if (value instanceof Integer) { iconst((Integer) value); } else if (value instanceof Byte) { iconst(((Byte) value).intValue()); } else if (value instanceof Character) { iconst(((Character) value).charValue()); } else if (value instanceof Short) { iconst(((Short) value).intValue()); } else if (value instanceof Boolean) { iconst(((Boolean) value).booleanValue() ? 1 : 0); } else if (value instanceof Float) { fconst((Float) value); } else if (value instanceof Long) { lconst((Long) value); } else if (value instanceof Double) { dconst((Double) value); } else if (value instanceof String) { aconst(value); } else if (value instanceof Type) { tconst((Type) value); } else if (value instanceof Handle) { hconst((Handle) value); } else if (value instanceof ConstantDynamic) { cconst((ConstantDynamic) value); } else { throw new IllegalArgumentException(); } }
Example 4
Source File: ClassNode.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * Checks that this class node is compatible with the given ASM API version. This method checks * that this node, and all its children recursively, do not contain elements that were introduced * in more recent versions of the ASM API than the given version. * * @param api an ASM API version. Must be one of {@link Opcodes#ASM4}, {@link Opcodes#ASM5}, * {@link Opcodes#ASM6} or {@link Opcodes#ASM7}. */ public void check(final int api) { if (api < Opcodes.ASM7 && (nestHostClass != null || nestMembers != null)) { throw new UnsupportedClassVersionException(); } if (api < Opcodes.ASM6 && module != null) { throw new UnsupportedClassVersionException(); } if (api < Opcodes.ASM5) { if (visibleTypeAnnotations != null && !visibleTypeAnnotations.isEmpty()) { throw new UnsupportedClassVersionException(); } if (invisibleTypeAnnotations != null && !invisibleTypeAnnotations.isEmpty()) { throw new UnsupportedClassVersionException(); } } // Check the annotations. if (visibleAnnotations != null) { for (int i = visibleAnnotations.size() - 1; i >= 0; --i) { visibleAnnotations.get(i).check(api); } } if (invisibleAnnotations != null) { for (int i = invisibleAnnotations.size() - 1; i >= 0; --i) { invisibleAnnotations.get(i).check(api); } } if (visibleTypeAnnotations != null) { for (int i = visibleTypeAnnotations.size() - 1; i >= 0; --i) { visibleTypeAnnotations.get(i).check(api); } } if (invisibleTypeAnnotations != null) { for (int i = invisibleTypeAnnotations.size() - 1; i >= 0; --i) { invisibleTypeAnnotations.get(i).check(api); } } for (int i = fields.size() - 1; i >= 0; --i) { fields.get(i).check(api); } for (int i = methods.size() - 1; i >= 0; --i) { methods.get(i).check(api); } }
Example 5
Source File: CodeSizeEvaluator.java From Bytecoder with Apache License 2.0 | 4 votes |
public CodeSizeEvaluator(final MethodVisitor methodVisitor) { this(Opcodes.ASM7, methodVisitor); }
Example 6
Source File: CheckAnnotationAdapter.java From Bytecoder with Apache License 2.0 | 4 votes |
CheckAnnotationAdapter(final AnnotationVisitor annotationVisitor, final boolean useNamedValues) { super(Opcodes.ASM7, annotationVisitor); this.useNamedValue = useNamedValues; }
Example 7
Source File: CheckMethodAdapter.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * Constructs a new {@link CheckMethodAdapter} object. This method adapter will not perform any * data flow check (see {@link #CheckMethodAdapter(int,String,String,MethodVisitor,Map)}). * <i>Subclasses must not use this constructor</i>. Instead, they must use the {@link * #CheckMethodAdapter(int, MethodVisitor, Map)} version. * * @param methodVisitor the method visitor to which this adapter must delegate calls. * @param labelInsnIndices the index of the instruction designated by each visited label so far * (in other methods). This map is updated with the labels from the visited method. * @throws IllegalStateException If a subclass calls this constructor. */ public CheckMethodAdapter( final MethodVisitor methodVisitor, final Map<Label, Integer> labelInsnIndices) { this(Opcodes.ASM7, methodVisitor, labelInsnIndices); if (getClass() != CheckMethodAdapter.class) { throw new IllegalStateException(); } }
Example 8
Source File: TryCatchBlockSorter.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * Constructs a new {@link TryCatchBlockSorter}. * * @param methodVisitor the method visitor to which this visitor must delegate method calls. May * be {@literal null}. * @param access the method's access flags (see {@link Opcodes}). This parameter also indicates if * the method is synthetic and/or deprecated. * @param name the method's name. * @param descriptor the method's descriptor (see {@link jdk.internal.org.objectweb.asm.Type}). * @param signature the method's signature. May be {@literal null} if the method parameters, * return type and exceptions do not use generic types. * @param exceptions the internal names of the method's exception classes (see {@link * jdk.internal.org.objectweb.asm.Type#getInternalName()}). May be {@literal null}. */ public TryCatchBlockSorter( final MethodVisitor methodVisitor, final int access, final String name, final String descriptor, final String signature, final String[] exceptions) { this(Opcodes.ASM7, methodVisitor, access, name, descriptor, signature, exceptions); if (getClass() != TryCatchBlockSorter.class) { throw new IllegalStateException(); } }
Example 9
Source File: SerialVersionUIDAdder.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * Constructs a new {@link SerialVersionUIDAdder}. <i>Subclasses must not use this * constructor</i>. Instead, they must use the {@link #SerialVersionUIDAdder(int, ClassVisitor)} * version. * * @param classVisitor a {@link ClassVisitor} to which this visitor will delegate calls. * @throws IllegalStateException If a subclass calls this constructor. */ public SerialVersionUIDAdder(final ClassVisitor classVisitor) { this(Opcodes.ASM7, classVisitor); if (getClass() != SerialVersionUIDAdder.class) { throw new IllegalStateException(); } }
Example 10
Source File: MethodNode.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * Constructs a new {@link MethodNode}. <i>Subclasses must not use this constructor</i>. Instead, * they must use the {@link #MethodNode(int, int, String, String, String, String[])} version. * * @param access the method's access flags (see {@link Opcodes}). This parameter also indicates if * the method is synthetic and/or deprecated. * @param name the method's name. * @param descriptor the method's descriptor (see {@link Type}). * @param signature the method's signature. May be {@literal null}. * @param exceptions the internal names of the method's exception classes (see {@link * Type#getInternalName()}). May be {@literal null}. * @throws IllegalStateException If a subclass calls this constructor. */ public MethodNode( final int access, final String name, final String descriptor, final String signature, final String[] exceptions) { this(Opcodes.ASM7, access, name, descriptor, signature, exceptions); if (getClass() != MethodNode.class) { throw new IllegalStateException(); } }
Example 11
Source File: CheckFieldAdapter.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * Constructs a new {@link CheckFieldAdapter}. <i>Subclasses must not use this constructor</i>. * Instead, they must use the {@link #CheckFieldAdapter(int, FieldVisitor)} version. * * @param fieldVisitor the field visitor to which this adapter must delegate calls. * @throws IllegalStateException If a subclass calls this constructor. */ public CheckFieldAdapter(final FieldVisitor fieldVisitor) { this(Opcodes.ASM7, fieldVisitor); if (getClass() != CheckFieldAdapter.class) { throw new IllegalStateException(); } }
Example 12
Source File: ModuleNode.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * Constructs a {@link ModuleNode}. <i>Subclasses must not use this constructor</i>. Instead, they * must use the {@link #ModuleNode(int,String,int,String,List,List,List,List,List)} version. * * @param name the fully qualified name (using dots) of the module. * @param access the module access flags, among {@code ACC_OPEN}, {@code ACC_SYNTHETIC} and {@code * ACC_MANDATED}. * @param version the module version, or {@literal null}. * @throws IllegalStateException If a subclass calls this constructor. */ public ModuleNode(final String name, final int access, final String version) { super(Opcodes.ASM7); if (getClass() != ModuleNode.class) { throw new IllegalStateException(); } this.name = name; this.access = access; this.version = version; }
Example 13
Source File: FieldNode.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * Constructs a new {@link FieldNode}. <i>Subclasses must not use this constructor</i>. Instead, * they must use the {@link #FieldNode(int, int, String, String, String, Object)} version. * * @param access the field's access flags (see {@link jdk.internal.org.objectweb.asm.Opcodes}). This parameter * also indicates if the field is synthetic and/or deprecated. * @param name the field's name. * @param descriptor the field's descriptor (see {@link jdk.internal.org.objectweb.asm.Type}). * @param signature the field's signature. * @param value the field's initial value. This parameter, which may be {@literal null} if the * field does not have an initial value, must be an {@link Integer}, a {@link Float}, a {@link * Long}, a {@link Double} or a {@link String}. * @throws IllegalStateException If a subclass calls this constructor. */ public FieldNode( final int access, final String name, final String descriptor, final String signature, final Object value) { this(Opcodes.ASM7, access, name, descriptor, signature, value); if (getClass() != FieldNode.class) { throw new IllegalStateException(); } }
Example 14
Source File: InstructionAdapter.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * Constructs a new {@link InstructionAdapter}. <i>Subclasses must not use this constructor</i>. * Instead, they must use the {@link #InstructionAdapter(int, MethodVisitor)} version. * * @param methodVisitor the method visitor to which this adapter delegates calls. * @throws IllegalStateException If a subclass calls this constructor. */ public InstructionAdapter(final MethodVisitor methodVisitor) { this(Opcodes.ASM7, methodVisitor); if (getClass() != InstructionAdapter.class) { throw new IllegalStateException(); } }
Example 15
Source File: GeneratorAdapter.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * Constructs a new {@link GeneratorAdapter}. <i>Subclasses must not use this constructor</i>. * Instead, they must use the {@link #GeneratorAdapter(int, MethodVisitor, int, String, String)} * version. * * @param methodVisitor the method visitor to which this adapter delegates calls. * @param access the method's access flags (see {@link Opcodes}). * @param name the method's name. * @param descriptor the method's descriptor (see {@link Type}). * @throws IllegalStateException if a subclass calls this constructor. */ public GeneratorAdapter( final MethodVisitor methodVisitor, final int access, final String name, final String descriptor) { this(Opcodes.ASM7, methodVisitor, access, name, descriptor); if (getClass() != GeneratorAdapter.class) { throw new IllegalStateException(); } }
Example 16
Source File: AnnotationNode.java From Bytecoder with Apache License 2.0 | 2 votes |
/** * Constructs a new {@link AnnotationNode} to visit an array value. * * @param values where the visited values must be stored. */ AnnotationNode(final List<Object> values) { super(Opcodes.ASM7); this.values = values; }
Example 17
Source File: SignatureRemapper.java From Bytecoder with Apache License 2.0 | 2 votes |
/** * Constructs a new {@link SignatureRemapper}. <i>Subclasses must not use this constructor</i>. * Instead, they must use the {@link #SignatureRemapper(int,SignatureVisitor,Remapper)} version. * * @param signatureVisitor the signature visitor this remapper must deleted to. * @param remapper the remapper to use to remap the types in the visited signature. */ public SignatureRemapper(final SignatureVisitor signatureVisitor, final Remapper remapper) { this(Opcodes.ASM7, signatureVisitor, remapper); }
Example 18
Source File: TraceMethodVisitor.java From Bytecoder with Apache License 2.0 | 2 votes |
/** * Constructs a new {@link TraceMethodVisitor}. * * @param methodVisitor the method visitor to which to delegate calls. May be {@literal null}. * @param printer the printer to convert the visited method into text. */ public TraceMethodVisitor(final MethodVisitor methodVisitor, final Printer printer) { super(Opcodes.ASM7, methodVisitor); this.p = printer; }
Example 19
Source File: StaticInitMerger.java From Bytecoder with Apache License 2.0 | 2 votes |
/** * Constructs a new {@link StaticInitMerger}. <i>Subclasses must not use this constructor</i>. * Instead, they must use the {@link #StaticInitMerger(int, String, ClassVisitor)} version. * * @param prefix the prefix to use to rename the existing <clinit> methods. * @param classVisitor the class visitor to which this visitor must delegate method calls. May be * null. */ public StaticInitMerger(final String prefix, final ClassVisitor classVisitor) { this(Opcodes.ASM7, prefix, classVisitor); }
Example 20
Source File: TraceAnnotationVisitor.java From Bytecoder with Apache License 2.0 | 2 votes |
/** * Constructs a new {@link TraceAnnotationVisitor}. * * @param annotationVisitor the annotation visitor to which to delegate calls. May be {@literal * null}. * @param printer the printer to convert the visited annotation into text. */ public TraceAnnotationVisitor(final AnnotationVisitor annotationVisitor, final Printer printer) { super(Opcodes.ASM7, annotationVisitor); this.printer = printer; }