nus-yam/ex-repair huggingface dataset:
Program: 2412
Project: 2412
Buggy source:
public synchronized void reregister(Role peer,BinaryChannelWrapper w) throws IOException, GeneralSecurityException {
  this.sel.pause();
  w.wrapChannel(getChannelEndpoint(peer));
  w.clientHandshake();
  this.chans.put(peer,w);
  this.sel.unpause();
}

Fixed version (ground truth):
public synchronized void reregister(Role peer,BinaryChannelWrapper w) throws IOException, GeneralSecurityException {
  BinaryChannelEndpoint c=getChannelEndpoint(peer);
  c.sync();
  this.sel.pause();
  w.wrapChannel(c);
  w.clientHandshake();
  this.chans.put(peer,w);
  this.sel.unpause();
}
Program: 2413
Project: 2413
Buggy source:
@Override public boolean equals(Object o){
  if (this == o) {
    return true;
  }
  if (!(o instanceof ScribMessage)) {
    return false;
  }
  ScribMessage body=(ScribMessage)o;
  return this.op.equals(body.op) && this.payload.equals(body.payload);
}

Fixed version (ground truth):
@Override public boolean equals(Object o){
  if (this == o) {
    return true;
  }
  if (!(o instanceof ScribMessage)) {
    return false;
  }
  ScribMessage m=(ScribMessage)o;
  return m.canEqual(this) && this.op.equals(m.op) && this.payload.equals(m.payload);
}
Program: 2414
Project: 2414
Buggy source:
public synchronized void enqueue(Role peer,ScribMessage o){
  this.queues.get(peer).add(o);
  this.counts.put(peer,this.counts.get(peer) + 1);
  this.notifyAll();
}

Fixed version (ground truth):
public synchronized void enqueue(Role peer,ScribMessage o){
  this.queues.get(peer).add(o);
  this.counts.put(peer,this.counts.get(peer) + 1);
  notifyAll();
}
Program: 2415
Project: 2415
Buggy source:
public synchronized CompletableFuture<ScribMessage> getFuture(Role peer){
  return CompletableFuture.supplyAsync(() -> {
    try {
      return dequeue(peer,getTicket(peer));
    }
 catch (    IOException e) {
      throw new RuntimeException(e);
    }
  }
);
}

Fixed version (ground truth):
public synchronized CompletableFuture<ScribMessage> getFuture(Role peer){
  return CompletableFuture.supplyAsync(() -> {
    try {
      ScribMessage m=dequeue(peer,getTicket(peer));
      if (m instanceof ScribInterrupt) {
        throw new RuntimeScribbleException((Throwable)((ScribInterrupt)m).payload[0]);
      }
      return m;
    }
 catch (    IOException e) {
      throw new RuntimeScribbleException(e);
    }
  }
);
}
Program: 2416
Project: 2416
Buggy source:
public void run(){
  EndpointInputQueues queues=this.ep.getInputQueues();
  try {
    while (true) {
      queues.enqueue(this.peer,this.ep.smf.readMessage(this.dis));
    }
  }
 catch (  IOException e) {
    this.fail=e;
  }
 finally {
    try {
      dis.close();
    }
 catch (    IOException e) {
      if (this.fail == null) {
        this.fail=e;
      }
    }
 finally {
    }
  }
}

Fixed version (ground truth):
public void run(){
  EndpointInputQueues queues=this.ep.getInputQueues();
  try {
    while (true) {
      queues.enqueue(this.peer,this.ep.smf.readMessage(this.dis));
    }
  }
 catch (  IOException e) {
    this.fail=e;
  }
 finally {
    try {
      dis.close();
    }
 catch (    IOException e) {
      if (this.fail == null) {
        this.fail=e;
      }
    }
 finally {
      if (this.fail != null) {
        queues.interrupt(this.peer,this.fail);
      }
    }
  }
}
Program: 2417
Project: 2417
Buggy source:
public static void main(String[] args) throws UnknownHostException, ScribbleRuntimeException, IOException, ClassNotFoundException, ExecutionException, InterruptedException {
  Proto1 adder=new Proto1();
  SessionEndpoint se=adder.project(Proto1.C,new ObjectStreamFormatter());
  try (Proto1_C_0 s0=new Proto1_C_0(se)){
    s0.connect(Proto1.S,"String_Node_Str",8888);
    Proto1_C_1 s1=s0.init();
    Proto1_C_6 s6=s1.branch();
switch (s6.op) {
case _1:
{
        Buff<Integer> b1=new Buff<>();
        Buff<Future_Proto1_C_4> b2=new Buff<>();
        s6.receive(Proto1._1,b1).async(Proto1._2,b2);
        System.out.println("String_Node_Str");
        System.out.println("String_Node_Str" + b2.val.sync().pay1);
        break;
      }
case _4:
{
      s6.receive(Proto1._4).async(Proto1._5).receive(Proto1._6);
      break;
    }
}
System.out.println("String_Node_Str");
}
 }

Fixed version (ground truth):
public static void main(String[] args) throws UnknownHostException, ScribbleRuntimeException, IOException, ClassNotFoundException, ExecutionException, InterruptedException {
  Proto1 adder=new Proto1();
  SessionEndpoint se=adder.project(Proto1.C,new ObjectStreamFormatter());
  try (Proto1_C_0 s0=new Proto1_C_0(se)){
    s0.connect(Proto1.S,"String_Node_Str",8888);
    Proto1_C_1 s1=s0.init();
    Proto1_C_6 s6=s1.branch();
switch (s6.op) {
case _1:
{
        Buff<Integer> b1=new Buff<>();
        Buff<Future_Proto1_C_4> b2=new Buff<>();
        s6.receive(Proto1._1,b1).async(Proto1._2,b2).send(Proto1.S,Proto1._3,3);
        System.out.println("String_Node_Str");
        System.out.println("String_Node_Str" + b2.val.sync().pay1);
        break;
      }
case _4:
{
      s6.receive(Proto1._4).async(Proto1._5).receive(Proto1._6);
      break;
    }
}
System.out.println("String_Node_Str");
}
 }
Program: 2418
Project: 2418
Buggy source:
@Override public void close() throws ScribbleRuntimeException {
  if (!this.ep.isCompleted()) {
    this.ep.close();
    throw new ScribbleRuntimeException("String_Node_Str" + this.ep.self);
  }
}

Fixed version (ground truth):
@Override public void close() throws ScribbleRuntimeException {
  this.ep.close();
  if (!this.ep.isCompleted()) {
    throw new ScribbleRuntimeException("String_Node_Str" + this.ep.self);
  }
}
Program: 2419
Project: 2419
Buggy source:
public synchronized boolean isEmpty(Role peer){
  System.out.println("String_Node_Str" + peer + "String_Node_Str"+ this.queues);
  return this.queues.get(peer).isEmpty();
}

Fixed version (ground truth):
public synchronized boolean isEmpty(Role peer){
  return this.queues.get(peer).isEmpty();
}
Program: 2420
Project: 2420
Buggy source:
public static void main(String[] args) throws UnknownHostException, ScribbleRuntimeException, IOException, ClassNotFoundException, ExecutionException, InterruptedException {
  Buff<Integer> i1=new Buff<>(1);
  Buff<Integer> i2=new Buff<>(1);
  Proto1 adder=new Proto1();
  SessionEndpoint se=adder.project(Proto1.C,new ObjectStreamFormatter());
  try (Proto1_C_0 s0=new Proto1_C_0(se)){
    s0.connect(Proto1.S,"String_Node_Str",8888);
    Proto1_C_1 s1=s0.init();
    Proto1_C_6 s6=s1.branch();
switch (s6.op) {
case _4:
{
        Proto1_C_2 s2=s6.receive(Proto1._4);
        boolean done=s2.isDone();
        Proto1_C_3 s3;
        if (done) {
          s3=s2.receive(Proto1._5);
        }
 else {
          s3=s2.async(Proto1._5);
        }
        Buff<Future_Proto1_C_4> b=new Buff<>();
        s3.send(Proto1.S,Proto1._1,999).async(Proto1._2,b).send(Proto1.S,Proto1._3,b.val.sync().pay1);
        System.out.println("String_Node_Str" + b.val.sync().pay1);
        break;
      }
case _6:
{
      s6.receive(Proto1._6,i1);
      System.out.println("String_Node_Str" + i1);
    }
}
}
 }

Fixed version (ground truth):
public static void main(String[] args) throws UnknownHostException, ScribbleRuntimeException, IOException, ClassNotFoundException, ExecutionException, InterruptedException {
  Buff<Integer> i1=new Buff<>(1);
  Buff<Integer> i2=new Buff<>(1);
  Proto1 adder=new Proto1();
  SessionEndpoint se=adder.project(Proto1.C,new ObjectStreamFormatter());
  try (Proto1_C_0 s0=new Proto1_C_0(se)){
    s0.connect(Proto1.S,"String_Node_Str",8888);
    Proto1_C_1 s1=s0.init();
    Proto1_C_6 s6=s1.branch();
switch (s6.op) {
case _4:
{
        Proto1_C_2 s2=s6.receive(Proto1._4);
        boolean done=s2.isDone();
        Proto1_C_3 s3;
        if (done) {
          s3=s2.receive(Proto1._5);
        }
 else {
          s3=s2.async(Proto1._5);
        }
        Buff<Future_Proto1_C_4> b=new Buff<>();
        s3.send(Proto1.S,Proto1._1,999).async(Proto1._2,b).send(Proto1.S,Proto1._3,b.val.sync().pay1);
        System.out.println("String_Node_Str" + done + "String_Node_Str"+ b.val.sync().pay1);
        break;
      }
case _6:
{
      s6.receive(Proto1._6,i1);
      System.out.println("String_Node_Str" + i1);
    }
}
}
 }
Program: 2421
Project: 2421
Buggy source:
public static void main(String[] args) throws IOException, ScribbleRuntimeException {
  try (ScribServerSocket ss=new ScribServerSocket(8888)){
    Buff<Integer> i1=new Buff<>();
    Buff<Integer> i2=new Buff<>();
    while (true) {
      Proto1 foo=new Proto1();
      SessionEndpoint se=foo.project(Proto1.S,new ObjectStreamFormatter());
      Proto1_S_0 init=new Proto1_S_0(se);
      init.accept(ss,Proto1.C);
      try (Proto1_S_0 s0=init){
        Proto1_S_1 s1=s0.init();
        Proto1_S_2 s2=s1.send(Proto1.C,Proto1._4,4,5);
        Thread.sleep(3000);
        s2.send(Proto1.C,Proto1._5).receive(Proto1._1,i1).send(Proto1.C,Proto1._2,i1.val).receive(Proto1._3,i1);
      }
 catch (      ScribbleRuntimeException|IOException|ExecutionException|InterruptedException|ClassNotFoundException e) {
        e.printStackTrace();
      }
    }
  }
 }

Fixed version (ground truth):
public static void main(String[] args) throws IOException, ScribbleRuntimeException {
  try (ScribServerSocket ss=new ScribServerSocket(8888)){
    Buff<Integer> i1=new Buff<>();
    Buff<Integer> i2=new Buff<>();
    while (true) {
      Proto1 foo=new Proto1();
      SessionEndpoint se=foo.project(Proto1.S,new ObjectStreamFormatter());
      Proto1_S_0 init=new Proto1_S_0(se);
      init.accept(ss,Proto1.C);
      try (Proto1_S_0 s0=init){
        Proto1_S_1 s1=s0.init();
        Proto1_S_2 s2=s1.send(Proto1.C,Proto1._4,4,5);
        Thread.sleep(2000);
        s2.send(Proto1.C,Proto1._5).receive(Proto1._1,i1).send(Proto1.C,Proto1._2,i1.val).receive(Proto1._3,i1);
      }
 catch (      ScribbleRuntimeException|IOException|ExecutionException|InterruptedException|ClassNotFoundException e) {
        e.printStackTrace();
      }
    }
  }
 }
Program: 2424
Project: 2424
Buggy source:
protected void writeScribMessage(Role peer,Op op,Object... payload) throws IOException, ScribbleRuntimeException {
  use();
  ScribMessage msg=new ScribMessage(op,payload);
  this.ep.getSocketEndpoint(peer).writeMessageAndFlush(msg);
}

Fixed version (ground truth):
protected void writeScribMessage(Role peer,ScribMessage msg) throws IOException, ScribbleRuntimeException {
  use();
  this.ep.getSocketEndpoint(peer).writeMessageAndFlush(msg);
}
Program: 2425
Project: 2425
Buggy source:
public static void main(String[] args) throws UnknownHostException, ScribbleRuntimeException, IOException, ClassNotFoundException {
  Buff<Integer> i1=new Buff<>(1);
  Buff<Integer> i2=new Buff<>(2);
  Adder adder=new Adder();
  SessionEndpoint se=adder.project(Adder.C,new ObjectStreamFormatter());
  try (Adder_C_0 s0=new Adder_C_0(se)){
    s0.connect(Adder.S,"String_Node_Str",8888);
    Adder_C_1 s1=s0.init();
    s1.send(Adder.S,Adder.ADD,i1.val,i1.val).receive(Adder.RES,i1).send(Adder.S,Adder.ADD,i1.val,i1.val).receive(Adder.RES,i1).send(Adder.S,Adder.BYE).end();
    System.out.println("String_Node_Str" + i1.val);
  }
 }

Fixed version (ground truth):
public static void main(String[] args) throws UnknownHostException, ScribbleRuntimeException, IOException, ClassNotFoundException, ExecutionException, InterruptedException {
  Buff<Integer> i1=new Buff<>(1);
  Buff<Integer> i2=new Buff<>(2);
  Adder adder=new Adder();
  SessionEndpoint se=adder.project(Adder.C,new ObjectStreamFormatter());
  try (Adder_C_0 s0=new Adder_C_0(se)){
    s0.connect(Adder.S,"String_Node_Str",8888);
    Adder_C_1 s1=s0.init();
    s1.send(Adder.S,Adder.ADD,i1.val,i1.val).receive(Adder.RES,i1).send(Adder.S,Adder.ADD,i1.val,i1.val).receive(Adder.RES,i1).send(Adder.S,Adder.BYE).receive(Adder.BYE);
    System.out.println("String_Node_Str" + i1.val);
  }
 }
Program: 2426
Project: 2426
Buggy source:
private static Adder_S_3 X(Adder_S_1 s1,Buff<Integer> i1,Buff<Integer> i2) throws ClassNotFoundException, ScribbleRuntimeException, IOException {
  Adder_S_4 s4=s1.branch();
switch (s4.op) {
case BYE:
{
      return s4.receive(Adder.BYE);
    }
case ADD:
{
    return X(s4.receive(Adder.ADD,i1,i2).send(Adder.C,Adder.RES,i1.val + i2.val),i1,i2);
  }
default :
{
  throw new RuntimeException("String_Node_Str");
}
}
}

Fixed version (ground truth):
private static Adder_S_3 X(Adder_S_1 s1,Buff<Integer> i1,Buff<Integer> i2) throws ClassNotFoundException, ScribbleRuntimeException, IOException, ExecutionException, InterruptedException {
  Adder_S_4 s4=s1.branch();
switch (s4.op) {
case BYE:
{
      return s4.receive(Adder.BYE);
    }
case ADD:
{
    return X(s4.receive(Adder.ADD,i1,i2).send(Adder.C,Adder.RES,i1.val + i2.val),i1,i2);
  }
default :
{
  throw new RuntimeException("String_Node_Str");
}
}
}
Program: 2427
Project: 2427
Buggy source:
public static void main(String[] args) throws IOException, ScribbleRuntimeException {
  try (ScribServerSocket ss=new ScribServerSocket(8888)){
    Buff<Integer> i1=new Buff<>();
    Buff<Integer> i2=new Buff<>();
    while (true) {
      Adder foo=new Adder();
      SessionEndpoint se=foo.project(Adder.S,new ObjectStreamFormatter());
      Adder_S_0 init=new Adder_S_0(se);
      init.accept(ss,Adder.C);
      try (Adder_S_0 s0=init){
        X(s0.init(),i1,i2).end();
      }
 catch (      ScribbleRuntimeException|IOException|ClassNotFoundException e) {
        e.printStackTrace();
      }
    }
  }
 }

Fixed version (ground truth):
public static void main(String[] args) throws IOException, ScribbleRuntimeException, ExecutionException, InterruptedException {
  try (ScribServerSocket ss=new ScribServerSocket(8888)){
    Buff<Integer> i1=new Buff<>();
    Buff<Integer> i2=new Buff<>();
    while (true) {
      Adder foo=new Adder();
      SessionEndpoint se=foo.project(Adder.S,new ObjectStreamFormatter());
      Adder_S_0 init=new Adder_S_0(se);
      init.accept(ss,Adder.C);
      try (Adder_S_0 s0=init){
        X(s0.init(),i1,i2).send(Adder.C,Adder.BYE);
      }
 catch (      ScribbleRuntimeException|IOException|ClassNotFoundException e) {
        e.printStackTrace();
      }
    }
  }
 }
Program: 2428
Project: 2428
Buggy source:
public static void main(String[] args) throws UnknownHostException, ScribbleRuntimeException, IOException, ClassNotFoundException {
  Buff<Integer> i1=new Buff<>(0);
  Buff<Integer> i2=new Buff<>(1);
  Adder adder=new Adder();
  SessionEndpoint se=adder.project(Adder.C,new ObjectStreamFormatter());
  try (Adder_C_0 s0=new Adder_C_0(se)){
    s0.connect(Adder.S,"String_Node_Str",8888);
    Adder_C_1 s1=s0.init();
    fib(s1,i1,i2,0).end();
  }
 }

Fixed version (ground truth):
public static void main(String[] args) throws UnknownHostException, ScribbleRuntimeException, IOException, ClassNotFoundException, ExecutionException, InterruptedException {
  Buff<Integer> i1=new Buff<>(0);
  Buff<Integer> i2=new Buff<>(1);
  Adder adder=new Adder();
  SessionEndpoint se=adder.project(Adder.C,new ObjectStreamFormatter());
  try (Adder_C_0 s0=new Adder_C_0(se)){
    s0.connect(Adder.S,"String_Node_Str",8888);
    Adder_C_1 s1=s0.init();
    fib(s1,i1,i2,0).receive(Adder.BYE);
  }
 }
Program: 2429
Project: 2429
Buggy source:
private static Adder_C_3 fib(Adder_C_1 s1,Buff<Integer> i1,Buff<Integer> i2,int i) throws ClassNotFoundException, ScribbleRuntimeException, IOException {
  return (i < 20) ? fib(side(s1.send(Adder.S,Adder.ADD,i1.val,i2.val),i1,i2).receive(Adder.RES,i2),i1,i2,i + 1) : s1.send(Adder.S,Adder.BYE);
}

Fixed version (ground truth):
private static Adder_C_3 fib(Adder_C_1 s1,Buff<Integer> i1,Buff<Integer> i2,int i) throws ClassNotFoundException, ScribbleRuntimeException, IOException, ExecutionException, InterruptedException {
  return (i < 20) ? fib(side(s1.send(Adder.S,Adder.ADD,i1.val,i2.val),i1,i2).receive(Adder.RES,i2),i1,i2,i + 1) : s1.send(Adder.S,Adder.BYE);
}
Program: 2430
Project: 2430
Buggy source:
public ProtocolDecl<K> getTargetProtocolDecl(JobContext jcontext,ModuleContext mcontext){
  ProtocolName<K> fullname=getTargetFullProtocolName(mcontext);
  return jcontext.getModule(fullname.getPrefix()).getProtocolDecl(fullname.getSimpleName());
}

Fixed version (ground truth):
public ProtocolDecl<K> getTargetProtocolDecl(JobContext jcontext,ModuleContext mcontext){
  ProtocolName<K> fullname=getTargetProtocolDeclFullName(mcontext);
  return jcontext.getModule(fullname.getPrefix()).getProtocolDecl(fullname.getSimpleName());
}
Program: 2431
Project: 2431
Buggy source:
@Override public Do<?> leaveProtocolDeclContextBuilding(ScribNode parent,ScribNode child,ProtocolDeclContextBuilder builder,ScribNode visited) throws ScribbleException {
  JobContext jcontext=builder.getJobContext();
  ModuleContext mcontext=builder.getModuleContext();
  Do<?> doo=(Do<?>)visited;
  ProtocolName<?> pn=doo.getTargetFullProtocolName(builder.getModuleContext());
  doo.roles.getRoles().stream().forEach((r) -> addProtocolDependency(builder,r,pn,doo.getTargetRoleParameter(jcontext,mcontext,r)));
  return doo;
}

Fixed version (ground truth):
@Override public Do<?> leaveProtocolDeclContextBuilding(ScribNode parent,ScribNode child,ProtocolDeclContextBuilder builder,ScribNode visited) throws ScribbleException {
  JobContext jcontext=builder.getJobContext();
  ModuleContext mcontext=builder.getModuleContext();
  Do<?> doo=(Do<?>)visited;
  ProtocolName<?> pn=doo.proto.toName();
  doo.roles.getRoles().stream().forEach((r) -> addProtocolDependency(builder,r,pn,doo.getTargetRoleParameter(jcontext,mcontext,r)));
  return doo;
}
Program: 2432
Project: 2432
Buggy source:
@Override public NonRoleArgList leaveDisambiguation(ScribNode parent,ScribNode child,NameDisambiguator disamb,ScribNode visited) throws ScribbleException {
  NonRoleArgList nral=(NonRoleArgList)super.leaveDisambiguation(parent,child,disamb,visited);
  ProtocolDecl<?> pd=getTargetProtocolDecl((Do<?>)parent,disamb);
  Iterator<NonRoleArg> args=nral.getDoArgs().iterator();
  for (  NonRoleParamDecl<?> param : pd.header.paramdecls.getDecls()) {
    NonRoleParamKind kind=param.kind;
    NonRoleArg arg=args.next();
    if (kind.equals(SigKind.KIND)) {
      if (!arg.val.isMessageSigNameNode() && !arg.val.isMessageSigNameNode()) {
        throw new RuntimeException("String_Node_Str" + arg + "String_Node_Str"+ kind);
      }
    }
 else     if (kind.equals(DataTypeKind.KIND)) {
      if (!arg.val.isDataTypeNameNode()) {
        throw new RuntimeException("String_Node_Str" + arg + "String_Node_Str"+ kind);
      }
    }
 else {
      throw new RuntimeException("String_Node_Str" + kind);
    }
  }
  return nral;
}

Fixed version (ground truth):
@Override public NonRoleArgList leaveDisambiguation(ScribNode parent,ScribNode child,NameDisambiguator disamb,ScribNode visited) throws ScribbleException {
  NonRoleArgList nral=(NonRoleArgList)super.leaveDisambiguation(parent,child,disamb,visited);
  ProtocolDecl<?> pd=getTargetProtocolDecl((Do<?>)parent,disamb);
  Iterator<NonRoleArg> args=nral.getDoArgs().iterator();
  for (  NonRoleParamDecl<?> param : pd.header.paramdecls.getDecls()) {
    NonRoleParamKind kind=param.kind;
    NonRoleArg arg=args.next();
    if (arg.val.isParamNode()) {
      if (!((NonRoleParamNode<?>)arg.val).kind.equals(kind)) {
        throw new ScribbleException("String_Node_Str" + arg + "String_Node_Str"+ kind);
      }
    }
 else     if (kind.equals(SigKind.KIND)) {
      if (!arg.val.isMessageSigNode() && !arg.val.isMessageSigNameNode()) {
        throw new ScribbleException("String_Node_Str" + arg + "String_Node_Str"+ kind);
      }
    }
 else     if (kind.equals(DataTypeKind.KIND)) {
      if (!arg.val.isDataTypeNameNode()) {
        throw new ScribbleException("String_Node_Str" + arg + "String_Node_Str"+ kind);
      }
    }
 else {
      throw new RuntimeException("String_Node_Str" + kind);
    }
  }
  return nral;
}
Program: 2433
Project: 2433
Buggy source:
@Override public GDo leaveProjection(ScribNode parent,ScribNode child,Projector proj,ScribNode visited) throws ScribbleException {
  GDo gd=(GDo)visited;
  Role popped=proj.popSelf();
  Role self=proj.peekSelf();
  LDo projection=null;
  if (gd.roles.getRoles().contains(self)) {
    RoleArgList roleinstans=gd.roles.project(self);
    NonRoleArgList arginstans=gd.args.project(self);
    LProtocolNameNode target=Projector.makeProjectedFullNameNode(gd.getTargetFullProtocolName(proj.getModuleContext()),popped);
    projection=AstFactoryImpl.FACTORY.LDo(roleinstans,arginstans,target);
  }
  proj.pushEnv(proj.popEnv().setProjection(projection));
  return (GDo)GSimpleInteractionNodeDel.super.leaveProjection(parent,child,proj,gd);
}

Fixed version (ground truth):
@Override public GDo leaveProjection(ScribNode parent,ScribNode child,Projector proj,ScribNode visited) throws ScribbleException {
  GDo gd=(GDo)visited;
  Role popped=proj.popSelf();
  Role self=proj.peekSelf();
  LDo projection=null;
  if (gd.roles.getRoles().contains(self)) {
    ModuleContext mc=proj.getModuleContext();
    RoleArgList roleinstans=gd.roles.project(self);
    NonRoleArgList arginstans=gd.args.project(self);
    LProtocolNameNode target=Projector.makeProjectedFullNameNode(gd.getTargetProtocolDeclFullName(mc),popped);
    projection=AstFactoryImpl.FACTORY.LDo(roleinstans,arginstans,target);
  }
  proj.pushEnv(proj.popEnv().setProjection(projection));
  return (GDo)GSimpleInteractionNodeDel.super.leaveProjection(parent,child,proj,gd);
}
Program: 2434
Project: 2434
Buggy source:
protected Do<?> visitOverrideForDo(InteractionSeq<?> parent,Do<?> child) throws ScribbleException {
  if (!isCycle()) {
    ModuleContext mcontext=getModuleContext();
    ProtocolDecl<? extends ProtocolKind> pd=child.getTargetProtocolDecl(getJobContext(),mcontext);
    ScribNode seq=applySubstitutions(pd.def.block.seq.clone());
    seq=seq.accept(this);
    pushEnv(popEnv().setTranslation(((InlineProtocolEnv)seq.del().env()).getTranslation()));
    return child;
  }
  return (child instanceof GDo) ? ((GDoDel)child.del()).visitForSubprotocolInlining(this,(GDo)child) : ((LDoDel)child.del()).visitForSubprotocolInlining(this,(LDo)child);
}

Fixed version (ground truth):
protected Do<?> visitOverrideForDo(InteractionSeq<?> parent,Do<?> child) throws ScribbleException {
  if (!isCycle()) {
    JobContext jc=getJobContext();
    ModuleContext mc=getModuleContext();
    ProtocolDecl<? extends ProtocolKind> pd=child.getTargetProtocolDecl(jc,mc);
    ScribNode seq=applySubstitutions(pd.def.block.seq.clone());
    seq=seq.accept(this);
    pushEnv(popEnv().setTranslation(((InlineProtocolEnv)seq.del().env()).getTranslation()));
    return child;
  }
  return (child instanceof GDo) ? ((GDoDel)child.del()).visitForSubprotocolInlining(this,(GDo)child) : ((LDoDel)child.del()).visitForSubprotocolInlining(this,(LDo)child);
}
Program: 2435
Project: 2435
Buggy source:
private Do<?> visitOverrideForDo(ScribNode parent,Do<?> doo) throws ScribbleException {
  if (!isCycle()) {
    ModuleContext mcontext=getModuleContext();
    ProtocolDecl<? extends ProtocolKind> pd=doo.getTargetProtocolDecl(getJobContext(),mcontext);
    ScribNode seq=applySubstitutions(pd.def.block.seq.clone());
    seq.accept(this);
  }
  return doo;
}

Fixed version (ground truth):
private Do<?> visitOverrideForDo(ScribNode parent,Do<?> doo) throws ScribbleException {
  if (!isCycle()) {
    JobContext jc=getJobContext();
    ModuleContext mc=getModuleContext();
    ProtocolDecl<? extends ProtocolKind> pd=doo.getTargetProtocolDecl(jc,mc);
    ScribNode seq=applySubstitutions(pd.def.block.seq.clone());
    seq.accept(this);
  }
  return doo;
}
Program: 2437
Project: 2437
Buggy source:
public static void main(String[] args) throws UnknownHostException, ScribbleRuntimeException, IOException, ClassNotFoundException, ExecutionException, InterruptedException {
  Buff<Integer> i1=new Buff<>(1);
  Buff<Integer> i2=new Buff<>(1);
  Proto1 adder=new Proto1();
  SessionEndpoint se=adder.project(Proto1.C,new ObjectStreamFormatter());
  try (Proto1_C_0 s0=new Proto1_C_0(se)){
    s0.connect(Proto1.S,"String_Node_Str",8888);
    Proto1_C_1 s1=s0.init();
    Proto1_C_6 s6=s1.branch();
switch (s6.op) {
case _4:
{
        Proto1_C_2 s2=s6.receive(Proto1._4);
        boolean done=s2.isDone();
        Proto1_C_3 s3;
        if (done) {
          s3=s2.receive(Proto1._5);
        }
 else {
          s3=s2.async(Proto1._5);
        }
        Buff<Future_Proto1_C_4> b=new Buff<>();
        s3.send(Proto1.S,Proto1._1,999).async(Proto1._2,b).send(Proto1.S,Proto1._3,b.val.sync().pay1);
        System.out.println("String_Node_Str" + done + "String_Node_Str"+ b.val.sync().pay1);
        break;
      }
case _6:
{
      s6.receive(Proto1._6,i1);
      System.out.println("String_Node_Str" + i1);
      break;
    }
}
}
 }

Fixed version (ground truth):
public static void main(String[] args) throws UnknownHostException, ScribbleRuntimeException, IOException, ClassNotFoundException, ExecutionException, InterruptedException {
  Buff<Integer> i1=new Buff<>(1);
  Buff<Integer> i2=new Buff<>(1);
  Proto1 adder=new Proto1();
  SessionEndpoint se=adder.project(Proto1.C,new ObjectStreamFormatter());
  try (Proto1_C_0 s0=new Proto1_C_0(se)){
    s0.connect(Proto1.S,"String_Node_Str",8888);
    Proto1_C_1 s1=s0.init();
    Proto1_C_6 s6=s1.branch();
switch (s6.op) {
case _4:
{
        Proto1_C_2 s2=s6.receive(Proto1._4);
        boolean done=s2.isDone();
        Proto1_C_3 s3;
        if (done) {
          s3=s2.receive(Proto1._5);
        }
 else {
          s3=s2.async(Proto1._5);
        }
        Buff<Future_Proto1_C_4> b=new Buff<>();
        s3.send(Proto1.S,Proto1._1,999).async(Proto1._2,b).send(Proto1.S,Proto1._3,b.val.sync().pay1);
        System.out.println("String_Node_Str" + done + "String_Node_Str"+ b.val.pay1+ "String_Node_Str"+ b.val.pay2);
        break;
      }
case _6:
{
      s6.receive(Proto1._6,i1);
      System.out.println("String_Node_Str" + i1);
      break;
    }
}
}
 }
Program: 2438
Project: 2438
Buggy source:
public static void main(String[] args) throws IOException, ScribbleRuntimeException {
  try (ScribServerSocket ss=new ScribServerSocket(8888)){
    Buff<Integer> i1=new Buff<>();
    Buff<Integer> i2=new Buff<>();
    while (true) {
      Proto1 foo=new Proto1();
      SessionEndpoint se=foo.project(Proto1.S,new ObjectStreamFormatter());
      Proto1_S_0 init=new Proto1_S_0(se);
      init.accept(ss,Proto1.C);
      try (Proto1_S_0 s0=init){
        Proto1_S_1 s1=s0.init();
        Proto1_S_2 s2=s1.send(Proto1.C,Proto1._4,4,5);
        Thread.sleep(2000);
        s2.send(Proto1.C,Proto1._5).receive(Proto1._1,i1).send(Proto1.C,Proto1._2,i1.val).receive(Proto1._3,i1);
      }
 catch (      ScribbleRuntimeException|IOException|ExecutionException|InterruptedException|ClassNotFoundException e) {
        e.printStackTrace();
      }
    }
  }
 }

Fixed version (ground truth):
public static void main(String[] args) throws IOException, ScribbleRuntimeException {
  try (ScribServerSocket ss=new ScribServerSocket(8888)){
    Buff<Integer> i1=new Buff<>();
    Buff<Integer> i2=new Buff<>();
    while (true) {
      Proto1 foo=new Proto1();
      SessionEndpoint se=foo.project(Proto1.S,new ObjectStreamFormatter());
      Proto1_S_0 init=new Proto1_S_0(se);
      init.accept(ss,Proto1.C);
      try (Proto1_S_0 s0=init){
        Proto1_S_1 s1=s0.init();
        Proto1_S_2 s2=s1.send(Proto1.C,Proto1._4,4,5);
        Thread.sleep(2000);
        s2.send(Proto1.C,Proto1._5).receive(Proto1._1,i1).send(Proto1.C,Proto1._2,i1.val,i1.val).receive(Proto1._3,i1);
      }
 catch (      ScribbleRuntimeException|IOException|ExecutionException|InterruptedException|ClassNotFoundException e) {
        e.printStackTrace();
      }
    }
  }
 }
Program: 2439
Project: 2439
Buggy source:
@Override public NonRoleParamDecl<K> reconstruct(SimpleNameNode<K> name){
  ScribDel del=del();
  NonRoleParamDecl<K> pd=new NonRoleParamDecl<>(this.kind,(NonRoleParamNode<K>)this.name);
  @SuppressWarnings("String_Node_Str") NonRoleParamDecl<K> tmp=(NonRoleParamDecl<K>)pd.del(del);
  return tmp;
}

Fixed version (ground truth):
@Override public NonRoleParamDecl<K> reconstruct(SimpleNameNode<K> name){
  ScribDel del=del();
  NonRoleParamDecl<K> pd=new NonRoleParamDecl<>(this.kind,(NonRoleParamNode<K>)name);
  @SuppressWarnings("String_Node_Str") NonRoleParamDecl<K> tmp=(NonRoleParamDecl<K>)pd.del(del);
  return tmp;
}
Program: 2440
Project: 2440
Buggy source:
@Override public NonRoleParamDeclList reconstruct(List<? extends HeaderParamDecl<NonRoleParamKind>> decls){
  ScribDel del=del();
  NonRoleParamDeclList rdl=new NonRoleParamDeclList(castParamDecls(decls));
  rdl=(NonRoleParamDeclList)rdl.del(del);
  return rdl;
}

Fixed version (ground truth):
@Override public NonRoleParamDeclList reconstruct(List<? extends HeaderParamDecl<NonRoleParamKind>> decls){
  ScribDel del=del();
  NonRoleParamDeclList rdl=AstFactoryImpl.FACTORY.NonRoleParamDeclList(castParamDecls(decls));
  rdl=(NonRoleParamDeclList)rdl.del(del);
  return rdl;
}
Program: 2441
Project: 2441
Buggy source:
@Override public HeaderParamDeclList<RoleKind> reconstruct(List<? extends HeaderParamDecl<RoleKind>> decls){
  ScribDel del=del();
  RoleDeclList rdl=new RoleDeclList(castRoleDecls(decls));
  rdl=(RoleDeclList)rdl.del(del);
  return rdl;
}

Fixed version (ground truth):
@Override public HeaderParamDeclList<RoleKind> reconstruct(List<? extends HeaderParamDecl<RoleKind>> decls){
  ScribDel del=del();
  RoleDeclList rdl=AstFactoryImpl.FACTORY.RoleDeclList(castRoleDecls(decls));
  rdl=(RoleDeclList)rdl.del(del);
  return rdl;
}
Program: 2444
Project: 2444
Buggy source:
private static List<CommonTree> filterChildren(CommonTree ct,AntlrNodeType... types){
  List<AntlrNodeType> tmp=Arrays.asList(types);
  List<CommonTree> children=Util.toCommonTreeList(ct.getChildren());
  return children.subList(1,children.size()).stream().filter((c) -> tmp.contains(Util.getAntlrNodeType(c))).collect(Collectors.toList());
}

Fixed version (ground truth):
private static List<CommonTree> filterChildren(CommonTree ct,AntlrNodeType... types){
  List<AntlrNodeType> tmp=Arrays.asList(types);
  List<CommonTree> children=ScribParserUtil.toCommonTreeList(ct.getChildren());
  return children.subList(1,children.size()).stream().filter((c) -> tmp.contains(ScribParserUtil.getAntlrNodeType(c))).collect(Collectors.toList());
}
Program: 2445
Project: 2445
Buggy source:
private static NonRoleArg parseNonRoleArg(ScribbleParser parser,CommonTree ct){
  AntlrNodeType type=Util.getAntlrNodeType(ct);
  if (type == AntlrNodeType.MESSAGESIGNATURE) {
    NonRoleArgNode arg=(NonRoleArgNode)parser.parse(ct);
    return AstFactoryImpl.FACTORY.NonRoleArg(arg);
  }
 else {
    if (type == AntlrNodeType.QUALIFIEDNAME) {
      if (ct.getChildCount() > 1) {
        DataTypeNameNode dt=AntlrQualifiedName.toDataTypeNameNode(ct);
        return AstFactoryImpl.FACTORY.NonRoleArg(dt);
      }
 else {
        AmbigNameNode an=AntlrAmbigName.toAmbigNameNode(ct);
        return AstFactoryImpl.FACTORY.NonRoleArg(an);
      }
    }
 else {
      throw new RuntimeException("String_Node_Str" + ct);
    }
  }
}

Fixed version (ground truth):
private static NonRoleArg parseNonRoleArg(ScribbleParser parser,CommonTree ct){
  AntlrNodeType type=ScribParserUtil.getAntlrNodeType(ct);
  if (type == AntlrNodeType.MESSAGESIGNATURE) {
    NonRoleArgNode arg=(NonRoleArgNode)parser.parse(ct);
    return AstFactoryImpl.FACTORY.NonRoleArg(arg);
  }
 else {
    if (type == AntlrNodeType.QUALIFIEDNAME) {
      if (ct.getChildCount() > 1) {
        DataTypeNameNode dt=AntlrQualifiedName.toDataTypeNameNode(ct);
        return AstFactoryImpl.FACTORY.NonRoleArg(dt);
      }
 else {
        AmbigNameNode an=AntlrAmbigName.toAmbigNameNode(ct);
        return AstFactoryImpl.FACTORY.NonRoleArg(an);
      }
    }
 else {
      throw new RuntimeException("String_Node_Str" + ct);
    }
  }
}
Program: 2446
Project: 2446
Buggy source:
public static List<CommonTree> getArgumentChildren(CommonTree ct){
  return (ct.getChildCount() == 0) ? Collections.emptyList() : Util.toCommonTreeList(ct.getChildren());
}

Fixed version (ground truth):
public static List<CommonTree> getArgumentChildren(CommonTree ct){
  return (ct.getChildCount() == 0) ? Collections.emptyList() : ScribParserUtil.toCommonTreeList(ct.getChildren());
}
Program: 2447
Project: 2447
Buggy source:
public static final List<CommonTree> getParamDeclChildren(CommonTree ct){
  return (ct.getChildCount() == 0) ? Collections.emptyList() : Util.toCommonTreeList(ct.getChildren());
}

Fixed version (ground truth):
public static final List<CommonTree> getParamDeclChildren(CommonTree ct){
  return (ct.getChildCount() == 0) ? Collections.emptyList() : ScribParserUtil.toCommonTreeList(ct.getChildren());
}
Program: 2448
Project: 2448
Buggy source:
public static NonRoleParamDeclList parseNonRoleParamDeclList(ScribbleParser parser,CommonTree ct){
  List<NonRoleParamDecl<NonRoleParamKind>> pds=new LinkedList<>();
  for (  CommonTree pd : getParamDeclChildren(ct)) {
    pds.add((NonRoleParamDecl<NonRoleParamKind>)parser.parse(pd));
  }
  return AstFactoryImpl.FACTORY.NonRoleParamDeclList(pds);
}

Fixed version (ground truth):
public static NonRoleParamDeclList parseNonRoleParamDeclList(ScribbleParser parser,CommonTree ct){
  List<NonRoleParamDecl<NonRoleParamKind>> pds=new LinkedList<>();
  for (  CommonTree pd : getParamDeclChildren(ct)) {
    NonRoleParamDecl<? extends NonRoleParamKind> parsed=(NonRoleParamDecl<?>)parser.parse(pd);
    @SuppressWarnings("String_Node_Str") NonRoleParamDecl<NonRoleParamKind> tmp=(NonRoleParamDecl<NonRoleParamKind>)parsed;
    pds.add(tmp);
  }
  return AstFactoryImpl.FACTORY.NonRoleParamDeclList(pds);
}
Program: 2449
Project: 2449
Buggy source:
public static final List<CommonTree> getPayloadElements(CommonTree ct){
  return (ct.getChildCount() == 0) ? Collections.emptyList() : Util.toCommonTreeList(ct.getChildren());
}

Fixed version (ground truth):
public static final List<CommonTree> getPayloadElements(CommonTree ct){
  return (ct.getChildCount() == 0) ? Collections.emptyList() : ScribParserUtil.toCommonTreeList(ct.getChildren());
}
Program: 2450
Project: 2450
Buggy source:
private static PayloadElem parsePayloadElem(CommonTree ct){
  AntlrNodeType type=Util.getAntlrNodeType(ct);
  if (type == AntlrNodeType.QUALIFIEDNAME) {
    if (ct.getChildCount() > 1) {
      DataTypeNameNode dt=AntlrQualifiedName.toDataTypeNameNode(ct);
      return AstFactoryImpl.FACTORY.PayloadElem(dt);
    }
 else {
      AmbigNameNode an=AntlrAmbigName.toAmbigNameNode(ct);
      return AstFactoryImpl.FACTORY.PayloadElem(an);
    }
  }
 else {
    throw new RuntimeException("String_Node_Str" + ct);
  }
}

Fixed version (ground truth):
private static PayloadElem parsePayloadElem(CommonTree ct){
  AntlrNodeType type=ScribParserUtil.getAntlrNodeType(ct);
  if (type == AntlrNodeType.QUALIFIEDNAME) {
    if (ct.getChildCount() > 1) {
      DataTypeNameNode dt=AntlrQualifiedName.toDataTypeNameNode(ct);
      return AstFactoryImpl.FACTORY.PayloadElem(dt);
    }
 else {
      AmbigNameNode an=AntlrAmbigName.toAmbigNameNode(ct);
      return AstFactoryImpl.FACTORY.PayloadElem(an);
    }
  }
 else {
    throw new RuntimeException("String_Node_Str" + ct);
  }
}
Program: 2451
Project: 2451
Buggy source:
public static final List<CommonTree> getRoleInstantiationChildren(CommonTree ct){
  return Util.toCommonTreeList(ct.getChildren());
}

Fixed version (ground truth):
public static final List<CommonTree> getRoleInstantiationChildren(CommonTree ct){
  return ScribParserUtil.toCommonTreeList(ct.getChildren());
}
Program: 2452
Project: 2452
Buggy source:
public static List<CommonTree> getRoleDeclChildren(CommonTree ct){
  return Util.toCommonTreeList(ct.getChildren());
}

Fixed version (ground truth):
public static List<CommonTree> getRoleDeclChildren(CommonTree ct){
  return ScribParserUtil.toCommonTreeList(ct.getChildren());
}
Program: 2453
Project: 2453
Buggy source:
public static List<CommonTree> getBlockChildren(CommonTree ct){
  List<?> children=ct.getChildren();
  return Util.toCommonTreeList(children.subList(BLOCK_CHILDREN_START_INDEX,children.size()));
}

Fixed version (ground truth):
public static List<CommonTree> getBlockChildren(CommonTree ct){
  List<?> children=ct.getChildren();
  return ScribParserUtil.toCommonTreeList(children.subList(BLOCK_CHILDREN_START_INDEX,children.size()));
}
Program: 2454
Project: 2454
Buggy source:
public static List<CommonTree> getInteractionChildren(CommonTree ct){
  return (ct.getChildCount() == 0) ? Collections.emptyList() : Util.toCommonTreeList(ct.getChildren());
}

Fixed version (ground truth):
public static List<CommonTree> getInteractionChildren(CommonTree ct){
  return (ct.getChildCount() == 0) ? Collections.emptyList() : ScribParserUtil.toCommonTreeList(ct.getChildren());
}
Program: 2455
Project: 2455
Buggy source:
public static List<CommonTree> getMessageChildren(CommonTree ct){
  return Util.toCommonTreeList(ct.getChildren().subList(MESSAGE_CHILDREN_START_INDEX,ct.getChildCount()));
}

Fixed version (ground truth):
public static List<CommonTree> getMessageChildren(CommonTree ct){
  return ScribParserUtil.toCommonTreeList(ct.getChildren().subList(MESSAGE_CHILDREN_START_INDEX,ct.getChildCount()));
}
Program: 2456
Project: 2456
Buggy source:
public static List<CommonTree> getInterruptChildren(CommonTree ct){
  List<?> children=ct.getChildren();
  return Util.toCommonTreeList(children.subList(INTERRUPT_CHILDREN_START_INDEX,children.size()));
}

Fixed version (ground truth):
public static List<CommonTree> getInterruptChildren(CommonTree ct){
  List<?> children=ct.getChildren();
  return ScribParserUtil.toCommonTreeList(children.subList(INTERRUPT_CHILDREN_START_INDEX,children.size()));
}
Program: 2457
Project: 2457
Buggy source:
public static List<CommonTree> getDestChildren(CommonTree ct){
  return Util.toCommonTreeList(ct.getChildren().subList(DESTINATION_CHILDREN_START_INDEX,ct.getChildCount()));
}

Fixed version (ground truth):
public static List<CommonTree> getDestChildren(CommonTree ct){
  return ScribParserUtil.toCommonTreeList(ct.getChildren().subList(DESTINATION_CHILDREN_START_INDEX,ct.getChildCount()));
}
Program: 2458
Project: 2458
Buggy source:
protected static MessageNode parseMessage(ScribbleParser parser,CommonTree ct){
  AntlrNodeType type=Util.getAntlrNodeType(ct);
  if (type == AntlrNodeType.MESSAGESIGNATURE) {
    return (MessageSigNode)parser.parse(ct);
  }
 else {
    return (ct.getChildCount() == 1) ? AntlrAmbigName.toAmbigNameNode(ct) : AntlrQualifiedName.toMessageSigNameNode(ct);
  }
}

Fixed version (ground truth):
protected static MessageNode parseMessage(ScribbleParser parser,CommonTree ct){
  AntlrNodeType type=ScribParserUtil.getAntlrNodeType(ct);
  if (type == AntlrNodeType.MESSAGESIGNATURE) {
    return (MessageSigNode)parser.parse(ct);
  }
 else {
    return (ct.getChildCount() == 1) ? AntlrAmbigName.toAmbigNameNode(ct) : AntlrQualifiedName.toMessageSigNameNode(ct);
  }
}
Program: 2459
Project: 2459
Buggy source:
public static final List<CommonTree> getBlockChildren(CommonTree ct){
  return Util.toCommonTreeList(ct.getChildren());
}

Fixed version (ground truth):
public static final List<CommonTree> getBlockChildren(CommonTree ct){
  return ScribParserUtil.toCommonTreeList(ct.getChildren());
}
Program: 2460
Project: 2460
Buggy source:
@Override public ScribNode leaveProjectedRoleDeclFixing(ScribNode parent,ScribNode child,ProjectedRoleDeclFixer fixer,ScribNode visited) throws ScribbleException {
  LDo ld=(LDo)visited;
  LProtocolDecl lpd=ld.getTargetProtocolDecl(fixer.getJobContext(),fixer.getModuleContext());
  Iterator<Role> roleargs=ld.roles.args.stream().map((ra) -> ra.val.toName()).collect(Collectors.toList()).iterator();
  Map<Role,Role> rolemap=lpd.header.roledecls.getRoles().stream().collect(Collectors.toMap((r) -> r,(r) -> roleargs.next()));
  Set<Role> occs=((LProtocolDeclDel)lpd.del()).getProtocolDeclContext().getRoleOccurrences().stream().map((r) -> rolemap.get(r)).collect(Collectors.toSet());
  List<RoleArg> ras=ld.roles.args.stream().filter((ra) -> occs.contains(ra.val.toName())).collect(Collectors.toList());
  RoleArgList roles=ld.roles.reconstruct(ras);
  return super.leaveProjectedRoleDeclFixing(parent,child,fixer,ld.reconstruct(roles,ld.args,ld.getProtocolNameNode()));
}

Fixed version (ground truth):
@Override public ScribNode leaveProjectedRoleDeclFixing(ScribNode parent,ScribNode child,ProjectedRoleDeclFixer fixer,ScribNode visited) throws ScribbleException {
  LDo ld=(LDo)visited;
  LProtocolDecl lpd=ld.getTargetProtocolDecl(fixer.getJobContext(),fixer.getModuleContext());
  Iterator<Role> roleargs=ld.roles.args.stream().map((ra) -> ra.val.toName()).collect(Collectors.toList()).iterator();
  JobContext jcontext=fixer.getJobContext();
  ModuleContext mcontext=fixer.getModuleContext();
  String mname=ld.getTargetFullProtocolName(mcontext).getPrefix().toString();
  mname=mname.substring(0,mname.lastIndexOf('_'));
  mname=mname.substring(0,mname.lastIndexOf('_'));
  String simppn=ld.getTargetFullProtocolName(mcontext).getLastElement();
  simppn=simppn.substring(0,simppn.lastIndexOf('_'));
  ModuleName modname;
  if (mname.indexOf('.') == -1) {
    modname=new ModuleName(mname);
  }
 else {
    String[] elems=mname.split("String_Node_Str");
    PackageName packname=new PackageName(Arrays.copyOf(elems,elems.length - 1));
    modname=new ModuleName(packname,new ModuleName(elems[elems.length - 1]));
  }
  GProtocolDecl gpd=(GProtocolDecl)jcontext.getModule(modname).getProtocolDecl(new GProtocolName(simppn));
  Map<Role,Role> rolemap=gpd.header.roledecls.getRoles().stream().collect(Collectors.toMap((r) -> r,(r) -> roleargs.next()));
  Set<Role> occs=((LProtocolDeclDel)lpd.del()).getProtocolDeclContext().getRoleOccurrences().stream().map((r) -> rolemap.get(r)).collect(Collectors.toSet());
  List<RoleArg> ras=ld.roles.args.stream().filter((ra) -> occs.contains(ra.val.toName())).collect(Collectors.toList());
  RoleArgList roles=ld.roles.reconstruct(ras);
  return super.leaveProjectedRoleDeclFixing(parent,child,fixer,ld.reconstruct(roles,ld.args,ld.getProtocolNameNode()));
}
Program: 2461
Project: 2461
Buggy source:
@Override public void enterFsmConstruction(ModelNode parent,ModelNode child,FsmConstructor conv){
  super.enterFsmConstruction(parent,child,conv);
  if (!conv.isCycle()) {
    SubprotocolSig subsig=conv.peekStack();
    Set<String> labs=new HashSet<>();
    labs.add(subsig.toString());
    ProtocolState s=conv.builder.newState(labs);
    conv.builder.setEntry(s);
    conv.builder.setSubprotocolEntry(subsig);
  }
}

Fixed version (ground truth):
@Override public void enterFsmConstruction(ModelNode parent,ModelNode child,FsmConstructor conv){
  super.enterFsmConstruction(parent,child,conv);
  if (!conv.isCycle()) {
    SubprotocolSig subsig=conv.peekStack();
    Set<String> labs=new HashSet<>(conv.builder.getEntry().getLabels());
    labs.add(subsig.toString());
    ProtocolState s=conv.builder.newState(labs);
    conv.builder.setEntry(s);
    conv.builder.setSubprotocolEntry(subsig);
  }
}
Program: 2462
Project: 2462
Buggy source:
@Override public void enterFsmConstruction(ModelNode parent,ModelNode child,FsmConstructor conv){
  super.enterFsmConstruction(parent,child,conv);
  LRecursion lr=(LRecursion)child;
  RecVar rv=lr.recvar.toName();
  Set<String> labs=new HashSet<>();
  labs.add(rv.toString());
  ProtocolState s=conv.builder.newState(labs);
  conv.builder.setEntry(s);
  conv.builder.setRecursionEntry(rv);
}

Fixed version (ground truth):
@Override public void enterFsmConstruction(ModelNode parent,ModelNode child,FsmConstructor conv){
  super.enterFsmConstruction(parent,child,conv);
  LRecursion lr=(LRecursion)child;
  RecVar rv=lr.recvar.toName();
  Set<String> labs=new HashSet<>(conv.builder.getEntry().getLabels());
  labs.add(rv.toString());
  ProtocolState s=conv.builder.newState(labs);
  conv.builder.setEntry(s);
  conv.builder.setRecursionEntry(rv);
}
Program: 2463
Project: 2463
Buggy source:
@Override public String toString(){
  System.out.println("String_Node_Str" + getDeclName());
  return getKeyword() + "String_Node_Str" + getDeclName().toString();
}

Fixed version (ground truth):
@Override public String toString(){
  return getKeyword() + "String_Node_Str" + getDeclName().toString();
}
Program: 2464
Project: 2464
Buggy source:
public static MessageSigDecl parseMessageSignatureDecl(ScribbleParser parser,CommonTree ct){
  CommonTree tmp1=getSchemaChild(ct);
  String schema=AntlrSimpleName.getName(tmp1);
  CommonTree tmp2=getExtNameChild(ct);
  String extName=AntlrExtIdentifier.getName(tmp2);
  CommonTree tmp3=getExtNameChild(ct);
  String source=AntlrExtIdentifier.getName(tmp3);
  MessageSigNameNode alias=AntlrSimpleName.toMessageSigNameNode(getAliasChild(ct));
  return ModelFactoryImpl.FACTORY.MessageSigDecl(schema,extName,source,alias);
}

Fixed version (ground truth):
public static MessageSigDecl parseMessageSignatureDecl(ScribbleParser parser,CommonTree ct){
  CommonTree tmp1=getSchemaChild(ct);
  String schema=AntlrSimpleName.getName(tmp1);
  CommonTree tmp2=getExtNameChild(ct);
  String extName=AntlrExtIdentifier.getName(tmp2);
  CommonTree tmp3=getSourceChild(ct);
  String source=AntlrExtIdentifier.getName(tmp3);
  MessageSigNameNode alias=AntlrSimpleName.toMessageSigNameNode(getAliasChild(ct));
  return ModelFactoryImpl.FACTORY.MessageSigDecl(schema,extName,source,alias);
}
Program: 2465
Project: 2465
Buggy source:
public ScribbleFsm build(){
  Set<ProtocolState> terms=this.init.findTerminals();
  if (terms.size() > 1) {
    throw new RuntimeException("String_Node_Str" + terms);
  }
  ProtocolState term=(terms.size() == 0) ? null : terms.iterator().next();
  ScribbleFsm f=new ScribbleFsm(this.init,term);
  this.init=null;
  return f;
}

Fixed version (ground truth):
public ScribbleFsm build(){
  ProtocolState term=validate();
  ScribbleFsm f=new ScribbleFsm(this.init,term);
  this.init=null;
  this.states.clear();
  return f;
}
Program: 2466
Project: 2466
Buggy source:
public ProtocolState makeInit(Set<RecVar> labs){
  if (this.init != null) {
    throw new RuntimeException("String_Node_Str");
  }
  this.init=new ProtocolState(labs);
  return this.init;
}

Fixed version (ground truth):
public ProtocolState makeInit(Set<RecVar> labs){
  if (this.init != null) {
    throw new RuntimeException("String_Node_Str");
  }
  this.init=newState(labs);
  return this.init;
}
Program: 2467
Project: 2467
Buggy source:
public void addEdge(ProtocolState s,MessageId op,ProtocolState succ){
  s.addEdge(op,succ);
}

Fixed version (ground truth):
public void addEdge(ProtocolState s,MessageId op,ProtocolState succ){
  if (!this.states.contains(s)) {
    throw new RuntimeException("String_Node_Str" + s);
  }
  if (!this.states.contains(succ)) {
    this.states.add(succ);
  }
  s.addEdge(op,succ);
}
Program: 2468
Project: 2468
Buggy source:
public ProtocolState newState(Set<RecVar> labs){
  return new ProtocolState(labs);
}

Fixed version (ground truth):
public ProtocolState newState(Set<RecVar> labs){
  ProtocolState s=new ProtocolState(labs);
  this.states.add(s);
  return s;
}
Program: 2469
Project: 2469
Buggy source:
public Set<RecVar> getLabels(){
  return this.labs;
}

Fixed version (ground truth):
public Set<RecVar> getLabels(){
  return new HashSet<>(this.labs);
}
Program: 2470
Project: 2470
Buggy source:
public Map<MessageId,ProtocolState> getEdges(){
  return this.edges;
}

Fixed version (ground truth):
protected Map<MessageId,ProtocolState> getEdges(){
  return this.edges;
}
Program: 2471
Project: 2471
Buggy source:
@Override public LInteractionSeq leaveFsmConversion(ModelNode parent,ModelNode child,FsmConverter conv,ModelNode visited){
  LInteractionSeq lis=(LInteractionSeq)visited;
  FsmBuilder b=new FsmBuilder();
  b.makeInit(Collections.emptySet());
  ScribbleFsm f=b.build();
  for (  InteractionNode<Local> li : lis.actions) {
    f=f.stitch(((FsmBuildingEnv)li.del().env()).getFsm());
  }
  FsmBuildingEnv env=conv.popEnv();
  conv.pushEnv(env.setFsm(f));
  return (LInteractionSeq)super.popAndSetVisitorEnv(parent,child,conv,lis);
}

Fixed version (ground truth):
@Override public LInteractionSeq leaveFsmConversion(ModelNode parent,ModelNode child,FsmConverter conv,ModelNode visited){
  LInteractionSeq lis=(LInteractionSeq)visited;
  FsmBuilder b=new FsmBuilder();
  ScribbleFsm f;
  if (lis.isEmpty()) {
    b.makeInit(Collections.emptySet());
    f=b.build();
  }
 else {
    f=((FsmBuildingEnv)lis.actions.get(0).del().env()).getFsm();
    for (    InteractionNode<Local> li : lis.actions.subList(1,lis.actions.size())) {
      f=f.stitch(((FsmBuildingEnv)li.del().env()).getFsm());
    }
  }
  FsmBuildingEnv env=conv.popEnv();
  conv.pushEnv(env.setFsm(f));
  return (LInteractionSeq)super.popAndSetVisitorEnv(parent,child,conv,lis);
}