org.objectweb.asm.Opcodes Java Examples

The following examples show how to use org.objectweb.asm.Opcodes. 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: SerianalyzerMethodVisitor.java    From serianalyzer with GNU General Public License v3.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @see org.objectweb.asm.MethodVisitor#visitFieldInsn(int, java.lang.String, java.lang.String, java.lang.String)
 */
@Override
public void visitFieldInsn ( int opcode, String owner, String name, String desc ) {
    JVMStackState s = this.stack;
    if ( opcode == Opcodes.PUTSTATIC ) {
        Object v = s.pop();

        if ( ! ( v instanceof BaseType ) || ( (BaseType) v ).isTainted() ) {

            // generated static cached, let's assume they are safe
            if ( name.indexOf('$') < 0 && this.ref.getMethod().indexOf('$') < 0 ) {
                this.parent.getAnalyzer().putstatic(this.ref);
            }
        }
    }
    else {
        JVMImpl.handleFieldInsn(opcode, owner, name, desc, s);
    }

    if ( ( opcode == Opcodes.GETSTATIC || opcode == Opcodes.GETFIELD ) && name.indexOf('$') < 0 ) {
        this.parent.getAnalyzer().instantiable(this.ref, Type.getType(desc));
    }

    super.visitFieldInsn(opcode, owner, name, desc);
}
 
Example #2
Source File: AvoidForLoopCounterFilter.java    From pitest with Apache License 2.0 6 votes vote down vote up
private static SequenceQuery<AbstractInsnNode> conditionalAtStart() {
  final Slot<Integer> counterVariable = Slot.create(Integer.class);
  final Slot<LabelNode> loopStart = Slot.create(LabelNode.class);
  final Slot<LabelNode> loopEnd = Slot.create(LabelNode.class);
  return QueryStart
      .any(AbstractInsnNode.class)
     // .then(anIntegerConstant().and(debug("constant"))) // skip this?
      .then(anIStore(counterVariable.write()).and(debug("store")))
      .then(aLabelNode(loopStart.write()).and(debug("label")))
      .then(anILoadOf(counterVariable.read()).and(debug("load")))
      .zeroOrMore(QueryStart.match(opCode(Opcodes.ALOAD))) // optionally put object on stack
      .then(loadsAnIntegerToCompareTo().and(debug("push")))
      .then(jumpsTo(loopEnd.write()).and(aConditionalJump()))
      .then(isA(LabelNode.class))
      .zeroOrMore(anything())
      .then(targetInstruction(counterVariable).and(debug("target")))
      .then(jumpsTo(loopStart.read()).and(debug("jump")))
      .then(labelNode(loopEnd.read()))
      .zeroOrMore(anything());
}
 
Example #3
Source File: AsmDeltaSpikeProxyClassGenerator.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
private static void defineDeltaSpikeProxyFields(ClassWriter cw)
{
    // generates
    // private DeltaSpikeProxyInvocationHandler invocationHandler;
    cw.visitField(Opcodes.ACC_PRIVATE, FIELDNAME_INVOCATION_HANDLER,
            TYPE_DELTA_SPIKE_PROXY_INVOCATION_HANDLER.getDescriptor(), null, null).visitEnd();
    
    // generates
    // private MyInvocationHandler delegateInvocationHandler;
    cw.visitField(Opcodes.ACC_PRIVATE, FIELDNAME_DELEGATE_INVOCATION_HANDLER,
            TYPE_INVOCATION_HANDLER.getDescriptor(), null, null).visitEnd();
    
    // generates
    // private Method[] delegateMethods;
    cw.visitField(Opcodes.ACC_PRIVATE, FIELDNAME_DELEGATE_METHODS,
            TYPE_METHOD_ARRAY.getDescriptor(), null, null).visitEnd();
}
 
Example #4
Source File: ClassPatcher.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void visitEnd() {
  if(bNeedBIDField) {
    // Add a static field containing the bundle id to the processed class.
    // This files is used by the wrapper methods to find the bundle owning
    // the class.
    // The field has the magic/long name defined by FIELD_BID
    // hopefully no-one else uses this
    super.visitField(Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL | Opcodes.ACC_STATIC,
                     FIELD_BID,
                     "J",
                     null,
                     new Long(bid));
  }

  super.visitEnd();

  if(Activator.debugEnabled()) {
    cp.dumpInfo();
  }
}
 
Example #5
Source File: ClassOptimizer.java    From JByteMod-Beta with GNU General Public License v2.0 6 votes vote down vote up
@Override
public FieldVisitor visitField(final int access, final String name, final String desc, final String signature, final Object value) {
  String s = remapper.mapFieldName(className, name, desc);
  if ("-".equals(s)) {
    return null;
  }
  if ((access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED)) == 0) {
    if ((access & Opcodes.ACC_FINAL) != 0 && (access & Opcodes.ACC_STATIC) != 0 && desc.length() == 1) {
    }
    super.visitField(access, name, desc, null, value);
  } else {
    if (!s.equals(name)) {
      throw new RuntimeException("The public or protected field " + className + '.' + name + " must not be renamed.");
    }
    super.visitField(access, name, desc, null, value);
  }
  return null; // remove debug info
}
 
Example #6
Source File: ValueHolderIden.java    From Bats with Apache License 2.0 5 votes vote down vote up
public void transfer(InstructionModifier mv, int newStart) {
  // if the new location is the same as the current position, there's nothing to do
  if (first == newStart) {
    return;
  }

  for (int i = 0; i < types.length; i++) {
    mv.directVarInsn(types[i].getOpcode(Opcodes.ILOAD), first + offsets[i]);
    mv.directVarInsn(types[i].getOpcode(Opcodes.ISTORE), newStart + offsets[i]);
  }

  this.first = newStart;
}
 
Example #7
Source File: AnalyzerAdapter.java    From JReFrameworker with MIT License 5 votes vote down vote up
@Override
public void visitLookupSwitchInsn(final Label dflt, final int[] keys, final Label[] labels) {
  super.visitLookupSwitchInsn(dflt, keys, labels);
  execute(Opcodes.LOOKUPSWITCH, 0, null);
  this.locals = null;
  this.stack = null;
}
 
Example #8
Source File: TestClassVisitor.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected TestClassVisitor(TestFrameworkDetector detector) {
    super(Opcodes.ASM4);
    if (detector == null) {
        throw new IllegalArgumentException("detector == null!");
    }
    this.detector = detector;
}
 
Example #9
Source File: HashCodeMethod.java    From byte-buddy with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Size apply(MethodVisitor methodVisitor, Context implementationContext) {
    methodVisitor.visitVarInsn(Opcodes.ASTORE, instrumentedMethod.getStackSize());
    methodVisitor.visitVarInsn(Opcodes.ALOAD, instrumentedMethod.getStackSize());
    methodVisitor.visitJumpInsn(Opcodes.IFNULL, label);
    methodVisitor.visitVarInsn(Opcodes.ALOAD, instrumentedMethod.getStackSize());
    return new Size(0, 0);
}
 
Example #10
Source File: InlineConstantMutator.java    From pitest with Apache License 2.0 5 votes vote down vote up
private void translateToByteCode(final Double constant) {
  if (constant == 0D) {
    super.visitInsn(Opcodes.DCONST_0);
  } else if (constant == 1D) {
    super.visitInsn(Opcodes.DCONST_1);
  } else {
    super.visitLdcInsn(constant);
  }
}
 
Example #11
Source File: InstructionAdapter.java    From JReFrameworker with MIT License 5 votes vote down vote up
/**
 * Deprecated.
 *
 * @param owner the internal name of the method's owner class.
 * @param name the method's name.
 * @param descriptor the method's descriptor (see {@link Type}).
 * @deprecated use {@link #invokespecial(String, String, String, boolean)} instead.
 */
@Deprecated
public void invokespecial(final String owner, final String name, final String descriptor) {
  if (api >= Opcodes.ASM5) {
    invokespecial(owner, name, descriptor, false);
    return;
  }
  mv.visitMethodInsn(Opcodes.INVOKESPECIAL, owner, name, descriptor, false);
}
 
Example #12
Source File: NodeUtils.java    From obfuscator with MIT License 5 votes vote down vote up
public static AbstractInsnNode getWrapperMethod(Type type) {
    if (type.getSort() != Type.VOID && TYPE_TO_WRAPPER.containsKey(type)) {
        return new MethodInsnNode(Opcodes.INVOKESTATIC, TYPE_TO_WRAPPER.get(type), "valueOf", "(" + type.toString() + ")L" + TYPE_TO_WRAPPER.get(type) + ";", false);
    }

    return new InsnNode(Opcodes.NOP);
}
 
Example #13
Source File: TraceMethodVisitor.java    From JReFrameworker with MIT License 5 votes vote down vote up
/**
 * Deprecated.
 *
 * @deprecated use {@link #visitMethodInsn(int, String, String, String, boolean)} instead.
 */
@Deprecated
@Override
public void visitMethodInsn(
    final int opcode, final String owner, final String name, final String descriptor) {
  if (api >= Opcodes.ASM5) {
    super.visitMethodInsn(opcode, owner, name, descriptor);
    return;
  }
  p.visitMethodInsn(opcode, owner, name, descriptor);
  if (mv != null) {
    mv.visitMethodInsn(opcode, owner, name, descriptor);
  }
}
 
Example #14
Source File: ItemTransformer.java    From SkyblockAddons with MIT License 5 votes vote down vote up
private InsnList insertDurabilityHook() {
    InsnList list = new InsnList();

    list.add(new TypeInsnNode(Opcodes.NEW, "codes/biscuit/skyblockaddons/asm/utils/ReturnValue"));
    list.add(new InsnNode(Opcodes.DUP)); // ReturnValue returnValue = new ReturnValue();
    list.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, "codes/biscuit/skyblockaddons/asm/utils/ReturnValue", "<init>", "()V", false));
    list.add(new VarInsnNode(Opcodes.ASTORE, 2));

    list.add(new VarInsnNode(Opcodes.ALOAD, 1)); // stack
    list.add(new VarInsnNode(Opcodes.ALOAD, 2)); // ItemHook.getDurabilityForDisplay(stack, returnValue);
    list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "codes/biscuit/skyblockaddons/asm/hooks/ItemHook", "getDurabilityForDisplay",
            "("+TransformerClass.ItemStack.getName()+"Lcodes/biscuit/skyblockaddons/asm/utils/ReturnValue;)V", false));

    list.add(new VarInsnNode(Opcodes.ALOAD, 2));
    list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "codes/biscuit/skyblockaddons/asm/utils/ReturnValue", "isCancelled",
            "()Z", false));
    LabelNode notCancelled = new LabelNode(); // if (returnValue.isCancelled())
    list.add(new JumpInsnNode(Opcodes.IFEQ, notCancelled));

    list.add(new VarInsnNode(Opcodes.ALOAD, 2));
    list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "codes/biscuit/skyblockaddons/asm/utils/ReturnValue", "getReturnValue",
            "()Ljava/lang/Object;", false));
    list.add(new TypeInsnNode(Opcodes.CHECKCAST, "java/lang/Double"));
    list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/lang/Double", "doubleValue",
            "()D", false));
    list.add(new InsnNode(Opcodes.DRETURN)); // return returnValue.getValue();
    list.add(notCancelled);

    return list;
}
 
Example #15
Source File: CodeEmitter.java    From yql-plus with Apache License 2.0 5 votes vote down vote up
public void dup(TypeWidget typeWidget) {
    switch (typeWidget.getJVMType().getSize()) {
        case 0:
            throw new UnsupportedOperationException();
        case 1:
            getMethodVisitor().visitInsn(Opcodes.DUP);
            return;
        case 2:
            getMethodVisitor().visitInsn(Opcodes.DUP2);
            return;
        default:
            throw new UnsupportedOperationException("Unexpected JVM type width: " + typeWidget.getJVMType());
    }
}
 
Example #16
Source File: MethodRebaseResolver.java    From byte-buddy with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public int getModifiers() {
    return Opcodes.ACC_SYNTHETIC
            | (methodDescription.isStatic() ? Opcodes.ACC_STATIC : EMPTY_MASK)
            | (methodDescription.isNative() ? Opcodes.ACC_NATIVE : EMPTY_MASK)
            | (instrumentedType.isInterface() ? Opcodes.ACC_PUBLIC : Opcodes.ACC_PRIVATE);
}
 
Example #17
Source File: Target.java    From Mixin with MIT License 5 votes vote down vote up
/**
 * Find the first <tt>&lt;init&gt;</tt> invocation after the specified
 * <tt>NEW</tt> insn 
 * 
 * @param newNode NEW insn
 * @return INVOKESPECIAL opcode of ctor, or null if not found
 */
public MethodInsnNode findInitNodeFor(TypeInsnNode newNode) {
    int start = this.indexOf(newNode);
    for (Iterator<AbstractInsnNode> iter = this.insns.iterator(start); iter.hasNext();) {
        AbstractInsnNode insn = iter.next();
        if (insn instanceof MethodInsnNode && insn.getOpcode() == Opcodes.INVOKESPECIAL) {
            MethodInsnNode methodNode = (MethodInsnNode)insn;
            if (Constants.CTOR.equals(methodNode.name) && methodNode.owner.equals(newNode.desc)) {
                return methodNode;
            }
        }
    }
    return null;
}
 
Example #18
Source File: MixinPostProcessor.java    From Mixin with MIT License 5 votes vote down vote up
private boolean processAccessor(ClassNode classNode, MixinInfo mixin) {
    if (!MixinEnvironment.getCompatibilityLevel().supports(LanguageFeature.METHODS_IN_INTERFACES)) {
        return false;
    }
    
    boolean transformed = false;
    MixinClassNode mixinClassNode = mixin.getClassNode(0);
    ClassInfo targetClass = mixin.getTargets().get(0);
    
    for (MixinMethodNode methodNode : mixinClassNode.mixinMethods) {
        if (!Bytecode.hasFlag(methodNode, Opcodes.ACC_STATIC)) {
            continue;
        }
        
        AnnotationNode accessor = methodNode.getVisibleAnnotation(Accessor.class);
        AnnotationNode invoker = methodNode.getVisibleAnnotation(Invoker.class);
        if (accessor != null || invoker != null) {
            Method method = this.getAccessorMethod(mixin, methodNode, targetClass);
            MixinPostProcessor.createProxy(methodNode, targetClass, method);
            Annotations.setVisible(methodNode, MixinProxy.class, "sessionId", this.sessionId);
            classNode.methods.add(methodNode);
            transformed = true;
        }
    }
    
    if (!transformed) {
        return false;
    }
    
    Bytecode.replace(mixinClassNode, classNode);
    return true;
}
 
Example #19
Source File: TestClassVisitor.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected TestClassVisitor(TestFrameworkDetector detector) {
    super(Opcodes.ASM4);
    if (detector == null) {
        throw new IllegalArgumentException("detector == null!");
    }
    this.detector = detector;
}
 
Example #20
Source File: ScopeExtractorMethodVisitor.java    From scott with MIT License 5 votes vote down vote up
@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
	super.visitFieldInsn(opcode, owner, name, desc);

	final boolean isStatic = Opcodes.GETSTATIC == opcode || Opcodes.PUTSTATIC == opcode;

	if (name.startsWith("this$")) {
		return;
	}

	accessedFields.add(new AccessedField(owner, name, desc, isStatic));
}
 
Example #21
Source File: SourceVersionUtils.java    From buck with Apache License 2.0 5 votes vote down vote up
/** Gets the class file version corresponding to the given source version constant. */
public static int sourceVersionToClassFileVersion(SourceVersion version) {
  switch (version) {
    case RELEASE_0:
      return Opcodes.V1_1; // JVMS8 4.1: 1.0 and 1.1 both support version 45.3 (Opcodes.V1_1)
    case RELEASE_1:
      return Opcodes.V1_1;
    case RELEASE_2:
      return Opcodes.V1_2;
    case RELEASE_3:
      return Opcodes.V1_3;
    case RELEASE_4:
      return Opcodes.V1_4;
    case RELEASE_5:
      return Opcodes.V1_5;
    case RELEASE_6:
      return Opcodes.V1_6;
    case RELEASE_7:
      return Opcodes.V1_7;
    case RELEASE_8:
      return Opcodes.V1_8;
    case RELEASE_9:
      return Opcodes.V9;
    case RELEASE_10:
      return Opcodes.V10;
    case RELEASE_11:
      return Opcodes.V11;
    default:
      throw new IllegalArgumentException(String.format("Unexpected source version: %s", version));
  }
}
 
Example #22
Source File: SerialVersionUIDAdder.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
@Override
public FieldVisitor visitField(
    final int access,
    final String name,
    final String desc,
    final String signature,
    final Object value) {
  // Get the class field information for step 4 of the algorithm. Also determine if the class
  // already has a SVUID.
  if (computeSVUID) {
    if ("serialVersionUID".equals(name)) {
      // Since the class already has SVUID, we won't be computing it.
      computeSVUID = false;
      hasSVUID = true;
    }
    // Collect the non private fields. Only the ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED,
    // ACC_STATIC, ACC_FINAL, ACC_VOLATILE, and ACC_TRANSIENT flags are used when computing
    // serialVersionUID values.
    if ((access & Opcodes.ACC_PRIVATE) == 0
        || (access & (Opcodes.ACC_STATIC | Opcodes.ACC_TRANSIENT)) == 0) {
      int mods =
          access
              & (Opcodes.ACC_PUBLIC
                  | Opcodes.ACC_PRIVATE
                  | Opcodes.ACC_PROTECTED
                  | Opcodes.ACC_STATIC
                  | Opcodes.ACC_FINAL
                  | Opcodes.ACC_VOLATILE
                  | Opcodes.ACC_TRANSIENT);
      svuidFields.add(new Item(name, mods, desc));
    }
  }

  return super.visitField(access, name, desc, signature, value);
}
 
Example #23
Source File: TraceMethodVisitor.java    From JReFrameworker with MIT License 5 votes vote down vote up
/**
 * Deprecated.
 *
 * @deprecated use {@link #visitMethodInsn(int, String, String, String, boolean)} instead.
 */
@Deprecated
@Override
public void visitMethodInsn(
    final int opcode, final String owner, final String name, final String descriptor) {
  if (api >= Opcodes.ASM5) {
    super.visitMethodInsn(opcode, owner, name, descriptor);
    return;
  }
  p.visitMethodInsn(opcode, owner, name, descriptor);
  if (mv != null) {
    mv.visitMethodInsn(opcode, owner, name, descriptor);
  }
}
 
Example #24
Source File: RemappingMethodAdapter.java    From JReFrameworker with MIT License 5 votes vote down vote up
@Override
public void visitMethodInsn(
    final int opcode,
    final String owner,
    final String name,
    final String descriptor,
    final boolean isInterface) {
  if (api < Opcodes.ASM5) {
    super.visitMethodInsn(opcode, owner, name, descriptor, isInterface);
    return;
  }
  doVisitMethodInsn(opcode, owner, name, descriptor, isInterface);
}
 
Example #25
Source File: CheckModuleAdapter.java    From JReFrameworker with MIT License 5 votes vote down vote up
@Override
public void visitUse(final String service) {
  checkVisitEndNotCalled();
  CheckMethodAdapter.checkInternalName(Opcodes.V9, service, "service");
  usedServices.checkNameNotAlreadyDeclared(service);
  super.visitUse(service);
}
 
Example #26
Source File: ModifierContributorResolverTest.java    From byte-buddy with Apache License 2.0 5 votes vote down vote up
@Test
public void testForMethod() throws Exception {
    assertThat(ModifierContributor.Resolver.of(Visibility.PUBLIC, MethodManifestation.FINAL).resolve(),
            is(Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL));
    assertThat(ModifierContributor.Resolver.of(Visibility.PUBLIC, MethodManifestation.ABSTRACT, MethodManifestation.FINAL).resolve(),
            is(Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL));
    assertThat(ModifierContributor.Resolver.of(Visibility.PUBLIC, MethodManifestation.FINAL).resolve(1),
            is(Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL | 1));
}
 
Example #27
Source File: ASMifier.java    From JReFrameworker with MIT License 5 votes vote down vote up
@Override
public void visitMethodInsn(
    final int opcode,
    final String owner,
    final String name,
    final String descriptor,
    final boolean isInterface) {
  if (api < Opcodes.ASM5) {
    super.visitMethodInsn(opcode, owner, name, descriptor, isInterface);
    return;
  }
  doVisitMethodInsn(opcode, owner, name, descriptor, isInterface);
}
 
Example #28
Source File: Concurnifier.java    From Concurnas with MIT License 5 votes vote down vote up
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
   	/*if(access == ACC_PUBLIC && name.equals("<init>") && desc.equals("(Lcom/concurnas/bootstrap/runtime/CopyTracker;" + theCurrentclass +")V") && signature == null && exceptions == null){
   		hasCopyConstructorAlready=true;
   	}*/
   	
   	if((access & ACC_PRIVATE) == ACC_PRIVATE && (access & Opcodes.ACC_SYNTHETIC) == Opcodes.ACC_SYNTHETIC && name.equals("defaultFieldInit$") && desc.equals("(Lcom/concurnas/bootstrap/runtime/InitUncreatable;[Z)V") && signature == null && exceptions == null){
   		hasDefaultFieldInit=true;
   	}
   	
	return super.visitMethod(access, name, desc, signature, exceptions);
}
 
Example #29
Source File: InstructionAdapter.java    From JReFrameworker with MIT License 5 votes vote down vote up
/**
 * Generates the instruction to create and push on the stack an array of the given type.
 *
 * @param type an array Type.
 */
public void newarray(final Type type) {
  int arrayType;
  switch (type.getSort()) {
    case Type.BOOLEAN:
      arrayType = Opcodes.T_BOOLEAN;
      break;
    case Type.CHAR:
      arrayType = Opcodes.T_CHAR;
      break;
    case Type.BYTE:
      arrayType = Opcodes.T_BYTE;
      break;
    case Type.SHORT:
      arrayType = Opcodes.T_SHORT;
      break;
    case Type.INT:
      arrayType = Opcodes.T_INT;
      break;
    case Type.FLOAT:
      arrayType = Opcodes.T_FLOAT;
      break;
    case Type.LONG:
      arrayType = Opcodes.T_LONG;
      break;
    case Type.DOUBLE:
      arrayType = Opcodes.T_DOUBLE;
      break;
    default:
      mv.visitTypeInsn(Opcodes.ANEWARRAY, type.getInternalName());
      return;
  }
  mv.visitIntInsn(Opcodes.NEWARRAY, arrayType);
}
 
Example #30
Source File: CheckMethodAdapter.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
private void doVisitMethodInsn(int opcode, final String owner, final String name, final String desc, final boolean itf) {
  checkStartCode();
  checkEndCode();
  checkOpcode(opcode, 5);
  if (opcode != Opcodes.INVOKESPECIAL || !"<init>".equals(name)) {
    checkMethodIdentifier(version, name, "name");
  }
  checkInternalName(owner, "owner");
  checkMethodDesc(desc);
  if (opcode == Opcodes.INVOKEVIRTUAL && itf) {
    throw new IllegalArgumentException("INVOKEVIRTUAL can't be used with interfaces");
  }
  if (opcode == Opcodes.INVOKEINTERFACE && !itf) {
    throw new IllegalArgumentException("INVOKEINTERFACE can't be used with classes");
  }
  if (opcode == Opcodes.INVOKESPECIAL && itf && (version & 0xFFFF) < Opcodes.V1_8) {
    throw new IllegalArgumentException("INVOKESPECIAL can't be used with interfaces prior to Java 8");
  }

  // Calling super.visitMethodInsn requires to call the correct version
  // depending on this.api (otherwise infinite loops can occur). To
  // simplify and to make it easier to automatically remove the backward
  // compatibility code, we inline the code of the overridden method here.
  if (mv != null) {
    mv.visitMethodInsn(opcode, owner, name, desc, itf);
  }
  ++insnCount;
}