Program: 30177
Project: 30177
Buggy source:
public void generateOptionalLocalInterfaceSubClass(Class superClass,String subClassName,Class delegateClass) throws Exception {
  if (protectionDomain == null) {
    protectionDomain=superClass.getProtectionDomain();
  }
  ClassWriter cw=new ClassWriter(INTF_FLAGS);
  ClassVisitor tv=cw;
  String[] interfaces=new String[]{OptionalLocalInterfaceProvider.class.getName().replace('.','/'),com.sun.ejb.spi.io.IndirectlySerializable.class.getName().replace('.','/')};
  tv.visit(V1_1,ACC_PUBLIC,subClassName.replace('.','/'),null,Type.getType(superClass).getInternalName(),interfaces);
  String fldDesc=Type.getDescriptor(delegateClass);
  FieldVisitor fv=tv.visitField(ACC_PRIVATE,DELEGATE_FIELD_NAME,fldDesc,null,null);
  fv.visitEnd();
{
    Constructor[] ctors=superClass.getConstructors();
    Constructor ctorWithParams=null;
    for (    Constructor ctor : ctors) {
      if (ctor.getParameterTypes().length > 0) {
        ctorWithParams=ctor;
        break;
      }
    }
    MethodVisitor cv=tv.visitMethod(ACC_PUBLIC,"String_Node_Str","String_Node_Str",null,null);
    cv.visitVarInsn(ALOAD,0);
    String paramTypeString="String_Node_Str";
    int maxValue=1;
    if (ctorWithParams != null) {
      Class[] paramTypes=ctorWithParams.getParameterTypes();
      for (int i=0; i < paramTypes.length; i++) {
        cv.visitInsn(ACONST_NULL);
      }
      paramTypeString=Type.getConstructorDescriptor(ctorWithParams);
      maxValue=paramTypes.length + 1;
    }
    cv.visitMethodInsn(INVOKESPECIAL,Type.getType(superClass).getInternalName(),"String_Node_Str",paramTypeString);
    cv.visitInsn(RETURN);
    cv.visitMaxs(maxValue,1);
  }
  generateSetDelegateMethod(tv,delegateClass,subClassName);
  generateGetSerializableObjectFactoryMethod(tv,fldDesc,subClassName.replace('.','/'));
  Set<java.lang.reflect.Method> allMethods=new HashSet<java.lang.reflect.Method>();
  for (Class clz=superClass; clz != Object.class; clz=clz.getSuperclass()) {
    java.lang.reflect.Method[] beanMethods=clz.getDeclaredMethods();
    for (    java.lang.reflect.Method mth : beanMethods) {
      if (!hasSameSignatureAsExisting(mth,allMethods)) {
        int modifiers=mth.getModifiers();
        boolean isPublic=Modifier.isPublic(modifiers);
        boolean isPrivate=Modifier.isPrivate(modifiers);
        boolean isProtected=Modifier.isProtected(modifiers);
        boolean isPackage=!isPublic && !isPrivate && !isProtected;
        boolean isStatic=Modifier.isStatic(modifiers);
        if (isPublic && !isStatic) {
          generateBeanMethod(tv,subClassName,mth,delegateClass);
        }
 else         if ((isPackage || isProtected) && !isStatic) {
          generateNonAccessibleMethod(tv,mth);
        }
        allMethods.add(mth);
      }
    }
  }
  java.lang.reflect.Method mth=Object.class.getDeclaredMethod("String_Node_Str",emptyClassArray);
  if (!hasSameSignatureAsExisting(mth,allMethods)) {
    generateToStringBeanMethod(tv,superClass);
  }
  tv.visitEnd();
  byte[] classData=cw.toByteArray();
  classMap.put(subClassName,classData);
}

Fixed version (ground truth):
public void generateOptionalLocalInterfaceSubClass(Class superClass,String subClassName,Class delegateClass) throws Exception {
  if (protectionDomain == null) {
    protectionDomain=superClass.getProtectionDomain();
  }
  ClassWriter cw=new ClassWriter(INTF_FLAGS);
  ClassVisitor tv=cw;
  String[] interfaces=new String[]{OptionalLocalInterfaceProvider.class.getName().replace('.','/'),com.sun.ejb.spi.io.IndirectlySerializable.class.getName().replace('.','/')};
  tv.visit(V1_1,ACC_PUBLIC,subClassName.replace('.','/'),null,Type.getType(superClass).getInternalName(),interfaces);
  String fldDesc=Type.getDescriptor(delegateClass);
  FieldVisitor fv=tv.visitField(ACC_PRIVATE,DELEGATE_FIELD_NAME,fldDesc,null,null);
  fv.visitEnd();
{
    Constructor[] ctors=superClass.getConstructors();
    Constructor ctorWithParams=null;
    for (    Constructor ctor : ctors) {
      if (ctor.getParameterTypes().length > 0) {
        ctorWithParams=ctor;
        break;
      }
    }
    MethodVisitor cv=tv.visitMethod(ACC_PUBLIC,"String_Node_Str","String_Node_Str",null,null);
    cv.visitVarInsn(ALOAD,0);
    String paramTypeString="String_Node_Str";
    int maxValue=1;
    if (ctorWithParams != null) {
      Class[] paramTypes=ctorWithParams.getParameterTypes();
      for (int i=0; i < paramTypes.length; i++) {
        cv.visitInsn(ACONST_NULL);
      }
      paramTypeString=Type.getConstructorDescriptor(ctorWithParams);
      maxValue=paramTypes.length + 1;
    }
    cv.visitMethodInsn(INVOKESPECIAL,Type.getType(superClass).getInternalName(),"String_Node_Str",paramTypeString);
    cv.visitInsn(RETURN);
    cv.visitMaxs(maxValue,1);
  }
  generateSetDelegateMethod(tv,delegateClass,subClassName);
  generateGetSerializableObjectFactoryMethod(tv,fldDesc,subClassName.replace('.','/'));
  Set<java.lang.reflect.Method> allMethods=new HashSet<java.lang.reflect.Method>();
  for (  java.lang.reflect.Method m : superClass.getMethods()) {
    if (qualifiedAsBeanMethod(m)) {
      generateBeanMethod(tv,subClassName,m,delegateClass);
    }
  }
  for (Class clz=superClass; clz != Object.class; clz=clz.getSuperclass()) {
    java.lang.reflect.Method[] beanMethods=clz.getDeclaredMethods();
    for (    java.lang.reflect.Method mth : beanMethods) {
      if (!hasSameSignatureAsExisting(mth,allMethods)) {
        int modifiers=mth.getModifiers();
        boolean isPublic=Modifier.isPublic(modifiers);
        boolean isPrivate=Modifier.isPrivate(modifiers);
        boolean isProtected=Modifier.isProtected(modifiers);
        boolean isPackage=!isPublic && !isPrivate && !isProtected;
        boolean isStatic=Modifier.isStatic(modifiers);
        if ((isPackage || isProtected) && !isStatic) {
          generateNonAccessibleMethod(tv,mth);
        }
        allMethods.add(mth);
      }
    }
  }
  java.lang.reflect.Method mth=Object.class.getDeclaredMethod("String_Node_Str",emptyClassArray);
  if (!hasSameSignatureAsExisting(mth,allMethods)) {
    generateToStringBeanMethod(tv,superClass);
  }
  tv.visitEnd();
  byte[] classData=cw.toByteArray();
  classMap.put(subClassName,classData);
}