Program: 170223
Project: 170223
Buggy source:
void excise(Enclosure enc,int tabno,String diagfn){
  clla=new LinkedList<Arrow>();
  Diagram oldDiag=enc.diag;
  driver.curDiag=this;
  maxBlockNo=Math.max(oldDiag.maxBlockNo,enc.id);
  enc.calcEdges();
  findEnclosedBlocksAndArrows(enc);
  for (  Block b : enc.llb) {
    blocks.put(new Integer(b.id),b);
    changed=true;
  }
  for (  Arrow a : enc.lla) {
    Arrow arr2=a.makeCopy(this);
    arrows.put(new Integer(arr2.id),arr2);
    changed=true;
  }
  findCrossingArrows(enc);
  if (enc.lla != null) {
    for (    Arrow arrow : enc.lla) {
      oldDiag.delArrow(arrow);
    }
    enc.lla=null;
  }
  boolean NOCHOOSE=false;
  if (enc.llb != null) {
    for (    Block block : enc.llb) {
      oldDiag.delBlock(block,NOCHOOSE);
    }
    enc.llb=null;
  }
  for (  Arrow arrow : arrows.values()) {
    Block from=blocks.get(new Integer(arrow.fromId));
    Block to=blocks.get(new Integer(arrow.toId));
    if (from == null) {
      ExtPortBlock eb=new ExtPortBlock(this);
      eb.cx=arrow.fromX - eb.width / 2;
      eb.cy=arrow.fromY;
      eb.type=Block.Types.EXTPORT_IN_BLOCK;
      maxBlockNo++;
      eb.id=maxBlockNo;
      arrow.fromId=eb.id;
      if (enc.subnetPorts != null) {
        for (        SubnetPort snp : enc.subnetPorts) {
          if (snp.side == Side.LEFT && arrow.toY == snp.y) {
            eb.substreamSensitive=snp.substreamSensitive;
            eb.description=snp.name;
          }
        }
      }
      blocks.put(new Integer(arrow.fromId),eb);
      eb.calcEdges();
    }
    if (to == null) {
      ExtPortBlock eb=new ExtPortBlock(this);
      eb.cx=arrow.toX + eb.width / 2;
      eb.cy=arrow.toY;
      eb.type=Block.Types.EXTPORT_OUT_BLOCK;
      maxBlockNo++;
      eb.id=maxBlockNo;
      arrow.toId=eb.id;
      if (enc.subnetPorts != null) {
        for (        SubnetPort snp : enc.subnetPorts) {
          if (snp.side == Side.RIGHT && arrow.toY == snp.y) {
            eb.substreamSensitive=snp.substreamSensitive;
            eb.description=snp.name;
          }
        }
      }
      blocks.put(new Integer(arrow.toId),eb);
      eb.calcEdges();
    }
  }
  Block block=new ProcessBlock(oldDiag);
  block.cx=oldDiag.xa;
  block.cy=oldDiag.ya;
  block.calcEdges();
  oldDiag.maxBlockNo++;
  block.id=oldDiag.maxBlockNo;
  oldDiag.blocks.put(new Integer(block.id),block);
  oldDiag.changed=true;
  driver.selBlock=block;
  block.diagramFileName=diagfn;
  block.isSubnet=true;
  block.description=enc.description;
  enc.description="String_Node_Str";
  desc=block.description;
  if (desc != null)   desc=desc.replace('\n',' ');
  block.cx=enc.cx;
  block.cy=enc.cy;
  block.calcEdges();
  driver.frame.repaint();
  Integer aid;
  for (  Arrow arrow : clla) {
    aid=new Integer(arrow.id);
    oldDiag.arrows.put(aid,arrow);
    Block from=oldDiag.blocks.get(new Integer(arrow.fromId));
    Block to=oldDiag.blocks.get(new Integer(arrow.toId));
    if (to == null) {
      arrow.toId=block.id;
      Side side=findQuadrant(arrow.fromX,arrow.fromY,block);
      if (side != null) {
        if (side == Side.TOP) {
          arrow.toY=block.cy - block.height / 2;
          arrow.toX=block.cx;
        }
 else {
          arrow.toX=block.cx - block.width / 2;
          arrow.toY=block.cy;
        }
      }
    }
    if (from == null) {
      arrow.fromId=block.id;
      Side side=findQuadrant(arrow.toX,arrow.toY,block);
      if (side != null) {
        if (side == Side.BOTTOM) {
          arrow.fromY=block.cy + block.height / 2;
          arrow.fromX=block.cx;
        }
 else {
          arrow.fromX=block.cx + block.width / 2;
          arrow.fromY=block.cy;
        }
      }
    }
  }
}

Fixed version (ground truth):
void excise(Enclosure enc,int tabno,String diagfn){
  clla=new LinkedList<Arrow>();
  Diagram oldDiag=enc.diag;
  driver.curDiag=this;
  maxBlockNo=Math.max(oldDiag.maxBlockNo,enc.id);
  enc.calcEdges();
  findEnclosedBlocksAndArrows(enc);
  for (  Block b : enc.llb) {
    blocks.put(new Integer(b.id),b);
    changed=true;
  }
  for (  Arrow a : enc.lla) {
    Arrow arr2=a.makeCopy(this);
    arrows.put(new Integer(arr2.id),arr2);
    changed=true;
  }
  findCrossingArrows(enc);
  if (enc.lla != null) {
    for (    Arrow arrow : enc.lla) {
      oldDiag.delArrow(arrow);
    }
    enc.lla=null;
  }
  boolean NOCHOOSE=false;
  if (enc.llb != null) {
    for (    Block block : enc.llb) {
      oldDiag.delBlock(block,NOCHOOSE);
    }
    enc.llb=null;
  }
  for (  Arrow arrow : arrows.values()) {
    Block from=blocks.get(new Integer(arrow.fromId));
    Block to=blocks.get(new Integer(arrow.toId));
    if (from == null) {
      ExtPortBlock eb=new ExtPortBlock(this);
      eb.cx=arrow.fromX - eb.width / 2;
      eb.cy=arrow.fromY;
      eb.type=Block.Types.EXTPORT_IN_BLOCK;
      maxBlockNo++;
      eb.id=maxBlockNo;
      arrow.fromId=eb.id;
      eb.description=arrow.downStreamPort;
      for (      SubnetPort snp : enc.subnetPorts) {
        if (snp.side == Side.LEFT && arrow.toY == snp.y) {
          eb.substreamSensitive=snp.substreamSensitive;
          eb.description=snp.name;
        }
      }
      blocks.put(new Integer(arrow.fromId),eb);
      eb.calcEdges();
    }
    if (to == null) {
      ExtPortBlock eb=new ExtPortBlock(this);
      eb.cx=arrow.toX + eb.width / 2;
      eb.cy=arrow.toY;
      eb.type=Block.Types.EXTPORT_OUT_BLOCK;
      maxBlockNo++;
      eb.id=maxBlockNo;
      arrow.toId=eb.id;
      eb.description=arrow.upStreamPort;
      for (      SubnetPort snp : enc.subnetPorts) {
        if (snp.side == Side.RIGHT && arrow.toY == snp.y) {
          eb.substreamSensitive=snp.substreamSensitive;
          eb.description=snp.name;
        }
      }
      blocks.put(new Integer(arrow.toId),eb);
      eb.calcEdges();
    }
  }
  Block block=new ProcessBlock(oldDiag);
  block.cx=oldDiag.xa;
  block.cy=oldDiag.ya;
  block.calcEdges();
  oldDiag.maxBlockNo++;
  block.id=oldDiag.maxBlockNo;
  oldDiag.blocks.put(new Integer(block.id),block);
  oldDiag.changed=true;
  driver.selBlock=block;
  block.diagramFileName=diagfn;
  block.isSubnet=true;
  block.description=enc.description;
  enc.description="String_Node_Str";
  desc=block.description;
  if (desc != null)   desc=desc.replace('\n',' ');
  block.cx=enc.cx;
  block.cy=enc.cy;
  block.calcEdges();
  driver.frame.repaint();
  Integer aid;
  for (  Arrow arrow : clla) {
    aid=new Integer(arrow.id);
    oldDiag.arrows.put(aid,arrow);
    Block from=oldDiag.blocks.get(new Integer(arrow.fromId));
    Block to=oldDiag.blocks.get(new Integer(arrow.toId));
    if (to == null) {
      arrow.toId=block.id;
      Side side=findQuadrant(arrow.fromX,arrow.fromY,block);
      if (side != null) {
        if (side == Side.TOP) {
          arrow.toY=block.cy - block.height / 2;
          arrow.toX=block.cx;
        }
 else {
          arrow.toX=block.cx - block.width / 2;
          arrow.toY=block.cy;
        }
      }
    }
    if (from == null) {
      arrow.fromId=block.id;
      Side side=findQuadrant(arrow.toX,arrow.toY,block);
      if (side != null) {
        if (side == Side.BOTTOM) {
          arrow.fromY=block.cy + block.height / 2;
          arrow.fromX=block.cx;
        }
 else {
          arrow.fromX=block.cx + block.width / 2;
          arrow.fromY=block.cy;
        }
      }
    }
  }
}