Program: 2341
Project: 2341
Buggy source:
@Override protected void addMethods(){
  final String ROLE_PARAM="String_Node_Str";
  final String MESSAGE_VAR="String_Node_Str";
  final String OPENUM_VAR="String_Node_Str";
  final String OP=MESSAGE_VAR + "String_Node_Str" + StateChannelApiGenerator.SCRIBMESSAGE_OP_FIELD;
  Module main=this.apigen.getMainModule();
  ClassBuilder caseclass=new CaseSocketGenerator(apigen,curr).generateType();
  String next=caseclass.getName();
  String enumClass=getBranchEnumClassName(this.apigen,this.curr);
  MethodBuilder mb=cb.newMethod("String_Node_Str");
  mb.setReturn(next);
  mb.addParameters(SessionApiGenerator.getRoleClassName(curr.getAcceptable().iterator().next().obj) + "String_Node_Str" + ROLE_PARAM);
  mb.addModifiers(JavaBuilder.PUBLIC);
  mb.addExceptions(StateChannelApiGenerator.SCRIBBLERUNTIMEEXCEPTION_CLASS,"String_Node_Str","String_Node_Str");
  mb.addAnnotations("String_Node_Str");
  Role peer=curr.getAcceptable().iterator().next().obj;
  mb.addBodyLine(StateChannelApiGenerator.SCRIBMESSAGE_CLASS + "String_Node_Str" + MESSAGE_VAR+ "String_Node_Str"+ JavaBuilder.SUPER+ "String_Node_Str"+ getSessionApiRoleConstant(peer)+ "String_Node_Str");
  mb.addBodyLine(enumClass + "String_Node_Str" + OPENUM_VAR+ "String_Node_Str");
  boolean first=true;
  for (  IOAction a : curr.getAcceptable()) {
    mb.addBodyLine(((first) ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str" + OP+ "String_Node_Str"+ getSessionApiOpConstant(a.mid)+ "String_Node_Str");
    mb.addBodyLine(1,OPENUM_VAR + "String_Node_Str" + enumClass+ "String_Node_Str"+ SessionApiGenerator.getOpClassName(a.mid)+ "String_Node_Str");
    mb.addBodyLine("String_Node_Str");
    first=false;
  }
  mb.addBodyLine("String_Node_Str");
  mb.addBodyLine(1,"String_Node_Str" + JavaBuilder.NEW + "String_Node_Str"+ OP+ "String_Node_Str");
  mb.addBodyLine("String_Node_Str");
  mb.addBodyLine(JavaBuilder.RETURN + "String_Node_Str" + JavaBuilder.NEW+ "String_Node_Str"+ next+ "String_Node_Str"+ SCRIBSOCKET_SE_FIELD+ "String_Node_Str"+ OPENUM_VAR+ "String_Node_Str"+ MESSAGE_VAR+ "String_Node_Str");
  String handlerif=HandlerInterfaceGenerator.getHandlerInterfaceName(this.cb.getName());
  String handleif=HandleInterfaceGenerator.getHandleInterfaceName(this.apigen.getSelf(),this.curr);
  MethodBuilder mb2=this.cb.newMethod("String_Node_Str");
  mb2.addParameters(SessionApiGenerator.getRoleClassName(peer) + "String_Node_Str" + ROLE_PARAM);
  mb2.addParameters(handlerif + "String_Node_Str");
  mb2.setReturn(JavaBuilder.VOID);
  mb2.addModifiers(JavaBuilder.PUBLIC);
  mb2.addExceptions(StateChannelApiGenerator.SCRIBBLERUNTIMEEXCEPTION_CLASS,"String_Node_Str","String_Node_Str");
  first=true;
  handleif+="String_Node_Str";
  for (  IOAction a : this.curr.getAcceptable().stream().sorted(IOStateInterfaceGenerator.IOACTION_COMPARATOR).collect(Collectors.toList())) {
    if (first) {
      first=false;
    }
 else {
      handleif+="String_Node_Str";
    }
    EndpointState succ=this.curr.accept(a);
    if (succ.isTerminal()) {
      handleif+=ScribSocketGenerator.GENERATED_ENDSOCKET_NAME;
    }
 else {
      handleif+=this.apigen.getSocketClassName(succ);
    }
  }
  handleif+="String_Node_Str";
  mb2.addBodyLine("String_Node_Str" + handleif + "String_Node_Str");
  MethodBuilder mb3=this.cb.newMethod("String_Node_Str");
  mb3.addParameters(SessionApiGenerator.getRoleClassName(peer) + "String_Node_Str" + ROLE_PARAM);
  mb3.addParameters(handleif + "String_Node_Str");
  mb3.setReturn(JavaBuilder.VOID);
  mb3.addModifiers(JavaBuilder.PUBLIC);
  mb3.addAnnotations("String_Node_Str");
  mb3.addExceptions(StateChannelApiGenerator.SCRIBBLERUNTIMEEXCEPTION_CLASS,"String_Node_Str","String_Node_Str");
  mb3.addBodyLine(StateChannelApiGenerator.SCRIBMESSAGE_CLASS + "String_Node_Str" + MESSAGE_VAR+ "String_Node_Str"+ JavaBuilder.SUPER+ "String_Node_Str"+ getSessionApiRoleConstant(peer)+ "String_Node_Str");
  first=true;
  for (  IOAction a : this.curr.getAcceptable()) {
    EndpointState succ=this.curr.accept(a);
    if (first) {
      first=false;
    }
 else {
      mb3.addBodyLine("String_Node_Str");
    }
    mb3.addBodyLine("String_Node_Str" + MESSAGE_VAR + "String_Node_Str"+ StateChannelApiGenerator.SCRIBMESSAGE_OP_FIELD+ "String_Node_Str"+ getSessionApiOpConstant(a.mid)+ "String_Node_Str");
    if (succ.isTerminal()) {
      mb3.addBodyLine(1,SCRIBSOCKET_SE_FIELD + "String_Node_Str");
    }
    String ln="String_Node_Str";
{
      ln+=JavaBuilder.NEW + "String_Node_Str" + (succ.isTerminal() ? ScribSocketGenerator.GENERATED_ENDSOCKET_NAME : this.apigen.getSocketClassName(succ))+ "String_Node_Str"+ SCRIBSOCKET_SE_FIELD+ "String_Node_Str";
    }
    ln+=getSessionApiOpConstant(a.mid);
    if (a.mid.isOp()) {
      if (!a.payload.isEmpty()) {
        String buffSuper=JavaBuilder.NEW + "String_Node_Str" + BUF_CLASS+ "String_Node_Str";
        int i=0;
        for (        PayloadType<?> pt : a.payload.elems) {
          DataTypeDecl dtd=main.getDataTypeDecl((DataType)pt);
          ln+="String_Node_Str" + buffSuper + "String_Node_Str"+ dtd.extName+ "String_Node_Str"+ RECEIVE_MESSAGE_PARAM+ "String_Node_Str"+ SCRIBMESSAGE_PAYLOAD_FIELD+ "String_Node_Str"+ i+++ "String_Node_Str";
        }
      }
    }
 else {
      MessageSigNameDecl msd=main.getMessageSigDecl(((MessageSigName)a.mid).getSimpleName());
      ln+="String_Node_Str" + JavaBuilder.NEW + "String_Node_Str"+ BUF_CLASS+ "String_Node_Str"+ msd.extName+ "String_Node_Str"+ RECEIVE_MESSAGE_PARAM+ "String_Node_Str"+ SCRIBMESSAGE_PAYLOAD_FIELD+ "String_Node_Str";
    }
    ln+="String_Node_Str";
    mb3.addBodyLine(1,ln);
    mb3.addBodyLine("String_Node_Str");
  }
  mb3.addBodyLine("String_Node_Str");
  mb3.addBodyLine(1,"String_Node_Str" + JavaBuilder.NEW + "String_Node_Str"+ OP+ "String_Node_Str");
  mb3.addBodyLine("String_Node_Str");
  MethodBuilder mb4=this.cb.newMethod("String_Node_Str");
  mb4.addParameters(SessionApiGenerator.getRoleClassName(peer) + "String_Node_Str" + ROLE_PARAM);
  String tmp=HandleInterfaceGenerator.getHandleInterfaceName(this.apigen.getSelf(),this.curr) + "String_Node_Str";
  tmp+=this.curr.getAcceptable().stream().sorted(IOStateInterfaceGenerator.IOACTION_COMPARATOR).map((a) -> SuccessorInterfaceGenerator.getSuccessorInterfaceName(a)).collect(Collectors.joining("String_Node_Str")) + "String_Node_Str";
  mb4.addParameters(tmp + "String_Node_Str");
  mb4.setReturn(JavaBuilder.VOID);
  mb4.addModifiers(JavaBuilder.PUBLIC);
  mb4.addExceptions(StateChannelApiGenerator.SCRIBBLERUNTIMEEXCEPTION_CLASS,"String_Node_Str","String_Node_Str");
  mb4.addAnnotations("String_Node_Str");
  mb4.addBodyLine(StateChannelApiGenerator.SCRIBMESSAGE_CLASS + "String_Node_Str" + MESSAGE_VAR+ "String_Node_Str"+ JavaBuilder.SUPER+ "String_Node_Str"+ getSessionApiRoleConstant(peer)+ "String_Node_Str");
  first=true;
  for (  IOAction a : this.curr.getAcceptable()) {
    EndpointState succ=this.curr.accept(a);
    if (first) {
      first=false;
    }
 else {
      mb4.addBodyLine("String_Node_Str");
    }
    mb4.addBodyLine("String_Node_Str" + MESSAGE_VAR + "String_Node_Str"+ StateChannelApiGenerator.SCRIBMESSAGE_OP_FIELD+ "String_Node_Str"+ getSessionApiOpConstant(a.mid)+ "String_Node_Str");
    if (succ.isTerminal()) {
      mb4.addBodyLine(1,SCRIBSOCKET_SE_FIELD + "String_Node_Str");
    }
    String ln="String_Node_Str";
{
      ln+=JavaBuilder.NEW + "String_Node_Str" + (succ.isTerminal() ? ScribSocketGenerator.GENERATED_ENDSOCKET_NAME : this.apigen.getSocketClassName(succ))+ "String_Node_Str"+ SCRIBSOCKET_SE_FIELD+ "String_Node_Str";
    }
    ln+=getSessionApiOpConstant(a.mid);
    if (a.mid.isOp()) {
      if (!a.payload.isEmpty()) {
        String buffSuper=JavaBuilder.NEW + "String_Node_Str" + BUF_CLASS+ "String_Node_Str";
        int i=0;
        for (        PayloadType<?> pt : a.payload.elems) {
          DataTypeDecl dtd=main.getDataTypeDecl((DataType)pt);
          ln+="String_Node_Str" + buffSuper + "String_Node_Str"+ dtd.extName+ "String_Node_Str"+ RECEIVE_MESSAGE_PARAM+ "String_Node_Str"+ SCRIBMESSAGE_PAYLOAD_FIELD+ "String_Node_Str"+ i+++ "String_Node_Str";
        }
      }
    }
 else {
      MessageSigNameDecl msd=main.getMessageSigDecl(((MessageSigName)a.mid).getSimpleName());
      ln+="String_Node_Str" + JavaBuilder.NEW + "String_Node_Str"+ BUF_CLASS+ "String_Node_Str"+ msd.extName+ "String_Node_Str"+ RECEIVE_MESSAGE_PARAM+ "String_Node_Str"+ SCRIBMESSAGE_PAYLOAD_FIELD+ "String_Node_Str";
    }
    ln+="String_Node_Str";
    mb4.addBodyLine(1,ln);
    mb4.addBodyLine("String_Node_Str");
  }
  mb4.addBodyLine("String_Node_Str");
  mb4.addBodyLine(1,"String_Node_Str" + JavaBuilder.NEW + "String_Node_Str"+ OP+ "String_Node_Str");
  mb4.addBodyLine("String_Node_Str");
  this.apigen.addTypeDecl(new HandlerInterfaceGenerator(this.apigen,this.cb,this.curr).generateType());
}

Fixed version (ground truth):
@Override protected void addMethods(){
  final String ROLE_PARAM="String_Node_Str";
  final String MESSAGE_VAR="String_Node_Str";
  final String OPENUM_VAR="String_Node_Str";
  final String OP=MESSAGE_VAR + "String_Node_Str" + StateChannelApiGenerator.SCRIBMESSAGE_OP_FIELD;
  Module main=this.apigen.getMainModule();
  ClassBuilder caseclass=new CaseSocketGenerator(apigen,curr).generateType();
  String next=caseclass.getName();
  String enumClass=getBranchEnumClassName(this.apigen,this.curr);
  MethodBuilder mb=cb.newMethod("String_Node_Str");
  mb.setReturn(next);
  mb.addParameters(SessionApiGenerator.getRoleClassName(curr.getTakeable().iterator().next().obj) + "String_Node_Str" + ROLE_PARAM);
  mb.addModifiers(JavaBuilder.PUBLIC);
  mb.addExceptions(StateChannelApiGenerator.SCRIBBLERUNTIMEEXCEPTION_CLASS,"String_Node_Str","String_Node_Str");
  mb.addAnnotations("String_Node_Str");
  Role peer=curr.getTakeable().iterator().next().obj;
  mb.addBodyLine(StateChannelApiGenerator.SCRIBMESSAGE_CLASS + "String_Node_Str" + MESSAGE_VAR+ "String_Node_Str"+ JavaBuilder.SUPER+ "String_Node_Str"+ getSessionApiRoleConstant(peer)+ "String_Node_Str");
  mb.addBodyLine(enumClass + "String_Node_Str" + OPENUM_VAR+ "String_Node_Str");
  boolean first=true;
  for (  IOAction a : curr.getTakeable()) {
    mb.addBodyLine(((first) ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str" + OP+ "String_Node_Str"+ getSessionApiOpConstant(a.mid)+ "String_Node_Str");
    mb.addBodyLine(1,OPENUM_VAR + "String_Node_Str" + enumClass+ "String_Node_Str"+ SessionApiGenerator.getOpClassName(a.mid)+ "String_Node_Str");
    mb.addBodyLine("String_Node_Str");
    first=false;
  }
  mb.addBodyLine("String_Node_Str");
  mb.addBodyLine(1,"String_Node_Str" + JavaBuilder.NEW + "String_Node_Str"+ OP+ "String_Node_Str");
  mb.addBodyLine("String_Node_Str");
  mb.addBodyLine(JavaBuilder.RETURN + "String_Node_Str" + JavaBuilder.NEW+ "String_Node_Str"+ next+ "String_Node_Str"+ SCRIBSOCKET_SE_FIELD+ "String_Node_Str"+ OPENUM_VAR+ "String_Node_Str"+ MESSAGE_VAR+ "String_Node_Str");
  String handlerif=HandlerInterfaceGenerator.getHandlerInterfaceName(this.cb.getName());
  String handleif=HandleInterfaceGenerator.getHandleInterfaceName(this.apigen.getSelf(),this.curr);
  MethodBuilder mb2=this.cb.newMethod("String_Node_Str");
  mb2.addParameters(SessionApiGenerator.getRoleClassName(peer) + "String_Node_Str" + ROLE_PARAM);
  mb2.addParameters(handlerif + "String_Node_Str");
  mb2.setReturn(JavaBuilder.VOID);
  mb2.addModifiers(JavaBuilder.PUBLIC);
  mb2.addExceptions(StateChannelApiGenerator.SCRIBBLERUNTIMEEXCEPTION_CLASS,"String_Node_Str","String_Node_Str");
  first=true;
  handleif+="String_Node_Str";
  for (  IOAction a : this.curr.getTakeable().stream().sorted(IOStateInterfaceGenerator.IOACTION_COMPARATOR).collect(Collectors.toList())) {
    if (first) {
      first=false;
    }
 else {
      handleif+="String_Node_Str";
    }
    EndpointState succ=this.curr.take(a);
    if (succ.isTerminal()) {
      handleif+=ScribSocketGenerator.GENERATED_ENDSOCKET_NAME;
    }
 else {
      handleif+=this.apigen.getSocketClassName(succ);
    }
  }
  handleif+="String_Node_Str";
  mb2.addBodyLine("String_Node_Str" + handleif + "String_Node_Str");
  MethodBuilder mb3=this.cb.newMethod("String_Node_Str");
  mb3.addParameters(SessionApiGenerator.getRoleClassName(peer) + "String_Node_Str" + ROLE_PARAM);
  mb3.addParameters(handleif + "String_Node_Str");
  mb3.setReturn(JavaBuilder.VOID);
  mb3.addModifiers(JavaBuilder.PUBLIC);
  mb3.addAnnotations("String_Node_Str");
  mb3.addExceptions(StateChannelApiGenerator.SCRIBBLERUNTIMEEXCEPTION_CLASS,"String_Node_Str","String_Node_Str");
  mb3.addBodyLine(StateChannelApiGenerator.SCRIBMESSAGE_CLASS + "String_Node_Str" + MESSAGE_VAR+ "String_Node_Str"+ JavaBuilder.SUPER+ "String_Node_Str"+ getSessionApiRoleConstant(peer)+ "String_Node_Str");
  first=true;
  for (  IOAction a : this.curr.getTakeable()) {
    EndpointState succ=this.curr.take(a);
    if (first) {
      first=false;
    }
 else {
      mb3.addBodyLine("String_Node_Str");
    }
    mb3.addBodyLine("String_Node_Str" + MESSAGE_VAR + "String_Node_Str"+ StateChannelApiGenerator.SCRIBMESSAGE_OP_FIELD+ "String_Node_Str"+ getSessionApiOpConstant(a.mid)+ "String_Node_Str");
    if (succ.isTerminal()) {
      mb3.addBodyLine(1,SCRIBSOCKET_SE_FIELD + "String_Node_Str");
    }
    String ln="String_Node_Str";
{
      ln+=JavaBuilder.NEW + "String_Node_Str" + (succ.isTerminal() ? ScribSocketGenerator.GENERATED_ENDSOCKET_NAME : this.apigen.getSocketClassName(succ))+ "String_Node_Str"+ SCRIBSOCKET_SE_FIELD+ "String_Node_Str";
    }
    ln+=getSessionApiOpConstant(a.mid);
    if (a.mid.isOp()) {
      if (!a.payload.isEmpty()) {
        String buffSuper=JavaBuilder.NEW + "String_Node_Str" + BUF_CLASS+ "String_Node_Str";
        int i=0;
        for (        PayloadType<?> pt : a.payload.elems) {
          DataTypeDecl dtd=main.getDataTypeDecl((DataType)pt);
          ln+="String_Node_Str" + buffSuper + "String_Node_Str"+ dtd.extName+ "String_Node_Str"+ RECEIVE_MESSAGE_PARAM+ "String_Node_Str"+ SCRIBMESSAGE_PAYLOAD_FIELD+ "String_Node_Str"+ i+++ "String_Node_Str";
        }
      }
    }
 else {
      MessageSigNameDecl msd=main.getMessageSigDecl(((MessageSigName)a.mid).getSimpleName());
      ln+="String_Node_Str" + JavaBuilder.NEW + "String_Node_Str"+ BUF_CLASS+ "String_Node_Str"+ msd.extName+ "String_Node_Str"+ RECEIVE_MESSAGE_PARAM+ "String_Node_Str"+ SCRIBMESSAGE_PAYLOAD_FIELD+ "String_Node_Str";
    }
    ln+="String_Node_Str";
    mb3.addBodyLine(1,ln);
    mb3.addBodyLine("String_Node_Str");
  }
  mb3.addBodyLine("String_Node_Str");
  mb3.addBodyLine(1,"String_Node_Str" + JavaBuilder.NEW + "String_Node_Str"+ OP+ "String_Node_Str");
  mb3.addBodyLine("String_Node_Str");
  MethodBuilder mb4=this.cb.newMethod("String_Node_Str");
  mb4.addParameters(SessionApiGenerator.getRoleClassName(peer) + "String_Node_Str" + ROLE_PARAM);
  String tmp=HandleInterfaceGenerator.getHandleInterfaceName(this.apigen.getSelf(),this.curr) + "String_Node_Str";
  tmp+=this.curr.getTakeable().stream().sorted(IOStateInterfaceGenerator.IOACTION_COMPARATOR).map((a) -> SuccessorInterfaceGenerator.getSuccessorInterfaceName(a)).collect(Collectors.joining("String_Node_Str")) + "String_Node_Str";
  mb4.addParameters(tmp + "String_Node_Str");
  mb4.setReturn(JavaBuilder.VOID);
  mb4.addModifiers(JavaBuilder.PUBLIC);
  mb4.addExceptions(StateChannelApiGenerator.SCRIBBLERUNTIMEEXCEPTION_CLASS,"String_Node_Str","String_Node_Str");
  mb4.addAnnotations("String_Node_Str");
  mb4.addBodyLine(StateChannelApiGenerator.SCRIBMESSAGE_CLASS + "String_Node_Str" + MESSAGE_VAR+ "String_Node_Str"+ JavaBuilder.SUPER+ "String_Node_Str"+ getSessionApiRoleConstant(peer)+ "String_Node_Str");
  first=true;
  for (  IOAction a : this.curr.getTakeable()) {
    EndpointState succ=this.curr.take(a);
    if (first) {
      first=false;
    }
 else {
      mb4.addBodyLine("String_Node_Str");
    }
    mb4.addBodyLine("String_Node_Str" + MESSAGE_VAR + "String_Node_Str"+ StateChannelApiGenerator.SCRIBMESSAGE_OP_FIELD+ "String_Node_Str"+ getSessionApiOpConstant(a.mid)+ "String_Node_Str");
    if (succ.isTerminal()) {
      mb4.addBodyLine(1,SCRIBSOCKET_SE_FIELD + "String_Node_Str");
    }
    String ln="String_Node_Str";
{
      ln+=JavaBuilder.NEW + "String_Node_Str" + (succ.isTerminal() ? ScribSocketGenerator.GENERATED_ENDSOCKET_NAME : this.apigen.getSocketClassName(succ))+ "String_Node_Str"+ SCRIBSOCKET_SE_FIELD+ "String_Node_Str";
    }
    ln+=getSessionApiOpConstant(a.mid);
    if (a.mid.isOp()) {
      if (!a.payload.isEmpty()) {
        String buffSuper=JavaBuilder.NEW + "String_Node_Str" + BUF_CLASS+ "String_Node_Str";
        int i=0;
        for (        PayloadType<?> pt : a.payload.elems) {
          DataTypeDecl dtd=main.getDataTypeDecl((DataType)pt);
          ln+="String_Node_Str" + buffSuper + "String_Node_Str"+ dtd.extName+ "String_Node_Str"+ RECEIVE_MESSAGE_PARAM+ "String_Node_Str"+ SCRIBMESSAGE_PAYLOAD_FIELD+ "String_Node_Str"+ i+++ "String_Node_Str";
        }
      }
    }
 else {
      MessageSigNameDecl msd=main.getMessageSigDecl(((MessageSigName)a.mid).getSimpleName());
      ln+="String_Node_Str" + JavaBuilder.NEW + "String_Node_Str"+ BUF_CLASS+ "String_Node_Str"+ msd.extName+ "String_Node_Str"+ RECEIVE_MESSAGE_PARAM+ "String_Node_Str"+ SCRIBMESSAGE_PAYLOAD_FIELD+ "String_Node_Str";
    }
    ln+="String_Node_Str";
    mb4.addBodyLine(1,ln);
    mb4.addBodyLine("String_Node_Str");
  }
  mb4.addBodyLine("String_Node_Str");
  mb4.addBodyLine(1,"String_Node_Str" + JavaBuilder.NEW + "String_Node_Str"+ OP+ "String_Node_Str");
  mb4.addBodyLine("String_Node_Str");
  this.apigen.addTypeDecl(new HandlerInterfaceGenerator(this.apigen,this.cb,this.curr).generateType());
}