nus-yam/ex-repair huggingface dataset:
Program: 178211
Project: 178211
Buggy source:
private void getEvents(final Channel ch,final long eventId,int cnt){
  if (ch == null) {
    return;
  }
  HTSMessage request=new HTSMessage();
  request.setMethod("String_Node_Str");
  request.putField("String_Node_Str",eventId);
  request.putField("String_Node_Str",cnt);
  connection.sendMessage(request,new HTSResponseHandler(){
    public void handleResponse(    HTSMessage response){
      if (!response.containsKey("String_Node_Str")) {
        return;
      }
      TVHGuideApplication app=(TVHGuideApplication)getApplication();
      for (      Object obj : response.getList("String_Node_Str")) {
        Programme p=new Programme();
        HTSMessage sub=(HTSMessage)obj;
        p.id=sub.getLong("String_Node_Str");
        p.nextId=sub.getLong("String_Node_Str",0);
        p.description=sub.getString("String_Node_Str",null);
        p.ext_desc=sub.getString("String_Node_Str",p.description);
        p.recording=app.getRecording(response.getLong("String_Node_Str",0));
        p.type=sub.getInt("String_Node_Str",0);
        p.title=sub.getString("String_Node_Str");
        p.start=sub.getDate("String_Node_Str");
        p.stop=sub.getDate("String_Node_Str");
        p.channel=ch;
        if (ch.epg.add(p)) {
          app.addProgramme(p);
        }
      }
      app.updateChannel(ch);
    }
  }
);
}

Fixed version (ground truth):
private void getEvents(final Channel ch,final long eventId,int cnt){
  if (ch == null) {
    return;
  }
  HTSMessage request=new HTSMessage();
  request.setMethod("String_Node_Str");
  request.putField("String_Node_Str",eventId);
  request.putField("String_Node_Str",cnt);
  connection.sendMessage(request,new HTSResponseHandler(){
    public void handleResponse(    HTSMessage response){
      if (!response.containsKey("String_Node_Str")) {
        return;
      }
      TVHGuideApplication app=(TVHGuideApplication)getApplication();
      for (      Object obj : response.getList("String_Node_Str")) {
        Programme p=new Programme();
        HTSMessage sub=(HTSMessage)obj;
        p.id=sub.getLong("String_Node_Str");
        p.nextId=sub.getLong("String_Node_Str",0);
        p.description=sub.getString("String_Node_Str",null);
        p.ext_desc=sub.getString("String_Node_Str",p.description);
        p.recording=app.getRecording(sub.getLong("String_Node_Str",0));
        p.type=sub.getInt("String_Node_Str",0);
        p.title=sub.getString("String_Node_Str");
        p.start=sub.getDate("String_Node_Str");
        p.stop=sub.getDate("String_Node_Str");
        p.channel=ch;
        if (ch.epg.add(p)) {
          app.addProgramme(p);
        }
      }
      app.updateChannel(ch);
    }
  }
);
}
Program: 178213
Project: 178213
Buggy source:
public void onClick(View view){
  Programme p=null;
  Iterator<Programme> it=channel.epg.iterator();
  long nextId=0;
  while (it.hasNext()) {
    p=it.next();
    if (p.id != nextId && nextId != 0) {
      break;
    }
    nextId=p.nextId;
  }
  if (nextId == 0) {
    nextId=p.nextId;
  }
  if (nextId == 0) {
    nextId=p.id;
    return;
  }
  Intent intent=new Intent(ProgrammeListActivity.this,HTSService.class);
  intent.setAction(HTSService.ACTION_GET_EVENTS);
  intent.putExtra("String_Node_Str",nextId);
  intent.putExtra("String_Node_Str",channel.id);
  intent.putExtra("String_Node_Str",10);
  startService(intent);
}

Fixed version (ground truth):
public void onClick(View view){
  Programme p=null;
  Iterator<Programme> it=channel.epg.iterator();
  long nextId=0;
  while (it.hasNext()) {
    p=it.next();
    if (p.id != nextId && nextId != 0) {
      break;
    }
    nextId=p.nextId;
  }
  if (nextId == 0) {
    nextId=p.nextId;
  }
  if (nextId == 0) {
    nextId=p.id;
  }
  Intent intent=new Intent(ProgrammeListActivity.this,HTSService.class);
  intent.setAction(HTSService.ACTION_GET_EVENTS);
  intent.putExtra("String_Node_Str",nextId);
  intent.putExtra("String_Node_Str",channel.id);
  intent.putExtra("String_Node_Str",10);
  startService(intent);
}
Program: 178214
Project: 178214
Buggy source:
private List<Map<String,String>> fetchEvents(){
  GreenhouseOperations greenhouse=Prefs.getGreenhouseTemplate(getSharedPreferences(Prefs.PREFS,Context.MODE_PRIVATE));
  List<Event> upcomingEvents=greenhouse.getUpcomingEvents();
  List<Map<String,String>> eventList=new ArrayList<Map<String,String>>();
  for (  Event event : upcomingEvents) {
    Map<String,String> map=new HashMap<String,String>();
    map.put("String_Node_Str",event.getTitle());
    map.put("String_Node_Str",event.getGroupName());
    eventList.add(map);
  }
  return eventList;
}

Fixed version (ground truth):
private List<Map<String,String>> fetchEvents(){
  GreenhouseOperations greenhouse=Prefs.getGreenhouseOperations(getSharedPreferences(Prefs.PREFS,Context.MODE_PRIVATE));
  List<Event> upcomingEvents=greenhouse.getUpcomingEvents();
  List<Map<String,String>> eventList=new ArrayList<Map<String,String>>();
  for (  Event event : upcomingEvents) {
    Map<String,String> map=new HashMap<String,String>();
    map.put("String_Node_Str",event.getTitle());
    map.put("String_Node_Str",event.getGroupName());
    eventList.add(map);
  }
  return eventList;
}
Program: 178215
Project: 178215
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (getIntent().getData() == null) {
    try {
      _settings=getSharedPreferences(Prefs.PREFS,Context.MODE_PRIVATE);
      ServiceBuilder serviceBuilder=new ServiceBuilder();
      OAuthService oAuthService=serviceBuilder.apiKey(Prefs.getConsumerKey()).apiSecret(Prefs.getConsumerSecret()).provider(GreenhouseApi.class).callback(Prefs.CALLBACK_URI_STRING).build();
      Token requestToken=oAuthService.getRequestToken();
      Prefs.saveRequestInformation(_settings,requestToken.getToken(),requestToken.getSecret());
      startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("String_Node_Str" + requestToken.getToken())));
      finish();
    }
 catch (    Exception e) {
      Log.e("String_Node_Str",e.getMessage(),e);
      Writer result=new StringWriter();
      e.printStackTrace(new PrintWriter(result));
    }
  }
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (getIntent().getData() == null) {
    try {
      _settings=getSharedPreferences(Prefs.PREFS,Context.MODE_PRIVATE);
      ServiceBuilder serviceBuilder=new ServiceBuilder();
      OAuthService oAuthService=serviceBuilder.apiKey(Prefs.getConsumerKey()).apiSecret(Prefs.getConsumerSecret()).provider(GreenhouseApi.class).callback(Prefs.CALLBACK_URI_STRING).build();
      Token requestToken=oAuthService.getRequestToken();
      Prefs.saveRequestInformation(_settings,requestToken.getToken(),requestToken.getSecret());
      startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse(Prefs.getUrlBase() + "String_Node_Str" + requestToken.getToken())));
      finish();
    }
 catch (    Exception e) {
      Log.e("String_Node_Str",e.getMessage(),e);
      Writer result=new StringWriter();
      e.printStackTrace(new PrintWriter(result));
    }
  }
}
Program: 178216
Project: 178216
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.profile);
  final TextView textViewMemberName=(TextView)findViewById(R.id.profile_textview_member_name);
  final ImageView imageViewPicture=(ImageView)findViewById(R.id.profile_imageview_picture);
  final Button buttonSignOut=(Button)findViewById(R.id.profile_button_signout);
  GreenhouseOperations greenhouse=Prefs.getGreenhouseTemplate(getSharedPreferences(Prefs.PREFS,Context.MODE_PRIVATE));
  GreenhouseProfile profile=greenhouse.getUserProfile();
  textViewMemberName.setText(profile.getDisplayName());
  imageViewPicture.setImageURI(Uri.parse(profile.getPictureUrl()));
  buttonSignOut.setOnClickListener(new OnClickListener(){
    public void onClick(    View v){
      Prefs.disconnect(getSharedPreferences(Prefs.PREFS,Context.MODE_PRIVATE));
      Intent intent=new Intent(ProfileActivity.this,FrontDoorActivity.class);
      startActivity(intent);
      finish();
    }
  }
);
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.profile);
  final TextView textViewMemberName=(TextView)findViewById(R.id.profile_textview_member_name);
  final ImageView imageViewPicture=(ImageView)findViewById(R.id.profile_imageview_picture);
  final Button buttonSignOut=(Button)findViewById(R.id.profile_button_signout);
  GreenhouseOperations greenhouse=Prefs.getGreenhouseOperations(getSharedPreferences(Prefs.PREFS,Context.MODE_PRIVATE));
  GreenhouseProfile profile=greenhouse.getUserProfile();
  textViewMemberName.setText(profile.getDisplayName());
  imageViewPicture.setImageBitmap(getImageBitmap(profile.getPictureUrl()));
  buttonSignOut.setOnClickListener(new OnClickListener(){
    public void onClick(    View v){
      Prefs.disconnect(getSharedPreferences(Prefs.PREFS,Context.MODE_PRIVATE));
      Intent intent=new Intent(ProfileActivity.this,FrontDoorActivity.class);
      startActivity(intent);
      finish();
    }
  }
);
}
Program: 178217
Project: 178217
Buggy source:
@Override public String getAccessTokenEndpoint(){
  return "String_Node_Str";
}

Fixed version (ground truth):
@Override public String getAccessTokenEndpoint(){
  return Prefs.getUrlBase() + "String_Node_Str";
}
Program: 178218
Project: 178218
Buggy source:
@Override public String getRequestTokenEndpoint(){
  return "String_Node_Str";
}

Fixed version (ground truth):
@Override public String getRequestTokenEndpoint(){
  return Prefs.getUrlBase() + "String_Node_Str";
}
Program: 178219
Project: 178219
Buggy source:
public static void disconnect(final SharedPreferences settings){
  SharedPreferences.Editor editor=settings.edit();
  editor.remove(ACCESS_TOKEN);
  editor.remove(ACCESS_TOKEN_SECRET);
  editor.commit();
}

Fixed version (ground truth):
public static void disconnect(final SharedPreferences settings){
  SharedPreferences.Editor editor=settings.edit();
  editor.remove(ACCESS_TOKEN);
  editor.remove(ACCESS_TOKEN_SECRET);
  editor.commit();
  greenhouseOperations=null;
}
Program: 178220
Project: 178220
Buggy source:
private static String getUrlBase(){
  return GREENHOUSE_SERVER_BASE_URL;
}

Fixed version (ground truth):
public static String getUrlBase(){
  return GREENHOUSE_SERVER_BASE_URL;
}
Program: 178221
Project: 178221
Buggy source:
/** 
 * Hatch all the polygons parallel to line hp with increment gap
 * @param hp
 * @param gap
 * @param a
 * @return a polygon list of hatch lines as the result with attributes a
 */
public RrPolygonList hatch(RrHalfPlane hp,double gap,Attributes a){
  push("String_Node_Str");
  RrRectangle big=box().scale(1.1);
  double d=Math.sqrt(big.dSquared());
  Rr2Point orth=hp.normal();
  int quadPointing=(int)(2 + 2 * Math.atan2(orth.y(),orth.x()) / Math.PI);
  Rr2Point org=big.ne();
switch (quadPointing) {
case 1:
    org=big.nw();
  break;
case 2:
org=big.sw();
break;
case 3:
org=big.se();
break;
case 0:
default :
break;
}
RrHalfPlane hatcher=new RrHalfPlane(org,Rr2Point.add(org,hp.pLine().direction()));
List<RrHalfPlane> hatches=new ArrayList<RrHalfPlane>();
iPolygonList iHatches=new iPolygonList();
double g=0;
while (g < d) {
iPolygon ip=hatch(hatcher);
if (ip.size() > 0) {
hatches.add(hatcher);
iHatches.add(ip);
}
hatcher=hatcher.offset(gap);
g+=gap;
}
iPolygonList snakes=new iPolygonList();
int segment;
do {
segment=-1;
for (int i=0; i < iHatches.size(); i++) {
if ((iHatches.polygon(i)).size() > 0) {
segment=i;
break;
}
}
if (segment >= 0) {
snakes.add(snakeGrow(iHatches,hatches,segment,0));
}
}
 while (segment >= 0);
try {
if (Preferences.loadGlobalBool("String_Node_Str")) joinUpSnakes(snakes,hatches,gap);
}
 catch (Exception e) {
}
resetVisited();
RrPolygonList result=snakes.realPolygons(a).simplify(realResolution);
pop();
return result;
}

Fixed version (ground truth):
/** 
 * Hatch all the polygons parallel to line hp with increment gap
 * @param hp
 * @param gap
 * @param a
 * @return a polygon list of hatch lines as the result with attributes a
 */
public RrPolygonList hatch(RrHalfPlane hp,double gap,Attributes a){
  if (gap <= 0)   return new RrPolygonList();
  RrRectangle big=box().scale(1.1);
  double d=Math.sqrt(big.dSquared());
  Rr2Point orth=hp.normal();
  int quadPointing=(int)(2 + 2 * Math.atan2(orth.y(),orth.x()) / Math.PI);
  Rr2Point org=big.ne();
switch (quadPointing) {
case 1:
    org=big.nw();
  break;
case 2:
org=big.sw();
break;
case 3:
org=big.se();
break;
case 0:
default :
break;
}
RrHalfPlane hatcher=new RrHalfPlane(org,Rr2Point.add(org,hp.pLine().direction()));
List<RrHalfPlane> hatches=new ArrayList<RrHalfPlane>();
iPolygonList iHatches=new iPolygonList();
double g=0;
while (g < d) {
iPolygon ip=hatch(hatcher);
if (ip.size() > 0) {
hatches.add(hatcher);
iHatches.add(ip);
}
hatcher=hatcher.offset(gap);
g+=gap;
}
iPolygonList snakes=new iPolygonList();
int segment;
do {
segment=-1;
for (int i=0; i < iHatches.size(); i++) {
if ((iHatches.polygon(i)).size() > 0) {
segment=i;
break;
}
}
if (segment >= 0) {
snakes.add(snakeGrow(iHatches,hatches,segment,0));
}
}
 while (segment >= 0);
try {
if (Preferences.loadGlobalBool("String_Node_Str")) joinUpSnakes(snakes,hatches,gap);
}
 catch (Exception e) {
}
resetVisited();
RrPolygonList result=snakes.realPolygons(a).simplify(realResolution);
return result;
}
Program: 178223
Project: 178223
Buggy source:
/** 
 * Turn the cooler (fan?) on or off
 * @param f true if the cooler is to be turned on, false to turn off
 * @throws IOException
 * @throws Exception 
 */
public void setCooler(boolean f) throws IOException, Exception ;

Fixed version (ground truth):
/** 
 * Turn the cooler (fan?) on or off
 * @param f true if the cooler is to be turned on, false to turn off
 * @throws IOException
 * @throws Exception 
 */
public void setCooler(boolean f,boolean really) throws IOException, Exception ;
Program: 178224
Project: 178224
Buggy source:
/** 
 * Zero the extruded length
 * @throws Exception 
 */
public void zeroExtrudedLength() throws Exception ;

Fixed version (ground truth):
/** 
 * Zero the extruded length
 * @throws Exception 
 */
public void zeroExtrudedLength(boolean really) throws Exception ;
Program: 178225
Project: 178225
Buggy source:
/** 
 * Indicates end of job, homes extruder, powers down etc
 * @throws Exception
 */
public void terminate() throws Exception ;

Fixed version (ground truth):
/** 
 * Indicates end of job, homes extruder, powers down etc
 * @throws Exception
 */
public void terminate(LayerRules layerRules) throws Exception ;
Program: 178226
Project: 178226
Buggy source:
/** 
 * Single move for when we're moving about giong places rather than making
 * @param x
 * @param y
 * @param z
 * @param feedrate
 */
public void singleMove(double x,double y,double z,double feedrate);

Fixed version (ground truth):
/** 
 * Single move for when we're moving about giong places rather than making
 * @param x
 * @param y
 * @param z
 * @param feedrate
 */
public void singleMove(double x,double y,double z,double feedrate,boolean really);
Program: 178227
Project: 178227
Buggy source:
/** 
 * Home XY and zero all extruders
 * @throws ReprapException
 * @throws IOException
 * @throws Exception 
 */
public void homeToZeroXYE() throws ReprapException, IOException, Exception ;

Fixed version (ground truth):
/** 
 * Home XY and zero all extruders
 * @throws ReprapException
 * @throws IOException
 * @throws Exception 
 */
public void homeToZeroXYE(boolean really) throws ReprapException, IOException, Exception ;
Program: 178228
Project: 178228
Buggy source:
/** 
 * All machine dwells and delays are routed via this function, rather than  calling Thread.sleep - this allows them to generate the right G codes (G4) etc. The RS232/USB etc comms system doesn't use this - it sets its own delays.
 * @param milliseconds
 * @throws Exception 
 */
public void machineWait(double milliseconds,boolean fastExtrude) throws Exception ;

Fixed version (ground truth):
/** 
 * All machine dwells and delays are routed via this function, rather than  calling Thread.sleep - this allows them to generate the right G codes (G4) etc. The RS232/USB etc comms system doesn't use this - it sets its own delays.
 * @param milliseconds
 * @throws Exception 
 */
public void machineWait(double milliseconds,boolean fastExtrude,boolean really) throws Exception ;
Program: 178229
Project: 178229
Buggy source:
/** 
 * Select a specific material to print with
 * @param extr identifier of the material
 * @throws Exception 
 */
public void selectExtruder(int extr) throws Exception ;

Fixed version (ground truth):
/** 
 * Select a specific material to print with
 * @param extr identifier of the material
 * @throws Exception 
 */
public void selectExtruder(int extr,boolean really) throws Exception ;
Program: 178234
Project: 178234
Buggy source:
/** 
 * @param prefs
 * @throws Exception
 */
public GCodeRepRap() throws Exception {
  super();
  gcode=new GCodeReaderAndWriter();
  gcode.queue("String_Node_Str");
  gcode.queue("String_Node_Str");
  String FirmwareConfig=gcode.lastResponse();
  FirmwareConfig=FirmwareConfig.replace('\\','\n');
  Debug.d("String_Node_Str" + FirmwareConfig);
  loadExtruders();
  forceSelection=true;
}

Fixed version (ground truth):
/** 
 * @param prefs
 * @throws Exception
 */
public GCodeRepRap() throws Exception {
  super();
  gcode=new GCodeReaderAndWriter();
  gcode.queue("String_Node_Str");
  loadExtruders();
  forceSelection=true;
}
Program: 178236
Project: 178236
Buggy source:
/** 
 * Gets the number of milliseconds to wait before opening the valve for the first track of a layer
 * @return
 */
public double getValveDelayForLayer(){
  return valveDelayForLayer;
}

Fixed version (ground truth):
/** 
 * Gets the number of milliseconds to wait before opening the valve for the first track of a layer
 * @return
 */
public double getValveDelayForLayer(){
  if (valvePulseTime < 0)   return 0;
  return valveDelayForLayer;
}
Program: 178237
Project: 178237
Buggy source:
/** 
 * Gets the number of milliseconds to wait before opening the valve for any other track
 * @return
 */
public double getValveDelayForPolygon(){
  return valveDelayForPolygon;
}

Fixed version (ground truth):
/** 
 * Gets the number of milliseconds to wait before opening the valve for any other track
 * @return
 */
public double getValveDelayForPolygon(){
  if (valvePulseTime < 0)   return 0;
  return valveDelayForPolygon;
}
Program: 178238
Project: 178238
Buggy source:
/** 
 * @return the valve overrun in millimeters (i.e. how many mmbefore the end of a track to turn off the extrude motor)
 */
public double getValveOverRun(){
  return valveOverRun;
}

Fixed version (ground truth):
/** 
 * @return the valve overrun in millimeters (i.e. how many mmbefore the end of a track to turn off the extrude motor)
 */
public double getValveOverRun(){
  if (valvePulseTime < 0)   return 0;
  return valveOverRun;
}
Program: 178241
Project: 178241
Buggy source:
/** 
 * Compute the intersection of two  bit patterns
 * @param d
 * @param e
 * @return
 */
public static BooleanGrid intersection(BooleanGrid d,BooleanGrid e){
  if (d.att != e.att)   Debug.e("String_Node_Str" + d.attribute().getMaterial() + "String_Node_Str"+ e.attribute().getMaterial());
  return intersection(d,e,d.att);
}

Fixed version (ground truth):
/** 
 * Compute the intersection of two  bit patterns
 * @param d
 * @param e
 * @return
 */
public static BooleanGrid intersection(BooleanGrid d,BooleanGrid e){
  BooleanGrid result=intersection(d,e,d.att);
  if (result != nothingThere && d.att != e.att)   Debug.e("String_Node_Str" + d.attribute().getMaterial() + "String_Node_Str"+ e.attribute().getMaterial());
  return result;
}
Program: 178242
Project: 178242
Buggy source:
/** 
 * Grid d - grid e d's rectangle is presumed to contain the result. TODO: write a function to compute the rectangle from the bitmap
 * @param d
 * @param e
 * @return
 */
public static BooleanGrid difference(BooleanGrid d,BooleanGrid e){
  if (d.att != e.att)   Debug.e("String_Node_Str" + d.attribute().getMaterial() + "String_Node_Str"+ e.attribute().getMaterial());
  return difference(d,e,d.att);
}

Fixed version (ground truth):
/** 
 * Grid d - grid e d's rectangle is presumed to contain the result. TODO: write a function to compute the rectangle from the bitmap
 * @param d
 * @param e
 * @return
 */
public static BooleanGrid difference(BooleanGrid d,BooleanGrid e){
  BooleanGrid result=difference(d,e,d.att);
  if (result != nothingThere && d.att != e.att)   Debug.e("String_Node_Str" + d.attribute().getMaterial() + "String_Node_Str"+ e.attribute().getMaterial());
  return result;
}
Program: 178243
Project: 178243
Buggy source:
/** 
 * Compute the union of two bit patterns
 * @param d
 * @param e
 * @return
 */
public static BooleanGrid union(BooleanGrid d,BooleanGrid e){
  if (d.att != e.att)   Debug.e("String_Node_Str" + d.attribute().getMaterial() + "String_Node_Str"+ e.attribute().getMaterial());
  return union(d,e,d.att);
}

Fixed version (ground truth):
/** 
 * Compute the union of two bit patterns
 * @param d
 * @param e
 * @return
 */
public static BooleanGrid union(BooleanGrid d,BooleanGrid e){
  BooleanGrid result=union(d,e,d.att);
  if (result != nothingThere && d.att != e.att)   Debug.e("String_Node_Str" + d.attribute().getMaterial() + "String_Node_Str"+ e.attribute().getMaterial());
  return result;
}
Program: 178244
Project: 178244
Buggy source:
/** 
 * Work out all the open polygons forming a set of infill hatches.  If surface is true, these polygons are on the outside (top or bottom).  If it's false they are in the interior.  If overrideDirection is not null, that is used as the hatch direction.  Otherwise the hatch is provided by layerConditions.
 * @param layerConditions
 * @param surface
 * @param overrideDirection
 * @return
 */
public RrPolygonList hatch(LayerRules layerConditions,boolean surface,RrHalfPlane overrideDirection){
  RrPolygonList result=new RrPolygonList();
  boolean foundation=layerConditions.getLayingSupport();
  Extruder[] es=layerConditions.getPrinter().getExtruders();
  for (int i=0; i < size(); i++) {
    Extruder e;
    Attributes att=attribute(i);
    if (foundation)     e=es[0];
 else     e=att.getExtruder();
    Extruder ei;
    if (!surface) {
      ei=e.getInfillExtruder();
      if (ei != null)       att=new Attributes(ei.getMaterial(),null,null,ei.getAppearance());
    }
 else     ei=e;
    if (ei != null) {
      RrHalfPlane hatchLine=layerConditions.getHatchDirection(ei);
      if (overrideDirection != null)       hatchLine=overrideDirection;
      result.add(get(i).hatch(hatchLine,layerConditions.getHatchWidth(ei),att));
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Work out all the open polygons forming a set of infill hatches.  If surface is true, these polygons are on the outside (top or bottom).  If it's false they are in the interior.  If overrideDirection is not null, that is used as the hatch direction.  Otherwise the hatch is provided by layerConditions.
 * @param layerConditions
 * @param surface
 * @param overrideDirection
 * @return
 */
public RrPolygonList hatch(LayerRules layerConditions,boolean surface,RrHalfPlane overrideDirection){
  RrPolygonList result=new RrPolygonList();
  boolean foundation=layerConditions.getLayingSupport();
  Extruder[] es=layerConditions.getPrinter().getExtruders();
  for (int i=0; i < size(); i++) {
    Extruder e;
    Attributes att=attribute(i);
    if (foundation)     e=es[0];
 else     e=att.getExtruder();
    Extruder ei;
    if (!surface) {
      ei=e.getInfillExtruder();
      if (ei != null)       att=new Attributes(ei.getMaterial(),null,null,ei.getAppearance());
    }
 else     ei=e;
    if (ei != null) {
      RrHalfPlane hatchLine;
      if (overrideDirection != null)       hatchLine=overrideDirection;
 else       hatchLine=layerConditions.getHatchDirection(ei);
      result.add(get(i).hatch(hatchLine,layerConditions.getHatchWidth(ei),att));
    }
  }
  return result;
}
Program: 178245
Project: 178245
Buggy source:
/** 
 * @param startX
 * @param startY
 * @param startZ
 * @param endX
 * @param endY
 * @param endZ
 * @throws ReprapException
 * @throws IOException
 * @throws Exception 
 */
public void moveTo(double x,double y,double z,double feedRate,boolean startUp,boolean endUp) throws ReprapException, IOException, Exception {
  if (isCancelled())   return;
  totalDistanceMoved+=segmentLength(x - currentX,y - currentY);
  if (z != currentZ)   totalDistanceMoved+=Math.abs(currentZ - z);
  currentX=x;
  currentY=y;
  currentZ=z;
  XYEAtZero=false;
}

Fixed version (ground truth):
public void moveTo(double x,double y,double z,double feedRate,boolean startUp,boolean endUp) throws ReprapException, IOException, Exception {
  if (isCancelled())   return;
  checkCoordinates(x,y,z);
  totalDistanceMoved+=segmentLength(x - currentX,y - currentY);
  if (z != currentZ)   totalDistanceMoved+=Math.abs(currentZ - z);
  currentX=x;
  currentY=y;
  currentZ=z;
  XYEAtZero=false;
}
Program: 178246
Project: 178246
Buggy source:
public void homeToZeroXYE() throws Exception {
  if (XYEAtZero)   return;
  homeToZeroX();
  homeToZeroY();
  int extruderNow=extruder;
  for (int i=0; i < extruders.length; i++) {
    if (extruders[i].getExtruderState().length() > 0) {
      selectExtruder(i);
      extruders[i].zeroExtrudedLength();
    }
  }
  selectExtruder(extruderNow);
  XYEAtZero=true;
  super.homeToZeroXYE();
}

Fixed version (ground truth):
public void homeToZeroXYE() throws Exception {
  if (XYEAtZero)   return;
  homeToZeroX();
  homeToZeroY();
  int extruderNow=extruder;
  for (int i=0; i < extruders.length; i++) {
    selectExtruder(i);
    extruders[i].zeroExtrudedLength();
  }
  selectExtruder(extruderNow);
  XYEAtZero=true;
  super.homeToZeroXYE();
}
Program: 178248
Project: 178248
Buggy source:
/** 
 * Just about to start the next layer
 * @param lc
 */
public void startingLayer(LayerRules lc) throws Exception {
  lc.setFractionDone();
  if (lc.getMachineLayer() > 0)   homeToZeroXYE();
  double datumX=getExtruder().getNozzleWipeDatumX();
  double datumY=getExtruder().getNozzleWipeDatumY();
  double strokeY=getExtruder().getNozzleWipeStrokeY();
  double clearTime=getExtruder().getNozzleClearTime();
  double waitTime=getExtruder().getNozzleWaitTime();
  double coolTime=getExtruder().getCoolingPeriod();
  if (layerPauseCheckbox != null && layerPauseCheckbox.isSelected())   layerPause();
  if (isCancelled()) {
    getExtruder().setCooler(false);
    getExtruder().stopExtruding();
    return;
  }
  double cool=Timer.elapsed();
  if (startCooling >= 0)   cool=cool - startCooling;
 else   cool=0;
  if (startCooling >= 0) {
    cool=coolTime - cool;
    machineWait(1000 * cool,false);
  }
  getExtruder().setCooler(false);
  if (startCooling >= 0) {
    machineWait(200 * coolTime,false);
    Debug.d("String_Node_Str");
  }
  if (getExtruder().getNozzleWipeEnabled()) {
    singleMove(datumX,datumY,currentZ,getExtruder().getOutlineFeedrate());
    if (clearTime > 0) {
      getExtruder().setValve(true);
      getExtruder().setMotor(true);
      machineWait(1000 * clearTime,false);
      getExtruder().setMotor(false);
      getExtruder().setValve(false);
      machineWait(1000 * waitTime,false);
    }
    singleMove(datumX,datumY + strokeY,currentZ,currentFeedrate);
  }
  lc.moveZAtStartOfLayer();
}

Fixed version (ground truth):
/** 
 * Just about to start the next layer
 * @param lc
 */
public void startingLayer(LayerRules lc) throws Exception {
  lc.setFractionDone();
  if (lc.getMachineLayer() > 0 && Preferences.loadGlobalBool("String_Node_Str"))   homeToZeroXYE();
  double datumX=getExtruder().getNozzleWipeDatumX();
  double datumY=getExtruder().getNozzleWipeDatumY();
  double strokeY=getExtruder().getNozzleWipeStrokeY();
  double clearTime=getExtruder().getNozzleClearTime();
  double waitTime=getExtruder().getNozzleWaitTime();
  double coolTime=getExtruder().getCoolingPeriod();
  if (layerPauseCheckbox != null && layerPauseCheckbox.isSelected())   layerPause();
  if (isCancelled()) {
    getExtruder().setCooler(false);
    getExtruder().stopExtruding();
    return;
  }
  double cool=Timer.elapsed();
  if (startCooling >= 0)   cool=cool - startCooling;
 else   cool=0;
  if (startCooling >= 0) {
    cool=coolTime - cool;
    machineWait(1000 * cool,false);
  }
  if (coolTime > 0)   getExtruder().setCooler(false);
  if (getExtruder().getNozzleWipeEnabled()) {
    singleMove(datumX,datumY,currentZ,getExtruder().getOutlineFeedrate());
    if (clearTime > 0) {
      getExtruder().setValve(true);
      getExtruder().setMotor(true);
      machineWait(1000 * clearTime,false);
      getExtruder().setMotor(false);
      getExtruder().setValve(false);
      machineWait(1000 * waitTime,false);
    }
    singleMove(datumX,datumY + strokeY,currentZ,currentFeedrate);
  }
  lc.moveZAtStartOfLayer();
}
Program: 178249
Project: 178249
Buggy source:
private void createBitmap(){
  gerberGcode=new GerberGCode(pcbPen,null,true);
  bigBox=new RrRectangle();
  try {
    in=new BufferedReader(new FileReader(inputTracksAndPads));
    while ((line=in.readLine()) != null) {
      RrRectangle r=processLine(line,false);
      if (r != null)       bigBox=RrRectangle.union(bigBox,r);
    }
    in.close();
    PCBOffsets.pcbo(bigBox);
    offsetX=PCBOffsets.getXoff() - bigBox.sw().x();
    offsetY=PCBOffsets.getYoff() - bigBox.sw().y();
    bigBox=bigBox.translate(new Rr2Point(PCBOffsets.getXoff(),PCBOffsets.getYoff()));
    in=new BufferedReader(new FileReader(inputTracksAndPads));
    BooleanGrid pattern=new BooleanGrid(RrCSG.nothing(),bigBox,new Attributes(null,null,null,pcbPen.getAppearance()));
    gerberGcode=new GerberGCode(pcbPen,pattern,true);
    while ((line=in.readLine()) != null) {
      processLine(line,false);
    }
    if (inputDrill != null) {
      in=new BufferedReader(new FileReader(inputDrill));
      gerberGcode=new GerberGCode(pcbPen,pattern,false);
      gerberGcode.addCircleAperture(-1,centreWidth);
      while ((line=in.readLine()) != null) {
        processLine(line,true);
      }
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
private void createBitmap(){
  gerberGcode=new GerberGCode(pcbPen,null,true);
  bigBox=new RrRectangle();
  RrRectangle r;
  try {
    in=new BufferedReader(new FileReader(inputTracksAndPads));
    while ((line=in.readLine()) != null) {
      r=processLine(line,false);
      if (r != null)       bigBox=RrRectangle.union(bigBox,r);
    }
    in.close();
    PCBOffsets.pcbo(bigBox);
    offsetX=PCBOffsets.getXoff() - bigBox.sw().x();
    offsetY=PCBOffsets.getYoff() - bigBox.sw().y();
    bigBox=bigBox.translate(new Rr2Point(offsetX,offsetY));
    in=new BufferedReader(new FileReader(inputTracksAndPads));
    BooleanGrid pattern=new BooleanGrid(RrCSG.nothing(),bigBox,new Attributes(null,null,null,pcbPen.getAppearance()));
    gerberGcode=new GerberGCode(pcbPen,pattern,true);
    while ((line=in.readLine()) != null) {
      processLine(line,false);
    }
    if (inputDrill != null) {
      in=new BufferedReader(new FileReader(inputDrill));
      gerberGcode=new GerberGCode(pcbPen,pattern,false);
      gerberGcode.addCircleAperture(-1,centreWidth);
      while ((line=in.readLine()) != null) {
        processLine(line,true);
      }
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
Program: 178250
Project: 178250
Buggy source:
/** 
 * Deep copy - NB: attributes _not_ deep copied
 * @param p
 */
public RrPolygon(RrPolygon p){
  this(p.att,p.closed);
  for (int i=0; i < p.size(); i++)   add(new Rr2Point(p.point(i)));
  if (p.speeds != null) {
    speeds=new ArrayList<Double>();
    for (int i=0; i < p.size(); i++)     speeds.add(new Double(p.speed(i)));
  }
  closed=p.closed;
}

Fixed version (ground truth):
/** 
 * Deep copy - NB: attributes _not_ deep copied
 * @param p
 */
public RrPolygon(RrPolygon p){
  this(p.att,p.closed);
  for (int i=0; i < p.size(); i++)   add(new Rr2Point(p.point(i)));
  if (p.speeds != null) {
    speeds=new ArrayList<Double>();
    for (int i=0; i < p.size(); i++)     speeds.add(new Double(p.speed(i)));
  }
  closed=p.closed;
  drawEnd=p.drawEnd;
}
Program: 178251
Project: 178251
Buggy source:
/** 
 * Find the nearest vertex on this polygon to any on polygon p, reorder p so that its nearest is its first one, then merge that polygon into this one.  The reordering is only done if the distance^2 is less  than linkUp.  If no reordering and merging are done false is returned,  otherwise true is returned.
 * @param p
 * @param linkUp
 * @return
 */
public boolean nearestVertexReorderMerge(RrPolygon p,double linkUp){
  if (!p.isClosed())   Debug.e("String_Node_Str");
  double d=Double.POSITIVE_INFINITY;
  int myPoint=-1;
  int itsPoint=-1;
  for (int i=0; i < size(); i++) {
    int j=p.nearestVertex(point(i));
    double d2=Rr2Point.dSquared(point(i),p.point(j));
    if (d2 < d) {
      d=d2;
      myPoint=i;
      itsPoint=j;
    }
  }
  if (itsPoint >= 0 && d < linkUp * linkUp) {
    RrPolygon ro=p.newStart(itsPoint);
    ro.add(0,point(myPoint));
    add(myPoint,ro);
    return true;
  }
 else   return false;
}

Fixed version (ground truth):
/** 
 * Find the nearest vertex on this polygon to any on polygon p, reorder p so that its nearest is its first one, then merge that polygon into this one.  The reordering is only done if the distance^2 is less  than linkUp.  If no reordering and merging are done false is returned,  otherwise true is returned.
 * @param p
 * @param linkUp
 * @return
 */
public boolean nearestVertexReorderMerge(RrPolygon p,double linkUp){
  if (!p.isClosed())   Debug.e("String_Node_Str");
  if (drawEnd >= 0 || p.drawEnd >= 0)   Debug.e("String_Node_Str");
  if (drawEnd >= 0)   Debug.e("String_Node_Str");
  double d=Double.POSITIVE_INFINITY;
  int myPoint=-1;
  int itsPoint=-1;
  for (int i=0; i < size(); i++) {
    int j=p.nearestVertex(point(i));
    double d2=Rr2Point.dSquared(point(i),p.point(j));
    if (d2 < d) {
      d=d2;
      myPoint=i;
      itsPoint=j;
    }
  }
  if (itsPoint >= 0 && d < linkUp * linkUp) {
    RrPolygon ro=p.newStart(itsPoint);
    ro.add(0,point(myPoint));
    add(myPoint,ro);
    return true;
  }
 else   return false;
}
Program: 178252
Project: 178252
Buggy source:
/** 
 * @return same polygon, but starting at vertex i
 */
public RrPolygon newStart(int i){
  if (!isClosed())   Debug.e("String_Node_Str");
  if (i < 0 || i >= size()) {
    Debug.e("String_Node_Str" + i);
    return this;
  }
  RrPolygon result=new RrPolygon(att,closed);
  for (int j=0; j < size(); j++) {
    result.add(point(i));
    if (speeds != null)     result.setSpeed(j,speed(i));
    i++;
    if (i >= size())     i=0;
  }
  return result;
}

Fixed version (ground truth):
/** 
 * @return same polygon, but starting at vertex i
 */
public RrPolygon newStart(int i){
  if (!isClosed())   Debug.e("String_Node_Str");
  if (drawEnd >= 0)   Debug.e("String_Node_Str");
  if (i < 0 || i >= size()) {
    Debug.e("String_Node_Str" + i);
    return this;
  }
  RrPolygon result=new RrPolygon(att,closed);
  for (int j=0; j < size(); j++) {
    result.add(point(i));
    if (speeds != null)     result.setSpeed(j,speed(i));
    i++;
    if (i >= size())     i=0;
  }
  return result;
}
Program: 178253
Project: 178253
Buggy source:
/** 
 * Put a new polygon in the middle (at vertex k, which will be at the end of the inserted polygon afterwards). (N.B. Attributes of the new polygon are ignored)
 * @param k
 * @param p
 */
public void add(int k,RrPolygon p){
  if (p.size() == 0)   return;
  if (speeds != p.speeds) {
    Debug.e("String_Node_Str");
    return;
  }
  for (int i=0; i < p.size(); i++) {
    if (speeds != null)     add(k,new Rr2Point(p.point(i)),p.speed(i));
 else     points.add(k,new Rr2Point(p.point(i)));
    k++;
  }
  box.expand(p.box);
}

Fixed version (ground truth):
/** 
 * Put a new polygon in the middle (at vertex k, which will be at the end of the inserted polygon afterwards). (N.B. Attributes of the new polygon are ignored)
 * @param k
 * @param p
 */
public void add(int k,RrPolygon p){
  if (p.size() == 0)   return;
  if (speeds != p.speeds) {
    Debug.e("String_Node_Str");
    return;
  }
  if (k <= drawEnd)   Debug.e("String_Node_Str");
  int de=-1;
  if (drawEnd >= 0)   de=drawEnd + p.size();
  for (int i=0; i < p.size(); i++) {
    if (i == p.drawEnd)     drawEnd=size();
    if (speeds != null)     add(k,new Rr2Point(p.point(i)),p.speed(i));
 else     points.add(k,new Rr2Point(p.point(i)));
    k++;
  }
  drawEnd=Math.max(drawEnd,de);
  box.expand(p.box);
}
Program: 178254
Project: 178254
Buggy source:
/** 
 * @return same polygon starting at point incremented from last polygon
 */
public RrPolygon incrementedStart(LayerRules lc){
  if (size() == 0 || lc.getModelLayer() < 0)   return this;
  int i=lc.getModelLayer() % size();
  return newStart(i);
}

Fixed version (ground truth):
/** 
 * @return same polygon starting at point incremented from last polygon
 */
public RrPolygon incrementedStart(LayerRules lc){
  if (size() == 0 || lc.getModelLayer() < 0)   return this;
  if (drawEnd >= 0)   Debug.e("String_Node_Str");
  int i=lc.getModelLayer() % size();
  return newStart(i);
}
Program: 178255
Project: 178255
Buggy source:
/** 
 * Negate (i.e. reverse cyclic order)
 * @return reversed polygon object
 */
public RrPolygon negate(){
  RrPolygon result=new RrPolygon(att,closed);
  for (int i=size() - 1; i >= 0; i--) {
    result.add(point(i));
  }
  if (speeds == null)   return result;
  for (int i=size() - 1; i >= 0; i--) {
    result.setSpeed(i,speed(i));
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Negate (i.e. reverse cyclic order)
 * @return reversed polygon object
 */
public RrPolygon negate(){
  if (drawEnd >= 0)   Debug.e("String_Node_Str");
  RrPolygon result=new RrPolygon(att,closed);
  for (int i=size() - 1; i >= 0; i--) {
    result.add(point(i));
  }
  if (speeds == null)   return result;
  for (int i=size() - 1; i >= 0; i--) {
    result.setSpeed(i,speed(i));
  }
  return result;
}
Program: 178256
Project: 178256
Buggy source:
/** 
 * Backtrack a given distance, inserting a new point there and returning its index
 * @param distance to backtrack
 * @return index of the inserted point
 */
public int backStep(double d){
  Rr2Point last, p;
  int start=size() - 1;
  if (isClosed())   last=point(0);
 else {
    last=point(start);
    start--;
  }
  double sum=0;
  for (int i=start; i >= 0; i--) {
    p=point(i);
    sum+=Rr2Point.d(p,last);
    if (sum > d) {
      sum=sum - d;
      p=Rr2Point.sub(last,p);
      sum=sum / p.mod();
      p=Rr2Point.add(point(i),Rr2Point.mul(sum,p));
      int j=i + 1;
      if (j < size()) {
        points.add(j,p);
        if (speeds != null)         speeds.add(j,new Double(0));
      }
 else {
        points.add(p);
        if (speeds != null)         speeds.add(new Double(0));
      }
      return (j);
    }
    last=p;
  }
  return 0;
}

Fixed version (ground truth):
/** 
 * Backtrack a given distance, inserting a new point there and set drawEnd to it. If drawEnd is already set, backtrack from that.
 * @param distance to backtrack
 * @return index of the inserted point
 */
public void backStep(double d){
  if (d <= 0)   return;
  Rr2Point p, q;
  int start, last;
  if (drawEnd >= 0)   start=drawEnd;
 else   start=size() - 1;
  if (!isClosed() && drawEnd < 0)   start--;
  if (start >= size() - 1)   last=0;
 else   last=start + 1;
  double sum=0;
  for (int i=start; i >= 0; i--) {
    sum+=Rr2Point.d(point(i),point(last));
    if (sum > d) {
      sum=sum - d;
      q=Rr2Point.sub(point(last),point(i));
      p=Rr2Point.add(point(i),Rr2Point.mul(sum / q.mod(),q));
      double s=0;
      if (speeds != null) {
        s=speeds.get(last) - speeds.get(i);
        s=speeds.get(i) + s * sum / q.mod();
      }
      int j=i + 1;
      if (j < size()) {
        points.add(j,p);
        if (speeds != null)         speeds.add(j,new Double(s));
      }
 else {
        points.add(p);
        if (speeds != null)         speeds.add(new Double(s));
      }
      drawEnd=j;
      return;
    }
    last=i;
  }
  drawEnd=0;
}
Program: 178257
Project: 178257
Buggy source:
/** 
 * @return same polygon starting at a random vertex
 */
public RrPolygon randomStart(){
  return newStart(rangen.nextInt(size()));
}

Fixed version (ground truth):
/** 
 * @return same polygon starting at a random vertex
 */
public RrPolygon randomStart(){
  if (drawEnd >= 0)   Debug.e("String_Node_Str");
  return newStart(rangen.nextInt(size()));
}
Program: 178258
Project: 178258
Buggy source:
public void actionPerformed(ActionEvent arg0){
  if (producer != null)   producer.setCancelled(true);
}

Fixed version (ground truth):
public void actionPerformed(ActionEvent arg0){
  onDelete();
}
Program: 178260
Project: 178260
Buggy source:
/** 
 * Queue a command.  
 */
private void bufferQueue(String cmd,int retries) throws Exception {
  if (simulationPlot != null)   simulationPlot.add(cmd);
  if (serialOutStream == null) {
    Debug.d("String_Node_Str" + cmd + "String_Node_Str");
    return;
  }
  if (retries > 3) {
    Debug.e("String_Node_Str" + retries + "String_Node_Str"+ cmd);
    return;
  }
  if (sendLine(cmd)) {
    long resp=waitForResponse();
    if (resp == shutDown) {
      throw new Exception("String_Node_Str");
    }
 else     if (resp == allSentOK) {
      lineNumber++;
    }
 else {
      long gotTo=lineNumber;
      lineNumber=resp;
      String rCmd="String_Node_Str";
      while (lineNumber <= gotTo && !rCmd.contentEquals("String_Node_Str")) {
        rCmd=ringGet(lineNumber);
        bufferQueue(rCmd,retries + 1);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Queue a command.  
 */
private void bufferQueue(String cmd,int retries) throws Exception {
  if (simulationPlot != null)   simulationPlot.add(cmd);
  if (serialOutStream == null) {
    if (nonRunningWarn)     Debug.d("String_Node_Str" + cmd + "String_Node_Str");
    nonRunningWarn=false;
    return;
  }
  if (retries > 3) {
    Debug.e("String_Node_Str" + retries + "String_Node_Str"+ cmd);
    return;
  }
  if (sendLine(cmd)) {
    long resp=waitForResponse();
    if (resp == shutDown) {
      throw new Exception("String_Node_Str");
    }
 else     if (resp == allSentOK) {
      lineNumber++;
    }
 else {
      long gotTo=lineNumber;
      lineNumber=resp;
      String rCmd="String_Node_Str";
      while (lineNumber <= gotTo && !rCmd.contentEquals("String_Node_Str")) {
        rCmd=ringGet(lineNumber);
        bufferQueue(rCmd,retries + 1);
      }
    }
  }
}
Program: 178262
Project: 178262
Buggy source:
private void init(){
  resetReceived();
  paused=false;
  iAmPaused=false;
  alreadyReversed=false;
  ringBuffer=new String[buflen];
  ringLines=new long[buflen];
  head=0;
  tail=0;
  lineNumber=0;
  exhaustBuffer=false;
  responsesExpected=0;
  opFileIndex=-1;
  lastResp="String_Node_Str";
  try {
    portName=Preferences.loadGlobalString("String_Node_Str");
  }
 catch (  Exception ex) {
    Debug.e("String_Node_Str");
    portName="String_Node_Str";
  }
  openSerialConnection(portName);
  myPriority=Thread.currentThread().getPriority();
  bufferThread=null;
}

Fixed version (ground truth):
private void init(){
  resetReceived();
  paused=false;
  iAmPaused=false;
  alreadyReversed=false;
  ringBuffer=new String[buflen];
  ringLines=new long[buflen];
  head=0;
  tail=0;
  nonRunningWarn=true;
  lineNumber=0;
  exhaustBuffer=false;
  responsesExpected=0;
  opFileIndex=-1;
  lastResp="String_Node_Str";
  try {
    portName=Preferences.loadGlobalString("String_Node_Str");
  }
 catch (  Exception ex) {
    Debug.e("String_Node_Str");
    portName="String_Node_Str";
  }
  openSerialConnection(portName);
  myPriority=Thread.currentThread().getPriority();
  bufferThread=null;
}
Program: 178263
Project: 178263
Buggy source:
/** 
 * @param p
 * @param modZMax
 * @param macZMax
 * @param modLMax
 * @param macLMax
 * @param found
 */
public LayerRules(Printer p,double modZMax,double macZMax,int modLMax,int macLMax,boolean found,RrRectangle bb){
  printer=p;
  bBox=bb;
  notStartedYet=true;
  topDown=printer.getTopDown();
  modelZMax=modZMax;
  machineZMax=macZMax;
  modelLayerMax=modLMax;
  machineLayerMax=macLMax;
  if (topDown) {
    modelZ=modelZMax;
    machineZ=machineZMax;
    modelLayer=modelLayerMax;
    machineLayer=machineLayerMax;
  }
 else {
    modelZ=0;
    machineZ=0;
    modelLayer=-1;
    machineLayer=0;
  }
  addToStep=0;
  layingSupport=found;
  Extruder[] es=printer.getExtruders();
  zStep=es[0].getExtrusionHeight();
  int fineLayers=es[0].getLowerFineLayers();
  if (es.length > 1) {
    for (int i=1; i < es.length; i++) {
      if (es[i].getLowerFineLayers() > fineLayers)       fineLayers=es[i].getLowerFineLayers();
      if (Math.abs(es[i].getExtrusionHeight() - zStep) > Preferences.tiny())       Debug.e("String_Node_Str" + zStep + "String_Node_Str"+ es[i].getExtrusionHeight());
    }
  }
  recordNumber=new int[fineLayers + 1];
  layerPointer=0;
}

Fixed version (ground truth):
/** 
 * @param p
 * @param modZMax
 * @param macZMax
 * @param modLMax
 * @param macLMax
 * @param found
 */
public LayerRules(Printer p,double modZMax,double macZMax,int modLMax,int macLMax,boolean found,RrRectangle bb){
  printer=p;
  bBox=new RrRectangle(bb);
  notStartedYet=true;
  topDown=printer.getTopDown();
  modelZMax=modZMax;
  machineZMax=macZMax;
  modelLayerMax=modLMax;
  machineLayerMax=macLMax;
  if (topDown) {
    modelZ=modelZMax;
    machineZ=machineZMax;
    modelLayer=modelLayerMax;
    machineLayer=machineLayerMax;
  }
 else {
    modelZ=0;
    machineZ=0;
    modelLayer=-1;
    machineLayer=0;
  }
  addToStep=0;
  layingSupport=found;
  Extruder[] es=printer.getExtruders();
  zStep=es[0].getExtrusionHeight();
  int fineLayers=es[0].getLowerFineLayers();
  if (es.length > 1) {
    for (int i=1; i < es.length; i++) {
      if (es[i].getLowerFineLayers() > fineLayers)       fineLayers=es[i].getLowerFineLayers();
      if (Math.abs(es[i].getExtrusionHeight() - zStep) > Preferences.tiny())       Debug.e("String_Node_Str" + zStep + "String_Node_Str"+ es[i].getExtrusionHeight());
    }
  }
  recordNumber=new int[fineLayers + 1];
  layerPointer=0;
}
Program: 178264
Project: 178264
Buggy source:
public RrRectangle getBox(){
  return bBox;
}

Fixed version (ground truth):
public RrRectangle getBox(){
  return new RrRectangle(bBox);
}
Program: 178265
Project: 178265
Buggy source:
/** 
 * The hatch pattern is: Foundation: X and Y rectangle Model: Alternate even then odd (which can be set to the same angle if wanted).
 * @return
 */
public RrHalfPlane getHatchDirection(Extruder e){
  double angle;
  if (getMachineLayer() < getFoundationLayers()) {
    if (getMachineLayer() == getFoundationLayers() - 2)     angle=e.getEvenHatchDirection();
 else     angle=e.getOddHatchDirection();
  }
 else {
    if (getModelLayer() % 2 == 0)     angle=e.getEvenHatchDirection();
 else     angle=e.getOddHatchDirection();
  }
  angle=angle * Math.PI / 180;
  return new RrHalfPlane(new Rr2Point(0.0,0.0),new Rr2Point(Math.sin(angle),Math.cos(angle)));
}

Fixed version (ground truth):
/** 
 * The hatch pattern is: Foundation: X and Y rectangle Model: Alternate even then odd (which can be set to the same angle if wanted).
 * @return
 */
public RrHalfPlane getHatchDirection(Extruder e){
  double angle;
  if (getMachineLayer() < getFoundationLayers()) {
    angle=e.getOddHatchDirection();
  }
 else {
    if (getModelLayer() % 2 == 0)     angle=e.getEvenHatchDirection();
 else     angle=e.getOddHatchDirection();
  }
  angle=angle * Math.PI / 180;
  return new RrHalfPlane(new Rr2Point(0.0,0.0),new Rr2Point(Math.sin(angle),Math.cos(angle)));
}
Program: 178266
Project: 178266
Buggy source:
public AssignableNode(SourcePosition position,Node valueNode){
}

Fixed version (ground truth):
public AssignableNode(SourcePosition position,Node valueNode){
  super(position);
  this.valueNode=adopt(valueNode);
}
Program: 178267
Project: 178267
Buggy source:
public Node(SourcePosition position){
}

Fixed version (ground truth):
public Node(SourcePosition position){
  this.position=position;
}