Program: 189423
Project: 189423
Buggy source:
public void writeDelegator(Class intfcl,String genclass,Writer w) throws IOException {
  IndentedWriter iw=CodegenUtils.toIndentedWriter(w);
  String pkg=genclass.substring(0,genclass.lastIndexOf('.'));
  String sgc=CodegenUtils.fqcnLastElement(genclass);
  String scn=(superclass != null ? ClassUtils.simpleClassName(superclass) : null);
  String sin=ClassUtils.simpleClassName(intfcl);
  String[] eins=null;
  if (extraInterfaces != null) {
    eins=new String[extraInterfaces.length];
    for (int i=0, len=extraInterfaces.length; i < len; ++i)     eins[i]=ClassUtils.simpleClassName(extraInterfaces[i]);
  }
  Set imports=new TreeSet(classComp);
  Method[] methods=intfcl.getMethods();
  if (!CodegenUtils.inSamePackage(intfcl.getName(),genclass))   imports.add(intfcl);
  if (superclass != null && !CodegenUtils.inSamePackage(superclass.getName(),genclass))   imports.add(superclass);
  if (extraInterfaces != null) {
    for (int i=0, len=extraInterfaces.length; i < len; ++i) {
      Class checkMe=extraInterfaces[i];
      if (!CodegenUtils.inSamePackage(checkMe.getName(),genclass))       imports.add(checkMe);
    }
  }
  ensureImports(genclass,imports,methods);
  if (reflectiveDelegateMethods != null)   ensureImports(genclass,imports,reflectiveDelegateMethods);
  if (reflectiveDelegationPolicy.delegateClass != null && !CodegenUtils.inSamePackage(reflectiveDelegationPolicy.delegateClass.getName(),genclass))   imports.add(reflectiveDelegationPolicy.delegateClass);
  generateBannerComment(iw);
  iw.println("String_Node_Str" + pkg + ';');
  iw.println();
  for (Iterator ii=imports.iterator(); ii.hasNext(); )   iw.println("String_Node_Str" + ((Class)ii.next()).getName() + ';');
  generateExtraImports(iw);
  iw.println();
  generateClassJavaDocComment(iw);
  iw.print(CodegenUtils.getModifierString(class_modifiers) + "String_Node_Str" + sgc);
  if (superclass != null)   iw.print("String_Node_Str" + scn);
  iw.print("String_Node_Str" + sin);
  if (eins != null)   for (int i=0, len=eins.length; i < len; ++i)   iw.print("String_Node_Str" + eins[i]);
  iw.println();
  iw.println("String_Node_Str");
  iw.upIndent();
  iw.println("String_Node_Str" + sin + "String_Node_Str");
  iw.println();
  if (reflectiveDelegateMethods != null)   iw.println("String_Node_Str");
  iw.println();
  iw.println("String_Node_Str" + sin + "String_Node_Str");
  iw.println("String_Node_Str");
  iw.upIndent();
  iw.println("String_Node_Str");
  if (reflectiveDelegateMethods != null) {
    String delegateClassExpr;
    if (reflectiveDelegationPolicy == ReflectiveDelegationPolicy.USE_MAIN_DELEGATE_INTERFACE)     delegateClassExpr=sin + "String_Node_Str";
 else     if (reflectiveDelegationPolicy == ReflectiveDelegationPolicy.USE_RUNTIME_CLASS)     delegateClassExpr="String_Node_Str";
 else     delegateClassExpr=ClassUtils.simpleClassName(reflectiveDelegationPolicy.delegateClass) + "String_Node_Str";
    iw.println("String_Node_Str" + delegateClassExpr + "String_Node_Str");
  }
  iw.downIndent();
  iw.println("String_Node_Str");
  iw.println();
  if (wrapping_constructor) {
    iw.println("String_Node_Str" + ' ' + sgc+ '('+ sin+ "String_Node_Str");
    iw.println("String_Node_Str");
  }
  if (default_constructor) {
    iw.println();
    iw.println("String_Node_Str" + ' ' + sgc+ "String_Node_Str");
    iw.println("String_Node_Str");
  }
  if (inner_setter) {
    iw.println();
    iw.println(CodegenUtils.getModifierString(method_modifiers) + "String_Node_Str" + sin+ "String_Node_Str");
    iw.println("String_Node_Str");
  }
  if (inner_getter) {
    iw.println();
    iw.println(CodegenUtils.getModifierString(method_modifiers) + ' ' + sin+ "String_Node_Str");
    iw.println("String_Node_Str");
  }
  iw.println();
  for (int i=0, len=methods.length; i < len; ++i) {
    Method method=methods[i];
    if (i != 0)     iw.println();
    iw.println(CodegenUtils.methodSignature(method_modifiers,method,null));
    iw.println("String_Node_Str");
    iw.upIndent();
    generatePreDelegateCode(intfcl,genclass,method,iw);
    generateDelegateCode(intfcl,genclass,method,iw);
    generatePostDelegateCode(intfcl,genclass,method,iw);
    iw.downIndent();
    iw.println("String_Node_Str");
  }
  if (reflectiveDelegateMethods != null) {
    iw.println("String_Node_Str");
    for (int i=0, len=reflectiveDelegateMethods.length; i < len; ++i) {
      Method method=reflectiveDelegateMethods[i];
      if (i != 0)       iw.println();
      iw.println(CodegenUtils.methodSignature(method_modifiers,method,null));
      iw.println("String_Node_Str");
      iw.upIndent();
      generatePreDelegateCode(intfcl,genclass,method,iw);
      generateReflectiveDelegateCode(intfcl,genclass,method,iw);
      generatePostDelegateCode(intfcl,genclass,method,iw);
      iw.downIndent();
      iw.println("String_Node_Str");
    }
  }
  iw.println();
  generateExtraDeclarations(intfcl,genclass,iw);
  iw.downIndent();
  iw.println("String_Node_Str");
}

Fixed version (ground truth):
public void writeDelegator(Class intfcl,String genclass,Writer w) throws IOException {
  IndentedWriter iw=CodegenUtils.toIndentedWriter(w);
  String pkg=genclass.substring(0,genclass.lastIndexOf('.'));
  String sgc=CodegenUtils.fqcnLastElement(genclass);
  String scn=(superclass != null ? ClassUtils.simpleClassName(superclass) : null);
  String sin=ClassUtils.simpleClassName(intfcl);
  String[] eins=null;
  if (extraInterfaces != null) {
    eins=new String[extraInterfaces.length];
    for (int i=0, len=extraInterfaces.length; i < len; ++i)     eins[i]=ClassUtils.simpleClassName(extraInterfaces[i]);
  }
  Set imports=new TreeSet(classComp);
  Method[] methods=intfcl.getMethods();
  if (!CodegenUtils.inSamePackage(intfcl.getName(),genclass))   imports.add(intfcl);
  if (superclass != null && !CodegenUtils.inSamePackage(superclass.getName(),genclass))   imports.add(superclass);
  if (extraInterfaces != null) {
    for (int i=0, len=extraInterfaces.length; i < len; ++i) {
      Class checkMe=extraInterfaces[i];
      if (!CodegenUtils.inSamePackage(checkMe.getName(),genclass))       imports.add(checkMe);
    }
  }
  ensureImports(genclass,imports,methods);
  if (reflectiveDelegateMethods != null)   ensureImports(genclass,imports,reflectiveDelegateMethods);
  if (reflectiveDelegationPolicy.delegateClass != null && !CodegenUtils.inSamePackage(reflectiveDelegationPolicy.delegateClass.getName(),genclass))   imports.add(reflectiveDelegationPolicy.delegateClass);
  generateBannerComment(iw);
  iw.println("String_Node_Str" + pkg + ';');
  iw.println();
  for (Iterator ii=imports.iterator(); ii.hasNext(); )   iw.println("String_Node_Str" + ((Class)ii.next()).getName() + ';');
  generateExtraImports(iw);
  iw.println();
  generateClassJavaDocComment(iw);
  iw.print(CodegenUtils.getModifierString(class_modifiers) + "String_Node_Str" + sgc);
  if (superclass != null)   iw.print("String_Node_Str" + scn);
  iw.print("String_Node_Str" + sin);
  if (eins != null)   for (int i=0, len=eins.length; i < len; ++i)   iw.print("String_Node_Str" + eins[i]);
  iw.println();
  iw.println("String_Node_Str");
  iw.upIndent();
  iw.println("String_Node_Str" + sin + "String_Node_Str");
  iw.println();
  if (reflectiveDelegateMethods != null)   iw.println("String_Node_Str");
  iw.println();
  iw.println("String_Node_Str" + sin + "String_Node_Str");
  iw.println("String_Node_Str");
  iw.upIndent();
  iw.println("String_Node_Str");
  if (reflectiveDelegateMethods != null) {
    String delegateClassExpr;
    if (reflectiveDelegationPolicy == ReflectiveDelegationPolicy.USE_MAIN_DELEGATE_INTERFACE)     delegateClassExpr=sin + "String_Node_Str";
 else     if (reflectiveDelegationPolicy == ReflectiveDelegationPolicy.USE_RUNTIME_CLASS)     delegateClassExpr="String_Node_Str";
 else     delegateClassExpr=ClassUtils.simpleClassName(reflectiveDelegationPolicy.delegateClass) + "String_Node_Str";
    iw.println("String_Node_Str" + delegateClassExpr + "String_Node_Str");
  }
  iw.downIndent();
  iw.println("String_Node_Str");
  iw.println();
  if (wrapping_constructor) {
    iw.println(CodegenUtils.getModifierString(wrapping_ctor_modifiers) + ' ' + sgc+ '('+ sin+ "String_Node_Str");
    iw.println("String_Node_Str");
  }
  if (default_constructor) {
    iw.println();
    iw.println(CodegenUtils.getModifierString(default_ctor_modifiers) + ' ' + sgc+ "String_Node_Str");
    iw.println("String_Node_Str");
  }
  if (inner_setter) {
    iw.println();
    iw.println(CodegenUtils.getModifierString(method_modifiers) + "String_Node_Str" + sin+ "String_Node_Str");
    iw.println("String_Node_Str");
  }
  if (inner_getter) {
    iw.println();
    iw.println(CodegenUtils.getModifierString(method_modifiers) + ' ' + sin+ "String_Node_Str");
    iw.println("String_Node_Str");
  }
  iw.println();
  for (int i=0, len=methods.length; i < len; ++i) {
    Method method=methods[i];
    if (i != 0)     iw.println();
    iw.println(CodegenUtils.methodSignature(method_modifiers,method,null));
    iw.println("String_Node_Str");
    iw.upIndent();
    generatePreDelegateCode(intfcl,genclass,method,iw);
    generateDelegateCode(intfcl,genclass,method,iw);
    generatePostDelegateCode(intfcl,genclass,method,iw);
    iw.downIndent();
    iw.println("String_Node_Str");
  }
  if (reflectiveDelegateMethods != null) {
    iw.println("String_Node_Str");
    for (int i=0, len=reflectiveDelegateMethods.length; i < len; ++i) {
      Method method=reflectiveDelegateMethods[i];
      if (i != 0)       iw.println();
      iw.println(CodegenUtils.methodSignature(method_modifiers,method,null));
      iw.println("String_Node_Str");
      iw.upIndent();
      generatePreDelegateCode(intfcl,genclass,method,iw);
      generateReflectiveDelegateCode(intfcl,genclass,method,iw);
      generatePostDelegateCode(intfcl,genclass,method,iw);
      iw.downIndent();
      iw.println("String_Node_Str");
    }
  }
  iw.println();
  generateExtraDeclarations(intfcl,genclass,iw);
  iw.downIndent();
  iw.println("String_Node_Str");
}