下面列出了org.objectweb.asm.Opcodes# ASM6 ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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;
}
/**
* 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();
}
/**
* 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;
}
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();
}
}
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);
}
};
}
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;
}
ArrayWrappingInterpreter(ClassHierarchy hierarchy) {
super(Opcodes.ASM6);
this.hierarchy = hierarchy;
}
public RejectionClassVisitor(PreRenameClassAccessRules preRenameClassAccessRules, NamespaceMapper namespaceMapper, boolean preserveDebuggability) {
super(Opcodes.ASM6);
this.preRenameClassAccessRules = preRenameClassAccessRules;
this.namespaceMapper = namespaceMapper;
this.preserveDebuggability = preserveDebuggability;
}
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
return new AnnotationVisitor(Opcodes.ASM6) {};
}
public ArraysRequiringAnalysisClassVisitor(ClassHierarchy hierarchy) {
super(Opcodes.ASM6);
this.hierarchy = hierarchy;
}
public UserClassMappingVisitor(NamespaceMapper mapper, boolean preserveDebuggability) {
super(Opcodes.ASM6);
this.mapper = mapper;
this.preserveDebuggability = preserveDebuggability;
}
CheckAnnotationAdapter(final AnnotationVisitor av, final boolean named) {
super(Opcodes.ASM6, av);
this.named = named;
}
public AutomaticGraphVisitor() {
super(Opcodes.ASM6);
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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;
}
/**
* 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);
}