Program: 153639
Project: 153639
Buggy source:
/** 
 * Wraps a method.
 * @param m The method to wrap.
 * @return The gerated method name.
 */
public String wrap(final Method m,final WeelFunction func){
  final String mname=m.getName() + "String_Node_Str";
  final JvmMethodWriter mw=this.classWriter.createMethod(mname,"String_Node_Str");
  final ByteList bl=mw.code;
  for (int i=0; i < m.getParameterTypes().length; i++) {
    if (m.getParameterTypes()[i] == com.github.rjeschke.weel.Runtime.class)     func.arguments--;
  }
  mw.maxStack=3;
  bl.add(JvmOp.ALOAD_0);
  mw.ldcInt(func.arguments);
  mw.ldcInt(0);
  bl.add(JvmOp.INVOKEVIRTUAL);
  bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
  int sp=m.getParameterTypes().length > 0 ? 2 : 0;
  final boolean returns;
  if (m.getReturnType() != void.class) {
    returns=true;
    bl.add(JvmOp.ALOAD_0);
    sp++;
  }
 else {
    returns=false;
  }
  for (int i=0, p=0; i < m.getParameterTypes().length; i++) {
    final Class<?> t=m.getParameterTypes()[i];
    if (t == com.github.rjeschke.weel.Runtime.class) {
      sp++;
      bl.add(JvmOp.ALOAD_0);
      continue;
    }
    bl.add(JvmOp.ALOAD_0);
    mw.ldcInt(p++);
    bl.add(JvmOp.INVOKEVIRTUAL);
    if (t == double.class) {
      sp+=2;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if (t == int.class) {
      sp+=2;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
      bl.add(JvmOp.D2I);
    }
 else     if (t == String.class) {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if (t == WeelFunction.class) {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if (t == Value.class) {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if (t == ValueMap.class) {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
      if (t != Object.class) {
        bl.add(JvmOp.CHECKCAST);
        bl.addShort(this.classWriter.addConstant(new JvmConstant(JvmConstant.CONSTANT_Class,this.classWriter.addConstant(new JvmConstant(t.getCanonicalName().replace('.','/'))))));
      }
    }
  }
  mw.maxStack=Math.max(mw.maxStack,sp);
  bl.add(JvmOp.INVOKESTATIC);
  bl.addShort(this.classWriter.addMethodRefConstant(m.getDeclaringClass().getCanonicalName(),m.getName(),"String_Node_Str" + JvmClassWriter.buildDescriptor(m.getParameterTypes()) + "String_Node_Str"+ JvmClassWriter.buildDescriptor(m.getReturnType())));
  if (returns) {
    sp=1;
    final Class<?> t=m.getReturnType();
    bl.add(JvmOp.INVOKEVIRTUAL);
    if (t == double.class) {
      sp+=2;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if (t == int.class) {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if (t == String.class) {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if (t == ValueMap.class) {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if (t == Value.class) {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if (t == WeelFunction.class) {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
    mw.maxStack=Math.max(mw.maxStack,sp);
    bl.add(JvmOp.ALOAD_0);
    mw.ldcInt(1);
    bl.add(JvmOp.INVOKEVIRTUAL);
    bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
  }
 else {
    bl.add(JvmOp.ALOAD_0);
    mw.ldcInt(0);
    bl.add(JvmOp.INVOKEVIRTUAL);
    bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
  }
  bl.add(JvmOp.RETURN);
  return mname;
}

Fixed version (ground truth):
/** 
 * Wraps a method.
 * @param m The method to wrap.
 * @return The gerated method name.
 */
public String wrap(final Method m,final WeelFunction func){
  for (int i=0; i < m.getParameterTypes().length; i++) {
    if (m.getParameterTypes()[i] == com.github.rjeschke.weel.Runtime.class)     func.arguments--;
  }
  final String mname="String_Node_Str" + m.getName() + "String_Node_Str"+ func.arguments;
  final JvmMethodWriter mw=this.classWriter.createMethod(mname,"String_Node_Str");
  final ByteList bl=mw.code;
  mw.maxStack=3;
  bl.add(JvmOp.ALOAD_0);
  mw.ldcInt(func.arguments);
  mw.ldcInt(0);
  bl.add(JvmOp.INVOKEVIRTUAL);
  bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
  int sp=m.getParameterTypes().length > 0 ? 2 : 0;
  final boolean returns;
  if (m.getReturnType() != void.class) {
    returns=true;
    bl.add(JvmOp.ALOAD_0);
    sp++;
  }
 else {
    returns=false;
  }
  for (int i=0, p=0; i < m.getParameterTypes().length; i++) {
    final Class<?> t=m.getParameterTypes()[i];
    if (t == com.github.rjeschke.weel.Runtime.class) {
      sp++;
      bl.add(JvmOp.ALOAD_0);
      continue;
    }
    bl.add(JvmOp.ALOAD_0);
    mw.ldcInt(p++);
    bl.add(JvmOp.INVOKEVIRTUAL);
    if (t == double.class) {
      sp+=2;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if (t == int.class) {
      sp+=2;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
      bl.add(JvmOp.D2I);
    }
 else     if (t == String.class) {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if (t == WeelFunction.class) {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if (t == Value.class) {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if (t == ValueMap.class) {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
      if (t != Object.class) {
        bl.add(JvmOp.CHECKCAST);
        bl.addShort(this.classWriter.addConstant(new JvmConstant(JvmConstant.CONSTANT_Class,this.classWriter.addConstant(new JvmConstant(t.getCanonicalName().replace('.','/'))))));
      }
    }
  }
  mw.maxStack=Math.max(mw.maxStack,sp);
  bl.add(JvmOp.INVOKESTATIC);
  bl.addShort(this.classWriter.addMethodRefConstant(m.getDeclaringClass().getCanonicalName(),m.getName(),"String_Node_Str" + JvmClassWriter.buildDescriptor(m.getParameterTypes()) + "String_Node_Str"+ JvmClassWriter.buildDescriptor(m.getReturnType())));
  if (returns) {
    sp=1;
    final Class<?> t=m.getReturnType();
    bl.add(JvmOp.INVOKEVIRTUAL);
    if (t == double.class) {
      sp+=2;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if (t == int.class) {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if (t == String.class) {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if (t == ValueMap.class) {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if (t == Value.class) {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if (t == WeelFunction.class) {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else {
      sp++;
      bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
    }
    mw.maxStack=Math.max(mw.maxStack,sp);
    bl.add(JvmOp.ALOAD_0);
    mw.ldcInt(1);
    bl.add(JvmOp.INVOKEVIRTUAL);
    bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
  }
 else {
    bl.add(JvmOp.ALOAD_0);
    mw.ldcInt(0);
    bl.add(JvmOp.INVOKEVIRTUAL);
    bl.addShort(this.classWriter.addMethodRefConstant("String_Node_Str","String_Node_Str","String_Node_Str"));
  }
  bl.add(JvmOp.RETURN);
  return mname;
}