Java Code Examples for org.objectweb.asm.Opcodes#ASM6

The following examples show how to use org.objectweb.asm.Opcodes#ASM6 . 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: ArraysRequiringAnalysisMethodNode.java    From AVM with MIT License 5 votes vote down vote up
public ArraysRequiringAnalysisMethodNode(final int access,
                                     final String name,
                                     final String descriptor,
                                     final String signature,
                                     final String[] exceptions,
                                     MethodVisitor mv,
                                     String className,
                                     ClassHierarchy hierarchy)
{
    super(Opcodes.ASM6, access, name, descriptor, signature, exceptions);
    this.className = className;
    this.mv = mv;
    this.hierarchy = hierarchy;
}
 
Example 2
Source File: MethodBranchAdapter.java    From javan-warty-pig with MIT License 5 votes vote down vote up
/**
 * Create this adapter with a set of {@link MethodRefs}, the internal class name for the method, values given from
 * {@link org.objectweb.asm.ClassVisitor#visitMethod(int, String, String, String, String[])}, and a
 * {@link MethodVisitor} to delegate to.
 */
public MethodBranchAdapter(MethodRefs refs, String className, int access, String name,
    String desc, String signature, String[] exceptions, MethodVisitor mv) {
  super(Opcodes.ASM6, access, name, desc, signature, exceptions);
  this.refs = refs;
  this.className = className;
  this.mv = mv;
}
 
Example 3
Source File: TypesOf.java    From jpeek with MIT License 5 votes vote down vote up
/**
 * Ctor.
 * @param sign Method signature
 */
TypesOf(final String sign) {
    super(Opcodes.ASM6);
    this.types = new LinkedList<>();
    this.singature = sign;
    this.rtype = new AtomicReference<>();
    this.ret = new AtomicBoolean();
}
 
Example 4
Source File: ClassMetering.java    From AVM with MIT License 5 votes vote down vote up
public MethodVisitor visitMethod(
        final int access,
        final String name,
        final String descriptor,
        final String signature,
        final String[] exceptions) {
    // Capture the visitor which actually constitutes the pipeline - we will need to do another pass before this one.
    MethodVisitor realVisitor = super.visitMethod(access, name, descriptor, signature, exceptions);
    
    // We use a MethodNode since we want to capture the bytecode to walk it twice.
    // The actual final write is done on the realVisitor.
    return new MethodNode(Opcodes.ASM6, access, name, descriptor, signature, exceptions) {
        @Override
        public void visitEnd() {
            // Let the superclass do what it wants to finish this.
            super.visitEnd();

            // Create the read-only visitor and use it to extract the block data.
            BlockBuildingMethodVisitor readingVisitor = new BlockBuildingMethodVisitor();
            this.accept(readingVisitor);
            List<BasicBlock> blocks = readingVisitor.getBlockList();

            // Apply the block fee for the bytecodes it contains.
            for (BasicBlock block : blocks) {
                long feeForBlock = calculateBlockFee(block);
                block.setEnergyCost(feeForBlock);
            }

            // We can now build the injection visitor over the real visitor, and accept it in order to add the instrumentation.
            ChargeEnergyInjectionVisitor instrumentingVisitor = new ChargeEnergyInjectionVisitor(realVisitor, blocks);
            this.accept(instrumentingVisitor);
        }
    };
}
 
Example 5
Source File: TryCatchBlockSorter.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
public TryCatchBlockSorter(
    final MethodVisitor methodVisitor,
    final int access,
    final String name,
    final String descriptor,
    final String signature,
    final String[] exceptions) {
  this(Opcodes.ASM6, methodVisitor, access, name, descriptor, signature, exceptions);
  if (getClass() != TryCatchBlockSorter.class) {
    throw new IllegalStateException();
  }
}
 
Example 6
Source File: SignatureVisitor.java    From JReFrameworker with MIT License 5 votes vote down vote up
/**
 * 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 7
Source File: AutomaticGraphVisitor.java    From AVM with MIT License 4 votes vote down vote up
public AutomaticGraphVisitor() {
    super(Opcodes.ASM6);
}
 
Example 8
Source File: CheckAnnotationAdapter.java    From JByteMod-Beta with GNU General Public License v2.0 4 votes vote down vote up
CheckAnnotationAdapter(final AnnotationVisitor av, final boolean named) {
  super(Opcodes.ASM6, av);
  this.named = named;
}
 
Example 9
Source File: UserClassMappingVisitor.java    From AVM with MIT License 4 votes vote down vote up
public UserClassMappingVisitor(NamespaceMapper mapper, boolean preserveDebuggability) {
    super(Opcodes.ASM6);
    
    this.mapper = mapper;
    this.preserveDebuggability = preserveDebuggability;
}
 
Example 10
Source File: ArraysRequiringAnalysisClassVisitor.java    From AVM with MIT License 4 votes vote down vote up
public ArraysRequiringAnalysisClassVisitor(ClassHierarchy hierarchy) {
    super(Opcodes.ASM6);
    this.hierarchy = hierarchy;
}
 
Example 11
Source File: EmptyClassVisitor.java    From jarjar with Apache License 2.0 4 votes vote down vote up
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
  return new AnnotationVisitor(Opcodes.ASM6) {};
}
 
Example 12
Source File: RejectionClassVisitor.java    From AVM with MIT License 4 votes vote down vote up
public RejectionClassVisitor(PreRenameClassAccessRules preRenameClassAccessRules, NamespaceMapper namespaceMapper, boolean preserveDebuggability) {
    super(Opcodes.ASM6);
    this.preRenameClassAccessRules = preRenameClassAccessRules;
    this.namespaceMapper = namespaceMapper;
    this.preserveDebuggability = preserveDebuggability;
}
 
Example 13
Source File: ArrayWrappingInterpreter.java    From AVM with MIT License 4 votes vote down vote up
ArrayWrappingInterpreter(ClassHierarchy hierarchy) {
  super(Opcodes.ASM6);
  this.hierarchy = hierarchy;
}
 
Example 14
Source File: TypeAnnotationNode.java    From JByteMod-Beta with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs a new {@link AnnotationNode}. <i>Subclasses must not use this
 * constructor</i>. Instead, they must use the
 * {@link #TypeAnnotationNode(int, int, TypePath, String)} version.
 * 
 * @param typeRef
 *          a reference to the annotated type. See {@link TypeReference}.
 * @param typePath
 *          the path to the annotated type argument, wildcard bound, array
 *          element type, or static inner type within 'typeRef'. May be
 *          <tt>null</tt> if the annotation targets 'typeRef' as a whole.
 * @param desc
 *          the class descriptor of the annotation class.
 * @throws IllegalStateException
 *           If a subclass calls this constructor.
 */
public TypeAnnotationNode(final int typeRef, final TypePath typePath, final String desc) {
  this(Opcodes.ASM6, typeRef, typePath, desc);
  if (getClass() != TypeAnnotationNode.class) {
    throw new IllegalStateException();
  }
}
 
Example 15
Source File: MethodNode.java    From JByteMod-Beta with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs an uninitialized {@link MethodNode}. <i>Subclasses must not use
 * this constructor</i>. Instead, they must use the {@link #MethodNode(int)}
 * version.
 * 
 * @throws IllegalStateException
 *           If a subclass calls this constructor.
 */
public MethodNode() {
  this(Opcodes.ASM6);
  if (getClass() != MethodNode.class) {
    throw new IllegalStateException();
  }
}
 
Example 16
Source File: AnalyzerAdapter.java    From JByteMod-Beta with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs a new {@link AnalyzerAdapter}. <i>Subclasses must not use this constructor</i>.
 * Instead, they must use the {@link #AnalyzerAdapter(int, String, int, String, String,
 * MethodVisitor)} version.
 *
 * @param owner the owner's class name.
 * @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}).
 * @param methodVisitor the method visitor to which this adapter delegates calls. May be
 *     <tt>null</tt>.
 * @throws IllegalStateException If a subclass calls this constructor.
 */
public AnalyzerAdapter(
    final String owner,
    final int access,
    final String name,
    final String descriptor,
    final MethodVisitor methodVisitor) {
  this(Opcodes.ASM6, owner, access, name, descriptor, methodVisitor);
  if (getClass() != AnalyzerAdapter.class) {
    throw new IllegalStateException();
  }
}
 
Example 17
Source File: ClassNode.java    From JByteMod-Beta with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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.ASM6);
  if (getClass() != ClassNode.class) {
    throw new IllegalStateException();
  }
}
 
Example 18
Source File: CheckFieldAdapter.java    From JByteMod-Beta with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs a new {@link CheckFieldAdapter}. <i>Subclasses must not use this
 * constructor</i>. Instead, they must use the
 * {@link #CheckFieldAdapter(int, FieldVisitor)} version.
 * 
 * @param fv
 *          the field visitor to which this adapter must delegate calls.
 * @throws IllegalStateException
 *           If a subclass calls this constructor.
 */
public CheckFieldAdapter(final FieldVisitor fv) {
  this(Opcodes.ASM6, fv);
  if (getClass() != CheckFieldAdapter.class) {
    throw new IllegalStateException();
  }
}
 
Example 19
Source File: LocalVariableAnnotationNode.java    From JByteMod-Beta with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Constructs a new {@link LocalVariableAnnotationNode}. <i>Subclasses must
 * not use this constructor</i>. Instead, they must use the
 * {@link #LocalVariableAnnotationNode(int, TypePath, LabelNode[], LabelNode[], int[], String)}
 * version.
 * 
 * @param typeRef
 *          a reference to the annotated type. See {@link TypeReference}.
 * @param typePath
 *          the path to the annotated type argument, wildcard bound, array
 *          element type, or static inner type within 'typeRef'. May be
 *          <tt>null</tt> if the annotation targets 'typeRef' as a whole.
 * @param start
 *          the fist instructions corresponding to the continuous ranges that
 *          make the scope of this local variable (inclusive).
 * @param end
 *          the last instructions corresponding to the continuous ranges that
 *          make the scope of this local variable (exclusive). This array must
 *          have the same size as the 'start' array.
 * @param index
 *          the local variable's index in each range. This array must have the
 *          same size as the 'start' array.
 * @param desc
 *          the class descriptor of the annotation class.
 */
public LocalVariableAnnotationNode(int typeRef, TypePath typePath, LabelNode[] start, LabelNode[] end, int[] index, String desc) {
  this(Opcodes.ASM6, typeRef, typePath, start, end, index, desc);
}
 
Example 20
Source File: ClassInfoVisitor.java    From AVM with MIT License 2 votes vote down vote up
/**
 * Constructs a new class visitor.
 *
 * If {@code isRenamed == true} then we interpret all classes we visit as post-rename classes.
 * Otherwise, we consider them pre-rename classes.
 *
 * Note that this visitor does not perform any renaming at all. It simply creates pre- or post-
 * rename class info objects accordingly.
 */
public ClassInfoVisitor(boolean isRenamed) {
    super(Opcodes.ASM6);
    this.isRenamed = isRenamed;
}