nus-yam/ex-repair huggingface dataset:
Program: 145317
Project: 145317
Buggy source:
protected void paint(Graphics g,int w,int h){
  for (int i=0; i <= rows; i++) {
    g.drawLine(0,i * dy,cols * dx,i * dy);
  }
  for (int i=0; i <= cols; i++) {
    g.drawLine(i * dx,0,i * dx,rows * dy);
  }
  int oldColor=g.getColor();
  g.setColor(0x00D0D0D0);
  g.fillRect((currentX * dx) + 1,(currentY * dy) + 1,dx - 1,dy - 1);
  g.setColor(oldColor);
  for (int i=0; i < rows; i++) {
    for (int j=0; j < cols; j++) {
      if (data[i][j] != null) {
        int oldClipX=g.getClipX();
        int oldClipY=g.getClipY();
        int oldClipWidth=g.getClipWidth();
        int oldClipHeight=g.getClipHeight();
        g.setClip((j * dx) + 1,i * dy,dx - 1,dy - 1);
        g.drawString(data[i][j],(j * dx) + 2,((i + 1) * dy) - 2,Graphics.BOTTOM | Graphics.LEFT);
        g.setClip(oldClipX,oldClipY,oldClipWidth,oldClipHeight);
      }
    }
  }
}

Fixed version (ground truth):
protected void paint(Graphics g,int w,int h){
  this.border=null;
  for (int i=0; i <= rows; i++) {
    g.drawLine(0,i * dy,cols * dx,i * dy);
  }
  for (int i=0; i <= cols; i++) {
    g.drawLine(i * dx,0,i * dx,rows * dy);
  }
  int oldColor=g.getColor();
  g.setColor(0x00D0D0D0);
  g.fillRect((currentX * dx) + 1,(currentY * dy) + 1,dx - 1,dy - 1);
  g.setColor(oldColor);
  for (int i=0; i < rows; i++) {
    for (int j=0; j < cols; j++) {
      if (data[i][j] != null) {
        int oldClipX=g.getClipX();
        int oldClipY=g.getClipY();
        int oldClipWidth=g.getClipWidth();
        int oldClipHeight=g.getClipHeight();
        g.setClip((j * dx) + 1,i * dy,dx - 1,dy - 1);
        g.drawString(data[i][j],(j * dx) + 2,((i + 1) * dy) - 2,Graphics.BOTTOM | Graphics.LEFT);
        g.setClip(oldClipX,oldClipY,oldClipWidth,oldClipHeight);
      }
    }
  }
}
Program: 145318
Project: 145318
Buggy source:
/** 
 * Preload the Data Model with the preload values that are enumerated in the data bindings.
 */
public void preloadModel(){
  IAnswerData preload=null;
  Enumeration en=getBindings().elements();
  while (en.hasMoreElements()) {
    DataBinding binding=(DataBinding)en.nextElement();
    if (binding.getPreload() != null)     preload=preloader.getQuestionPreload(binding.getPreload(),binding.getPreloadParams());
    if (preload != null) {
      model.updateDataValue(binding.getReference(),preload);
    }
  }
}

Fixed version (ground truth):
/** 
 * Preload the Data Model with the preload values that are enumerated in the data bindings.
 */
public void preloadModel(){
  IAnswerData preload=null;
  Enumeration en=getBindings().elements();
  while (en.hasMoreElements()) {
    DataBinding binding=(DataBinding)en.nextElement();
    preload=null;
    if (binding.getPreload() != null)     preload=preloader.getQuestionPreload(binding.getPreload(),binding.getPreloadParams());
    if (preload != null) {
      model.updateDataValue(binding.getReference(),preload);
    }
  }
}
Program: 145319
Project: 145319
Buggy source:
public void writeExternal(DataOutputStream out) throws IOException {
  out.writeInt(recordId);
  ExternalizableHelper.writeInteger(out,getPatientId());
  ExternalizableHelper.writeUTF(out,getPrefix());
  ExternalizableHelper.writeUTF(out,getFamilyName());
  ExternalizableHelper.writeUTF(out,getMiddleName());
  ExternalizableHelper.writeUTF(out,getGivenName());
  ExternalizableHelper.writeUTF(out,getGender());
  ExternalizableHelper.writeDate(out,getBirthDate());
  ExternalizableHelper.writeUTF(out,getPatientIdentifier());
  out.writeBoolean(isNewPatient());
  ExternalizableHelper.writeExternalStringValueMap(out,records);
}

Fixed version (ground truth):
public void writeExternal(DataOutputStream out) throws IOException {
  out.writeInt(recordId);
  ExternalizableHelper.writeInteger(out,getPatientId());
  ExternalizableHelper.writeUTF(out,getPrefix());
  ExternalizableHelper.writeUTF(out,getFamilyName());
  ExternalizableHelper.writeUTF(out,getMiddleName());
  ExternalizableHelper.writeUTF(out,getGivenName());
  ExternalizableHelper.writeUTF(out,getGender());
  ExternalizableHelper.writeDate(out,getBirthDate());
  ExternalizableHelper.writeUTF(out,getPatientIdentifier());
  out.writeBoolean(isNewPatient());
  vaccinationData.writeExternal(out);
  ExternalizableHelper.writeExternalStringValueMap(out,records);
}
Program: 145320
Project: 145320
Buggy source:
public Patient(){
  records.put("String_Node_Str",weightRecord);
  records.put("String_Node_Str",heightRecord);
  records.put("String_Node_Str",cd4CountRecord);
  Vector rows=new Vector();
  rows.addElement(new ImmunizationRow("String_Node_Str"));
  rows.addElement(new ImmunizationRow("String_Node_Str"));
  rows.addElement(new ImmunizationRow("String_Node_Str"));
  rows.addElement(new ImmunizationRow("String_Node_Str"));
  rows.addElement(new ImmunizationRow("String_Node_Str"));
  vaccinationData.setValue(rows);
}

Fixed version (ground truth):
public Patient(){
  records.put("String_Node_Str",weightRecord);
  records.put("String_Node_Str",heightRecord);
  records.put("String_Node_Str",cd4CountRecord);
  Vector rows=new Vector();
  rows.addElement(new ImmunizationRow("String_Node_Str"));
  rows.addElement(new ImmunizationRow("String_Node_Str"));
  rows.addElement(new ImmunizationRow("String_Node_Str"));
  rows.addElement(new ImmunizationRow("String_Node_Str"));
  rows.addElement(new ImmunizationRow("String_Node_Str"));
  vaccinationData=new ImmunizationData(rows);
}
Program: 145321
Project: 145321
Buggy source:
public void readExternal(DataInputStream in) throws IOException, InstantiationException, IllegalAccessException, UnavailableExternalizerException {
  recordId=in.readInt();
  setPatientId(ExternalizableHelper.readInteger(in));
  setPrefix(ExternalizableHelper.readUTF(in));
  setFamilyName(ExternalizableHelper.readUTF(in));
  setMiddleName(ExternalizableHelper.readUTF(in));
  setGivenName(ExternalizableHelper.readUTF(in));
  setGender(ExternalizableHelper.readUTF(in));
  setBirthDate(ExternalizableHelper.readDate(in));
  setPatientIdentifier(ExternalizableHelper.readUTF(in));
  setNewPatient(in.readBoolean());
  records=ExternalizableHelper.readExternalStringValueMap(in,NumericListData.class);
}

Fixed version (ground truth):
public void readExternal(DataInputStream in) throws IOException, InstantiationException, IllegalAccessException, UnavailableExternalizerException {
  recordId=in.readInt();
  setPatientId(ExternalizableHelper.readInteger(in));
  setPrefix(ExternalizableHelper.readUTF(in));
  setFamilyName(ExternalizableHelper.readUTF(in));
  setMiddleName(ExternalizableHelper.readUTF(in));
  setGivenName(ExternalizableHelper.readUTF(in));
  setGender(ExternalizableHelper.readUTF(in));
  setBirthDate(ExternalizableHelper.readDate(in));
  setPatientIdentifier(ExternalizableHelper.readUTF(in));
  setNewPatient(in.readBoolean());
  vaccinationData=new ImmunizationData();
  vaccinationData.readExternal(in);
  records=ExternalizableHelper.readExternalStringValueMap(in,NumericListData.class);
}
Program: 145322
Project: 145322
Buggy source:
/** 
 */
public IAnswerData handlePreload(String preloadParams){
  IAnswerData returnVal=null;
  if (preloadParams == "String_Node_Str") {
    returnVal=new IntegerData(12);
  }
 else {
    int selectorStart=preloadParams.indexOf("String_Node_Str");
    if (selectorStart == -1) {
      returnVal=(IAnswerData)patient.getRecord(preloadParams);
    }
 else {
      String type=preloadParams.substring(0,selectorStart);
      String selector=preloadParams.substring(selectorStart,preloadParams.length());
      Vector data=patient.getRecordSet(type,selector);
      returnVal=new NumericListData();
      returnVal.setValue(data);
    }
  }
  return returnVal;
}

Fixed version (ground truth):
/** 
 */
public IAnswerData handlePreload(String preloadParams){
  IAnswerData returnVal=null;
  if (preloadParams == "String_Node_Str") {
    returnVal=new IntegerData(12);
  }
 else   if ("String_Node_Str".equals(preloadParams)) {
    returnVal=new ImmunizationAnswerData(patient.getVaccinations());
  }
 else {
    int selectorStart=preloadParams.indexOf("String_Node_Str");
    if (selectorStart == -1) {
      returnVal=(IAnswerData)patient.getRecord(preloadParams);
    }
 else {
      String type=preloadParams.substring(0,selectorStart);
      String selector=preloadParams.substring(selectorStart,preloadParams.length());
      Vector data=patient.getRecordSet(type,selector);
      returnVal=new NumericListData();
      returnVal.setValue(data);
    }
  }
  return returnVal;
}
Program: 145324
Project: 145324
Buggy source:
protected IAnswerData getWidgetValue(){
  return d;
}

Fixed version (ground truth):
protected IAnswerData getWidgetValue(){
  return new ImmunizationAnswerData(d);
}
Program: 145326
Project: 145326
Buggy source:
public ImmunizationData getData(){
  ImmunizationData data=new ImmunizationData();
  for (int i=1; i < rows; ++i) {
    ImmunizationRow row=new ImmunizationRow(this.data[i][0]);
    for (int j=1; j < cols; j++) {
      if (selectedindex[i][j] == ExtensionConstants.VACCINATION_GIVEN_ON_DATE) {
        row.setDose(j,selectedindex[i][j],new Date(recorddate[i][j]));
      }
 else {
        row.setVaccinationDose(j,selectedindex[i][j]);
      }
    }
    data.addRow(row);
  }
  return data;
}

Fixed version (ground truth):
public ImmunizationData getData(){
  ImmunizationData data=new ImmunizationData();
  for (int i=1; i < rows; ++i) {
    ImmunizationRow row=new ImmunizationRow(this.data[i][0]);
    for (int j=1; j < cols; j++) {
      if (selectedindex[i][j] == ExtensionConstants.VACCINATION_GIVEN_ON_DATE) {
        row.setDose(j - 1,selectedindex[i][j],new Date(recorddate[i][j]));
      }
 else {
        row.setVaccinationDose(j - 1,selectedindex[i][j]);
      }
    }
    data.addRow(row);
  }
  return data;
}
Program: 145327
Project: 145327
Buggy source:
public void refreshWidget(QuestionDef question,IAnswerData data,int changeFlags){
  prompt.setText(question.getLongText());
  updateWidget(question);
  if (data != null) {
    setWidgetValue(data.getValue());
  }
}

Fixed version (ground truth):
public void refreshWidget(QuestionDef question,IAnswerData data,int changeFlags){
  prompt.setText(question.getLongText());
  updateWidget(question);
  if (data != null && changeFlags == QuestionStateListener.CHANGE_INIT) {
    setWidgetValue(data.getValue());
  }
}
Program: 145328
Project: 145328
Buggy source:
private void jumpToQuestion(int questionIndex){
  if (questionIndex != INDEX_NOT_SET && !model.isRelevant(questionIndex))   throw new IllegalStateException();
  if (questionIndex > activeQuestionIndex) {
    if (activeQuestionIndex != INDEX_NOT_SET) {
      ((ChatterboxWidget)get(activeQuestionIndex)).setViewState(ChatterboxWidget.VIEW_COLLAPSED);
    }
    for (int i=activeQuestionIndex + 1; i <= questionIndex; i++) {
      putQuestion(i,i == questionIndex);
    }
  }
 else   if (questionIndex <= activeQuestionIndex) {
    for (int i=activeQuestionIndex; i > questionIndex; i--) {
      removeFrame(i);
    }
    if (questionIndex != INDEX_NOT_SET) {
      ((ChatterboxWidget)get(questionIndex)).setViewState(ChatterboxWidget.VIEW_EXPANDED);
    }
  }
  if (activeQuestionIndex != questionIndex) {
    activeQuestionIndex=questionIndex;
    ChatterboxWidget widget=(ChatterboxWidget)get(activeQuestionIndex);
    this.focus(widget,true);
    progressBar.setValue(questionIndex);
  }
  babysitStyles();
}

Fixed version (ground truth):
private void jumpToQuestion(int questionIndex){
  if (questionIndex != INDEX_NOT_SET && !model.isRelevant(questionIndex))   throw new IllegalStateException();
  if (questionIndex > activeQuestionIndex) {
    if (activeQuestionIndex != INDEX_NOT_SET) {
      ((ChatterboxWidget)get(activeQuestionIndex)).setViewState(ChatterboxWidget.VIEW_COLLAPSED);
    }
    for (int i=activeQuestionIndex + 1; i <= questionIndex; i++) {
      putQuestion(i,i == questionIndex);
    }
  }
 else   if (questionIndex <= activeQuestionIndex) {
    for (int i=activeQuestionIndex; i > questionIndex; i--) {
      removeFrame(i);
    }
    if (questionIndex != INDEX_NOT_SET) {
      ((ChatterboxWidget)get(questionIndex)).setViewState(ChatterboxWidget.VIEW_EXPANDED);
    }
  }
  if (activeQuestionIndex != questionIndex) {
    activeQuestionIndex=questionIndex;
    ChatterboxWidget widget=(ChatterboxWidget)get(activeQuestionIndex);
    this.focus(widget,true);
    widget.showCommands();
    progressBar.setValue(questionIndex);
  }
  babysitStyles();
}
Program: 145329
Project: 145329
Buggy source:
/** 
 * Converts the date into a string formatted according to the xsd:dateTime specifications
 * @param date The date to be converted
 * @return The date represented by 'date' in the XML dateTime format.
 */
public static String formatDateToTimeStamp(Date date){
  String dateElement=getXMLStringValue(date);
  Calendar cd=Calendar.getInstance();
  cd.setTime(date);
  String hour=String.valueOf(cd.get(Calendar.HOUR));
  hour=hour.length() < 2 ? "String_Node_Str" + hour : hour;
  String minute=String.valueOf(cd.get(Calendar.MINUTE));
  minute=minute.length() < 2 ? "String_Node_Str" + minute : minute;
  String time=hour + "String_Node_Str" + minute+ "String_Node_Str"+ String.valueOf(cd.get(Calendar.MILLISECOND)).substring(0,2);
  return dateElement + "String_Node_Str" + time;
}

Fixed version (ground truth):
/** 
 * Converts the date into a string formatted according to the xsd:dateTime specifications
 * @param date The date to be converted
 * @return The date represented by 'date' in the XML dateTime format.
 */
public static String formatDateToTimeStamp(Date date){
  String dateElement=getXMLStringValue(date);
  Calendar cd=Calendar.getInstance();
  cd.setTime(date);
  String hour=String.valueOf(cd.get(Calendar.HOUR_OF_DAY));
  hour=hour.length() < 2 ? "String_Node_Str" + hour : hour;
  String minute=String.valueOf(cd.get(Calendar.MINUTE));
  minute=minute.length() < 2 ? "String_Node_Str" + minute : minute;
  String second=String.valueOf(cd.get(Calendar.SECOND));
  second=second.length() < 2 ? "String_Node_Str" + second : second;
  String time=hour + "String_Node_Str" + minute+ "String_Node_Str"+ second;
  return dateElement + "String_Node_Str" + time;
}
Program: 145330
Project: 145330
Buggy source:
/** 
 * Preloads a StringData object for the preload type 'timestamp'
 * @param preloadParams The parameters determining the timestamp
 * @return A preload string value if the parameters can be parsed,null otherwise
 */
private IAnswerData preloadTimestamp(String preloadParams){
  String value=null;
  if (preloadParams.equals("String_Node_Str") || preloadParams.equals("String_Node_Str")) {
    value=DateUtils.formatDateToTimeStamp(new Date());
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return new StringData(value);
}

Fixed version (ground truth):
/** 
 * Preloads a StringData object for the preload type 'timestamp'
 * @param preloadParams The parameters determining the timestamp
 * @return A preload string value if the parameters can be parsed,null otherwise
 */
private IAnswerData preloadTimestamp(String preloadParams){
  String value=null;
  if ("String_Node_Str".equals(preloadParams)) {
    value=DateUtils.formatDateToTimeStamp(new Date());
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return new StringData(value);
}
Program: 145331
Project: 145331
Buggy source:
public void keyPressed(int keyCode){
  int keyDownSelectedWidget=this.activeQuestionIndex;
  super.keyPressed(keyCode);
  if (multiLingual && keyCode == LANGUAGE_CYCLE_KEYCODE) {
    controller.cycleLanguage();
  }
 else   if (keyCode == KEY_CENTER_LETS_HOPE) {
    ChatterboxWidget widget=activeFrame();
    if (widget != null) {
      widget.UIHack(UIHACK_SELECT_PRESS);
    }
    indexWhenKeyPressed=keyDownSelectedWidget;
  }
}

Fixed version (ground truth):
public void keyPressed(int keyCode){
  int keyDownSelectedWidget=this.activeQuestionIndex;
  super.keyPressed(keyCode);
  if (multiLingual && keyCode == LANGUAGE_CYCLE_KEYCODE) {
    controller.cycleLanguage();
  }
 else   if (keyCode == KEY_CENTER_LETS_HOPE) {
    if (keyDownSelectedWidget == this.activeQuestionIndex) {
      ChatterboxWidget widget=activeFrame();
      if (widget != null) {
        widget.UIHack(UIHACK_SELECT_PRESS);
      }
    }
    indexWhenKeyPressed=keyDownSelectedWidget;
  }
}
Program: 145332
Project: 145332
Buggy source:
private void attachWidget(){
  Item widget=expandedStyle.getInteractiveWidget();
  widget.addCommand(nextCommand);
  widget.setItemCommandListener(this);
switch (expandedStyle.getNextMode()) {
case NEXT_ON_MANUAL:
    break;
case NEXT_ON_ENTRY:
  widget.setItemStateListener(this);
break;
case NEXT_ON_SELECT:
widget.setDefaultCommand(nextCommand);
break;
}
}

Fixed version (ground truth):
private void attachWidget(){
  Item widget=expandedStyle.getInteractiveWidget();
  widget.addCommand(nextCommand);
  widget.setItemCommandListener(this);
switch (expandedStyle.getNextMode()) {
case NEXT_ON_MANUAL:
    break;
case NEXT_ON_ENTRY:
  widget.setItemStateListener(this);
break;
case NEXT_ON_SELECT:
widget.setDefaultCommand(nextCommand);
break;
}
this.focus(this.itemsList.size() - 1);
}
Program: 145333
Project: 145333
Buggy source:
public void setViewState(int viewState){
  if (viewState != this.viewState) {
    if (this.viewState != VIEW_NOT_SET)     reset();
    this.viewState=viewState;
    activeStyle=getActiveStyle();
    activeStyle.initWidget(question,this);
    activeStyle.refreshWidget(question,form.getValue(question),QuestionStateListener.CHANGE_INIT);
    if (viewState == VIEW_EXPANDED)     attachWidget();
  }
}

Fixed version (ground truth):
public void setViewState(int viewState){
  if (viewState != this.viewState) {
    if (this.viewState != VIEW_NOT_SET)     reset();
    this.viewState=viewState;
    activeStyle=getActiveStyle();
    activeStyle.initWidget(question,this);
    activeStyle.refreshWidget(question,form.getValue(question),QuestionStateListener.CHANGE_INIT);
    if (viewState == VIEW_EXPANDED) {
      attachWidget();
    }
  }
}
Program: 145334
Project: 145334
Buggy source:
public void keyReleased(int keyCode){
  if (indexWhenKeyPressed == this.activeQuestionIndex) {
    super.keyReleased(keyCode);
  }
}

Fixed version (ground truth):
public void keyReleased(int keyCode){
  if (keyCode == KEY_CENTER_LETS_HOPE && !(indexWhenKeyPressed == this.activeQuestionIndex)) {
  }
 else {
    super.keyReleased(keyCode);
  }
}
Program: 145335
Project: 145335
Buggy source:
public void itemStateChanged(Item item){
  if (item.getClass() == ChoiceGroup.class) {
    ChoiceGroup cg=(ChoiceGroup)item;
    Vector choices=(Vector)screen.getItemChoices().get(cg);
    String propertyName=cg.getLabel();
    if (cg.getSelectedIndex() >= 0) {
      String selection=(String)choices.elementAt(cg.getSelectedIndex());
      if (JavaRosaServiceProvider.instance().getPropertyManager().getProperty(propertyName).contains(selection)) {
        changes.remove(propertyName);
      }
 else {
        changes.put(propertyName,selection);
      }
    }
  }
 else   if (item.getClass() == TextField.class) {
    TextField tf=(TextField)item;
    String propertyName=tf.getLabel();
    if (JavaRosaServiceProvider.instance().getPropertyManager().getProperty(propertyName).contains(tf.toString())) {
      changes.remove(propertyName);
    }
 else {
      changes.put(propertyName,tf.toString());
    }
  }
}

Fixed version (ground truth):
public void itemStateChanged(Item item){
  if (item instanceof ChoiceGroup) {
    ChoiceGroup cg=(ChoiceGroup)item;
    Vector choices=(Vector)screen.getItemChoices().get(cg);
    String propertyName=cg.getLabel();
    if (cg.getSelectedIndex() >= 0) {
      String selection=(String)choices.elementAt(cg.getSelectedIndex());
      if (JavaRosaServiceProvider.instance().getPropertyManager().getProperty(propertyName).contains(selection)) {
        changes.remove(propertyName);
      }
 else {
        changes.put(propertyName,selection);
      }
    }
  }
 else   if (item instanceof TextField) {
    TextField tf=(TextField)item;
    String propertyName=tf.getLabel();
    Vector prop=JavaRosaServiceProvider.instance().getPropertyManager().getProperty(propertyName);
    if (prop == null) {
      prop=new Vector();
    }
    if (prop.contains(tf.toString())) {
      changes.remove(propertyName);
    }
 else {
      changes.put(propertyName,tf.getString());
    }
  }
}
Program: 145336
Project: 145336
Buggy source:
public void start(Context context){
  changes=new Hashtable();
  screen=new PropertiesScreen(JavaRosaServiceProvider.instance().getPropertyManager());
  screen.addCommand(CMD_DONE);
  screen.addCommand(CMD_CANCEL);
  screen.setCommandListener(this);
  shell.setDisplay(this,screen);
}

Fixed version (ground truth):
public void start(Context context){
  changes=new Hashtable();
  screen=new PropertiesScreen(JavaRosaServiceProvider.instance().getPropertyManager());
  screen.addCommand(CMD_DONE);
  screen.addCommand(CMD_CANCEL);
  screen.setCommandListener(this);
  screen.setItemStateListener(this);
  shell.setDisplay(this,screen);
}
Program: 145337
Project: 145337
Buggy source:
public boolean canSerialize(IAnswerData data){
  if (data.getClass() == StringData.class || data.getClass() == DateData.class || data.getClass() == SelectMultiData.class || data.getClass() == SelectOneData.class) {
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
public boolean canSerialize(IAnswerData data){
  if (data instanceof StringData || data instanceof DateData || data instanceof SelectMultiData|| data instanceof SelectOneData) {
    return true;
  }
 else {
    return false;
  }
}
Program: 145338
Project: 145338
Buggy source:
public static void numericEncodingUnitTestSuite(){
  numericEncodingUnitTest(0);
  numericEncodingUnitTest(-1);
  numericEncodingUnitTest(1);
  numericEncodingUnitTest(-2);
  for (int i=3; i <= 64; i++) {
    long min=(i < 64 ? -((long)0x01 << (i - 1)) : -9223372036854775808l);
    long max=(i < 64 ? ((long)0x01 << (i - 1)) - 1 : 9223372036854775807l);
    numericEncodingUnitTest(max - 1);
    numericEncodingUnitTest(max);
    if (i < 64)     numericEncodingUnitTest(max + 1);
    numericEncodingUnitTest(min + 1);
    numericEncodingUnitTest(min);
    if (i < 64)     numericEncodingUnitTest(min - 1);
  }
}

Fixed version (ground truth):
public static void numericEncodingUnitTestSuite(){
  numericEncodingUnitTest(0);
  numericEncodingUnitTest(-1);
  numericEncodingUnitTest(1);
  numericEncodingUnitTest(-2);
  for (int i=3; i <= 64; i++) {
    long min=(i < 64 ? -((long)0x01 << (i - 1)) : Long.MIN_VALUE);
    long max=(i < 64 ? ((long)0x01 << (i - 1)) - 1 : Long.MAX_VALUE);
    numericEncodingUnitTest(max - 1);
    numericEncodingUnitTest(max);
    if (i < 64)     numericEncodingUnitTest(max + 1);
    numericEncodingUnitTest(min + 1);
    numericEncodingUnitTest(min);
    if (i < 64)     numericEncodingUnitTest(min - 1);
  }
}
Program: 145339
Project: 145339
Buggy source:
public static boolean numericEncodingUnitTest(long valIn){
  byte[] bytesOut;
  long valOut;
  System.out.println("String_Node_Str" + valIn);
  try {
    ByteArrayOutputStream baos=new ByteArrayOutputStream(100);
    ExternalizableHelper.writeNumeric(new DataOutputStream(baos),valIn);
    bytesOut=baos.toByteArray();
    ByteArrayInputStream bais=new ByteArrayInputStream(bytesOut);
    valOut=ExternalizableHelper.readNumeric(new DataInputStream(bais));
  }
 catch (  IOException ioe) {
    System.out.println("String_Node_Str");
    return false;
  }
  System.out.print("String_Node_Str");
  for (int i=0; i < bytesOut.length; i++) {
    String hex=Integer.toHexString(bytesOut[i]);
    if (hex.length() == 1)     hex="String_Node_Str" + hex;
 else     hex=hex.substring(hex.length() - 2);
    System.out.print(hex + "String_Node_Str");
    i++;
  }
  System.out.print("String_Node_Str");
  if (valIn == valOut) {
    System.out.println("String_Node_Str");
    return true;
  }
 else {
    System.out.println("String_Node_Str" + valOut + "String_Node_Str");
    return false;
  }
}

Fixed version (ground truth):
public static boolean numericEncodingUnitTest(long valIn){
  byte[] bytesOut;
  long valOut;
  System.out.print("String_Node_Str" + valIn);
  try {
    ByteArrayOutputStream baos=new ByteArrayOutputStream(100);
    ExternalizableHelper.writeNumeric(new DataOutputStream(baos),valIn);
    bytesOut=baos.toByteArray();
    ByteArrayInputStream bais=new ByteArrayInputStream(bytesOut);
    valOut=ExternalizableHelper.readNumeric(new DataInputStream(bais));
  }
 catch (  IOException ioe) {
    System.out.println("String_Node_Str");
    return false;
  }
  System.out.print("String_Node_Str");
  for (int i=0; i < bytesOut.length; i++) {
    String hex=Integer.toHexString(bytesOut[i]);
    if (hex.length() == 1)     hex="String_Node_Str" + hex;
 else     hex=hex.substring(hex.length() - 2);
    System.out.print(hex);
    if (i < bytesOut.length - 1)     System.out.print("String_Node_Str");
  }
  System.out.print("String_Node_Str");
  if (valIn == valOut) {
    System.out.println("String_Node_Str");
    return true;
  }
 else {
    System.out.println("String_Node_Str" + valOut + "String_Node_Str");
    return false;
  }
}
Program: 145340
Project: 145340
Buggy source:
public static FormDef getFormDef(Document doc){
  FormDef formDef=new FormDef();
  initStateVars();
  parseElement(formDef,doc.getRootElement(),formDef,topLevelHandlers);
  if (instanceNode != null) {
    parseInstance(formDef,instanceNode);
  }
  initStateVars();
  return formDef;
}

Fixed version (ground truth):
public static FormDef getFormDef(Document doc){
  FormDef formDef=new FormDef();
  initStateVars();
  parseElement(formDef,doc.getRootElement(),formDef,topLevelHandlers);
  if (instanceNode != null) {
    parseInstance(formDef,instanceNode);
  }
  verifyBindings(formDef);
  initStateVars();
  return formDef;
}
Program: 145341
Project: 145341
Buggy source:
private static TreeElement parseInstanceNodes(Element node,String currentPath){
  int childNum=node.getChildCount();
  TreeElement element;
  XPathReference reference=new XPathReference(currentPath + node.getName());
  if (bindingsByRef.containsKey(reference)) {
    DataBinding binding=(DataBinding)bindingsByRef.get(reference);
    element=new QuestionDataElement(node.getName(),reference);
    ((QuestionDataElement)element).setValue(XFormAnswerDataParser.getAnswerData(binding,node));
  }
 else {
    if (childNum == 0) {
      element=new QuestionDataElement(node.getName(),reference);
    }
 else     if (childNum == 1) {
      if (node.getType(0) == Node.TEXT) {
        element=new QuestionDataElement(node.getName(),reference);
        ((QuestionDataElement)element).setValue(new StringData((String)node.getChild(0)));
      }
 else {
        element=new QuestionDataGroup(node.getName());
        String newPath=currentPath + node.getName() + "String_Node_Str";
        ((QuestionDataGroup)element).addChild(parseInstanceNodes(node.getElement(0),newPath));
      }
    }
 else {
      element=new QuestionDataGroup(node.getName());
      for (int i=0; i < childNum; ++i) {
        if (node.getType(i) != Node.ELEMENT) {
          continue;
        }
 else {
          String newPath=currentPath + node.getName() + "String_Node_Str";
          ((QuestionDataGroup)element).addChild(parseInstanceNodes(node.getElement(i),newPath));
        }
      }
    }
  }
  return element;
}

Fixed version (ground truth):
private static TreeElement parseInstanceNodes(Element node,String currentPath){
  int childNum=node.getChildCount();
  TreeElement element;
  String refStr=currentPath + node.getName();
  XPathReference reference=new XPathReference(refStr);
  if (bindingsByRef.containsKey(refStr)) {
    DataBinding binding=(DataBinding)bindingsByRef.get(refStr);
    element=new QuestionDataElement(node.getName(),reference);
    ((QuestionDataElement)element).setValue(XFormAnswerDataParser.getAnswerData(binding,node));
  }
 else {
    if (childNum == 0) {
      element=new QuestionDataElement(node.getName(),reference);
    }
 else     if (childNum == 1) {
      if (node.getType(0) == Node.TEXT) {
        element=new QuestionDataElement(node.getName(),reference);
        ((QuestionDataElement)element).setValue(new StringData((String)node.getChild(0)));
      }
 else {
        element=new QuestionDataGroup(node.getName());
        String newPath=currentPath + node.getName() + "String_Node_Str";
        ((QuestionDataGroup)element).addChild(parseInstanceNodes(node.getElement(0),newPath));
      }
    }
 else {
      element=new QuestionDataGroup(node.getName());
      for (int i=0; i < childNum; ++i) {
        if (node.getType(i) != Node.ELEMENT) {
          continue;
        }
 else {
          String newPath=currentPath + node.getName() + "String_Node_Str";
          ((QuestionDataGroup)element).addChild(parseInstanceNodes(node.getElement(i),newPath));
        }
      }
    }
  }
  return element;
}
Program: 145342
Project: 145342
Buggy source:
private static void addBinding(FormDef f,DataBinding binding){
  f.addBinding(binding);
  if (binding.getId() != null) {
    if (bindingsByID.put(binding.getId(),binding) != null) {
      throw new XFormParseException("String_Node_Str");
    }
  }
  bindingsByRef.put(binding.getId(),binding);
}

Fixed version (ground truth):
private static void addBinding(FormDef f,DataBinding binding){
  f.addBinding(binding);
  if (binding.getId() != null) {
    if (bindingsByID.put(binding.getId(),binding) != null) {
      throw new XFormParseException("String_Node_Str");
    }
  }
  bindingsByRef.put((String)binding.getReference().getReference(),binding);
}
Program: 145343
Project: 145343
Buggy source:
public static Document getXMLDocument(Reader reader){
  Document doc=new Document();
  try {
    KXmlParser parser=new KXmlParser();
    parser.setInput(reader);
    parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES,true);
    doc.parse(parser);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return doc;
}

Fixed version (ground truth):
public static Document getXMLDocument(Reader reader){
  Document doc=new Document();
  try {
    KXmlParser parser=new KXmlParser();
    parser.setInput(reader);
    parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES,true);
    doc.parse(parser);
  }
 catch (  Exception e) {
    System.err.println("String_Node_Str");
    e.printStackTrace();
  }
  return doc;
}
Program: 145344
Project: 145344
Buggy source:
public static IAnswerData getAnswerData(DataBinding binding,Element node){
  String value;
switch (binding.getDataType()) {
case Constants.DATATYPE_DATE:
    value=(String)node.getChild(0);
  return new DateData(DateUtils.getDateFromString(value));
case Constants.DATATYPE_DATE_TIME:
value=(String)node.getChild(0);
return new DateData(DateUtils.getDateFromString(value));
case Constants.DATATYPE_INTEGER:
value=(String)node.getChild(0);
return new IntegerData(Integer.parseInt(value));
case Constants.DATATYPE_TEXT:
value=(String)node.getChild(0);
return new StringData(value);
case Constants.DATATYPE_TIME:
return null;
}
return null;
}

Fixed version (ground truth):
public static IAnswerData getAnswerData(DataBinding binding,Element node){
  String value=XFormParser.getXMLText(node,false);
  if (value == null)   return null;
switch (binding.getDataType()) {
case Constants.DATATYPE_DATE:
    return new DateData(DateUtils.getDateFromString(value));
case Constants.DATATYPE_DATE_TIME:
  return new DateData(DateUtils.getDateFromString(value));
case Constants.DATATYPE_INTEGER:
return new IntegerData(Integer.parseInt(value));
case Constants.DATATYPE_TEXT:
return new StringData(value);
case Constants.DATATYPE_TIME:
return null;
}
return null;
}
Program: 145345
Project: 145345
Buggy source:
public void keyPressed(int keyCode){
  if (multiLingual && keyCode == LANGUAGE_CYCLE_KEYCODE) {
    controller.cycleLanguage();
  }
 else   if (keyCode == KEY_CENTER_LETS_HOPE) {
    ChatterboxWidget widget=activeFrame();
    if (widget != null)     ;
  }
  super.keyPressed(keyCode);
}

Fixed version (ground truth):
public void keyPressed(int keyCode){
  int keyDownSelectedWidget=this.activeQuestionIndex;
  super.keyPressed(keyCode);
  if (multiLingual && keyCode == LANGUAGE_CYCLE_KEYCODE) {
    controller.cycleLanguage();
  }
 else   if (keyCode == KEY_CENTER_LETS_HOPE) {
    ChatterboxWidget widget=activeFrame();
    if (widget != null) {
    }
    indexWhenKeyPressed=keyDownSelectedWidget;
  }
}
Program: 145346
Project: 145346
Buggy source:
/** 
 * Resolves a binding to a particular question data element
 * @param binding The binding representing a particular question
 * @param group 
 * @return A QuestionDataElement corresponding to the bindingprovided. Null if none exists in this tree.
 */
private QuestionDataElement resolveReference(IDataReference binding,QuestionDataGroup group){
  Enumeration en=group.getChildren().elements();
  while (en.hasMoreElements()) {
    TreeElement dme=(TreeElement)en.nextElement();
    if (!dme.isLeaf()) {
      return resolveReference(binding,(QuestionDataGroup)dme);
    }
 else {
      if ((dme instanceof QuestionDataElement) && ((QuestionDataElement)dme).matchesReference(binding)) {
        return (QuestionDataElement)dme;
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Resolves a binding to a particular question data element
 * @param binding The binding representing a particular question
 * @param group 
 * @return A QuestionDataElement corresponding to the bindingprovided. Null if none exists in this tree.
 */
private QuestionDataElement resolveReference(IDataReference binding,QuestionDataGroup group){
  QuestionDataElement target=null;
  Enumeration en=group.getChildren().elements();
  while (target == null && en.hasMoreElements()) {
    TreeElement dme=(TreeElement)en.nextElement();
    if (!dme.isLeaf()) {
      target=resolveReference(binding,(QuestionDataGroup)dme);
    }
 else {
      if ((dme instanceof QuestionDataElement) && ((QuestionDataElement)dme).matchesReference(binding)) {
        target=(QuestionDataElement)dme;
      }
    }
  }
  return target;
}
Program: 145347
Project: 145347
Buggy source:
private void jumpToQuestion(int questionIndex){
  if (questionIndex != INDEX_NOT_SET && !model.isRelevant(questionIndex))   throw new IllegalStateException();
  if (questionIndex > activeQuestionIndex) {
    if (activeQuestionIndex != INDEX_NOT_SET) {
      ((ChatterboxWidget)get(activeQuestionIndex)).setViewState(ChatterboxWidget.VIEW_COLLAPSED);
    }
    for (int i=activeQuestionIndex + 1; i <= questionIndex; i++) {
      putQuestion(i,i == questionIndex);
    }
  }
 else   if (questionIndex <= activeQuestionIndex) {
    for (int i=activeQuestionIndex; i > questionIndex; i--) {
      removeFrame(i);
    }
    if (questionIndex != INDEX_NOT_SET) {
      ((ChatterboxWidget)get(questionIndex)).setViewState(ChatterboxWidget.VIEW_EXPANDED);
    }
  }
  if (activeQuestionIndex != questionIndex) {
    activeQuestionIndex=questionIndex;
    ChatterboxWidget widget=(ChatterboxWidget)get(activeQuestionIndex);
    focus(widget);
    progressBar.setValue(questionIndex);
  }
  babysitStyles();
}

Fixed version (ground truth):
private void jumpToQuestion(int questionIndex){
  if (questionIndex != INDEX_NOT_SET && !model.isRelevant(questionIndex))   throw new IllegalStateException();
  if (questionIndex > activeQuestionIndex) {
    if (activeQuestionIndex != INDEX_NOT_SET) {
      ((ChatterboxWidget)get(activeQuestionIndex)).setViewState(ChatterboxWidget.VIEW_COLLAPSED);
    }
    for (int i=activeQuestionIndex + 1; i <= questionIndex; i++) {
      putQuestion(i,i == questionIndex);
    }
  }
 else   if (questionIndex <= activeQuestionIndex) {
    for (int i=activeQuestionIndex; i > questionIndex; i--) {
      removeFrame(i);
    }
    if (questionIndex != INDEX_NOT_SET) {
      ((ChatterboxWidget)get(questionIndex)).setViewState(ChatterboxWidget.VIEW_EXPANDED);
    }
  }
  if (activeQuestionIndex != questionIndex) {
    activeQuestionIndex=questionIndex;
    ChatterboxWidget widget=(ChatterboxWidget)get(activeQuestionIndex);
    this.focus(widget,true);
    progressBar.setValue(questionIndex);
  }
  babysitStyles();
  Timer t=new Timer();
  t.schedule(new TimerTask(){
    public void run(){
      UiAccess.emitKeyPress(-2);
      UiAccess.emitKeyPress(DOWN);
      UiAccess.emitKeyRelease(DOWN);
    }
  }
,50);
}
Program: 145348
Project: 145348
Buggy source:
public void setFocus(){
  if (viewState == VIEW_EXPANDED) {
    if (expandedStyle.focus())     repaint();
  }
 else {
    throw new IllegalStateException("String_Node_Str");
  }
}

Fixed version (ground truth):
public void setFocus(){
  if (viewState == VIEW_EXPANDED) {
    if (expandedStyle.focus()) {
      repaint();
    }
  }
 else {
    throw new IllegalStateException("String_Node_Str");
  }
}
Program: 145349
Project: 145349
Buggy source:
public void setSelectItemIDs(SimpleOrderedHashtable selectItemIDs,Vector selectItemsLocalizable,Localizer localizer){
  this.selectItemIDs=selectItemIDs;
  this.selectItemsLocalizable=selectItemsLocalizable;
  if (localizer != null) {
    localizeSelectMap(localizer);
  }
}

Fixed version (ground truth):
public void setSelectItemIDs(SimpleOrderedHashtable selectItemIDs,Vector selectItemsLocalizable,Localizer localizer){
  this.selectItemIDs=selectItemIDs;
  this.selectItemsLocalizable=selectItemsLocalizable;
  if (selectItemIDs != null) {
    localizeSelectMap(localizer);
  }
}
Program: 145350
Project: 145350
Buggy source:
public void readExternal(DataInputStream in) throws IOException, InstantiationException, IllegalAccessException, UnavailableExternalizerException {
  this.setId(ExternalizableHelper.readUTF(in));
  this.setDataType(in.readInt());
  this.setPreload(ExternalizableHelper.readUTF(in));
  this.setPreloadParams(ExternalizableHelper.readUTF(in));
  this.setRequired(in.readBoolean());
  condition=new Condition();
  ExternalizableHelper.readExternalizable(in,condition);
  String factoryName=in.readUTF();
  FormDefRMSUtility fdrms=(FormDefRMSUtility)JavaRosaServiceProvider.instance().getStorageManager().getRMSStorageProvider().getUtility(FormDefRMSUtility.getUtilityName());
  PrototypeFactory factory=fdrms.getQuestionElementsFactory();
  ref=(IDataReference)factory.getNewInstance(factoryName);
  if (ref == null) {
    throw new UnavailableExternalizerException("String_Node_Str" + "String_Node_Str" + factoryName + "String_Node_Str"+ "String_Node_Str"+ this.getId());
  }
  ref.readExternal(in);
}

Fixed version (ground truth):
public void readExternal(DataInputStream in) throws IOException, InstantiationException, IllegalAccessException, UnavailableExternalizerException {
  this.setId(ExternalizableHelper.readUTF(in));
  this.setDataType(in.readInt());
  this.setPreload(ExternalizableHelper.readUTF(in));
  this.setPreloadParams(ExternalizableHelper.readUTF(in));
  this.setRequired(in.readBoolean());
  condition=(Condition)ExternalizableHelper.readExternalizable(in,new Condition());
  String factoryName=in.readUTF();
  FormDefRMSUtility fdrms=(FormDefRMSUtility)JavaRosaServiceProvider.instance().getStorageManager().getRMSStorageProvider().getUtility(FormDefRMSUtility.getUtilityName());
  PrototypeFactory factory=fdrms.getQuestionElementsFactory();
  ref=(IDataReference)factory.getNewInstance(factoryName);
  if (ref == null) {
    throw new UnavailableExternalizerException("String_Node_Str" + "String_Node_Str" + factoryName + "String_Node_Str"+ "String_Node_Str"+ this.getId());
  }
  ref.readExternal(in);
}
Program: 145351
Project: 145351
Buggy source:
public void setLocalizer(Localizer l){
  if (this.localizer != null) {
    this.localizer.unregisterLocalizable(this);
  }
  this.localizer=l;
  this.localizer.registerLocalizable(this);
}

Fixed version (ground truth):
public void setLocalizer(Localizer l){
  if (this.localizer != null) {
    this.localizer.unregisterLocalizable(this);
  }
  this.localizer=l;
  if (this.localizer != null) {
    this.localizer.registerLocalizable(this);
  }
}
Program: 145352
Project: 145352
Buggy source:
/** 
 * Reads the form definition object from the supplied stream. Requires that the model has been set to a prototype of the model that should be used for deserialization.
 * @param dis - the stream to read from.
 * @throws IOException
 * @throws InstantiationException
 * @throws IllegalAccessException
 */
public void readExternal(DataInputStream dis) throws IOException, InstantiationException, IllegalAccessException, UnavailableExternalizerException {
  if (!ExternalizableHelper.isEOF(dis)) {
    PrototypeFactory factory=new PrototypeFactory();
    factory.addNewPrototype(QuestionDef.class.getName(),QuestionDef.class);
    factory.addNewPrototype(GroupDef.class.getName(),GroupDef.class);
    setID(dis.readInt());
    setName(ExternalizableHelper.readUTF(dis));
    setChildren(ExternalizableHelper.readExternal(dis,factory));
    setBindings(ExternalizableHelper.readExternal(dis,new DataBinding().getClass()));
    String modelType=dis.readUTF();
    model=(IFormDataModel)modelFactory.getNewInstance(modelType);
    if (model == null) {
      throw new UnavailableExternalizerException("String_Node_Str" + "String_Node_Str");
    }
    model.setFormReferenceId(this.getID());
    model.readExternal(dis);
    Localizer l=new Localizer();
    ExternalizableHelper.readExternalizable(dis,l);
    setLocalizer(l);
  }
}

Fixed version (ground truth):
/** 
 * Reads the form definition object from the supplied stream. Requires that the model has been set to a prototype of the model that should be used for deserialization.
 * @param dis - the stream to read from.
 * @throws IOException
 * @throws InstantiationException
 * @throws IllegalAccessException
 */
public void readExternal(DataInputStream dis) throws IOException, InstantiationException, IllegalAccessException, UnavailableExternalizerException {
  if (!ExternalizableHelper.isEOF(dis)) {
    PrototypeFactory factory=new PrototypeFactory();
    factory.addNewPrototype(QuestionDef.class.getName(),QuestionDef.class);
    factory.addNewPrototype(GroupDef.class.getName(),GroupDef.class);
    setID(dis.readInt());
    setName(ExternalizableHelper.readUTF(dis));
    setChildren(ExternalizableHelper.readExternal(dis,factory));
    setBindings(ExternalizableHelper.readExternal(dis,new DataBinding().getClass()));
    String modelType=dis.readUTF();
    model=(IFormDataModel)modelFactory.getNewInstance(modelType);
    if (model == null) {
      throw new UnavailableExternalizerException("String_Node_Str" + "String_Node_Str");
    }
    model.setFormReferenceId(this.getID());
    model.readExternal(dis);
    setLocalizer((Localizer)ExternalizableHelper.readExternalizable(dis,new Localizer()));
  }
}
Program: 145353
Project: 145353
Buggy source:
public static void readExternalizable(DataInputStream dis,Externalizable item) throws IOException, InstantiationException, IllegalAccessException, UnavailableExternalizerException {
  if (dis.readBoolean()) {
    item.readExternal(dis);
  }
}

Fixed version (ground truth):
public static Externalizable readExternalizable(DataInputStream dis,Externalizable item) throws IOException, InstantiationException, IllegalAccessException, UnavailableExternalizerException {
  if (dis.readBoolean()) {
    item.readExternal(dis);
  }
 else {
    item=null;
  }
  return item;
}
Program: 145354
Project: 145354
Buggy source:
/** 
 * Read the object from stream.
 */
public void readExternal(DataInputStream dis) throws IOException, IllegalAccessException, InstantiationException {
  if (!ExternalizableHelper.isEOF(dis)) {
    fallbackDefaultLocale=ExternalizableHelper.readBoolean(dis).booleanValue();
    fallbackDefaultForm=ExternalizableHelper.readBoolean(dis).booleanValue();
    localeData=ExternalizableHelper.readExternalSOH(dis);
    if (localeData == null)     localeData=new SimpleOrderedHashtable();
    setDefaultLocale(ExternalizableHelper.readUTF(dis));
    setLocale(ExternalizableHelper.readUTF(dis));
  }
}

Fixed version (ground truth):
/** 
 * Read the object from stream.
 */
public void readExternal(DataInputStream dis) throws IOException, IllegalAccessException, InstantiationException {
  if (!ExternalizableHelper.isEOF(dis)) {
    fallbackDefaultLocale=ExternalizableHelper.readBoolean(dis).booleanValue();
    fallbackDefaultForm=ExternalizableHelper.readBoolean(dis).booleanValue();
    localeData=ExternalizableHelper.readExternalCompoundSOH(dis);
    if (localeData == null)     localeData=new SimpleOrderedHashtable();
    setDefaultLocale(ExternalizableHelper.readUTF(dis));
    String currentLocale=ExternalizableHelper.readUTF(dis);
    if (currentLocale != null) {
      setLocale(currentLocale);
    }
  }
}
Program: 145355
Project: 145355
Buggy source:
/** 
 * Reads the form definition object from the supplied stream.
 * @param dis - the stream to read from.
 * @throws IOException
 * @throws InstantiationException
 * @throws IllegalAccessException
 */
public void readExternal(DataInputStream dis) throws IOException, InstantiationException, IllegalAccessException, UnavailableExternalizerException {
  if (!ExternalizableHelper.isEOF(dis)) {
    PrototypeFactory factory=new PrototypeFactory();
    factory.addNewPrototype(QuestionDef.class.getName(),QuestionDef.class);
    factory.addNewPrototype(GroupDef.class.getName(),GroupDef.class);
    setID(dis.readInt());
    setName(ExternalizableHelper.readUTF(dis));
    setChildren(ExternalizableHelper.readExternal(dis,factory));
    setBindings(ExternalizableHelper.readExternal(dis,new DataBinding().getClass()));
    Localizer l=new Localizer();
    l.readExternal(dis);
    setLocalizer(l);
  }
}

Fixed version (ground truth):
/** 
 * Reads the form definition object from the supplied stream.
 * @param dis - the stream to read from.
 * @throws IOException
 * @throws InstantiationException
 * @throws IllegalAccessException
 */
public void readExternal(DataInputStream dis) throws IOException, InstantiationException, IllegalAccessException, UnavailableExternalizerException {
  if (!ExternalizableHelper.isEOF(dis)) {
    PrototypeFactory factory=new PrototypeFactory();
    factory.addNewPrototype(QuestionDef.class.getName(),QuestionDef.class);
    factory.addNewPrototype(GroupDef.class.getName(),GroupDef.class);
    setID(dis.readInt());
    setName(ExternalizableHelper.readUTF(dis));
    setChildren(ExternalizableHelper.readExternal(dis,factory));
    setBindings(ExternalizableHelper.readExternal(dis,new DataBinding().getClass()));
    Localizer l=new Localizer();
    ExternalizableHelper.readExternalizable(dis,l);
    setLocalizer(l);
  }
}
Program: 145357
Project: 145357
Buggy source:
public void accept(IDataModelVisitor visitor){
  visitor.visit(this);
  if (root != null) {
    if (visitor.getClass() == ITreeVisitor.class) {
      root.accept((ITreeVisitor)visitor);
    }
  }
}

Fixed version (ground truth):
public void accept(IDataModelVisitor visitor){
  visitor.visit(this);
  if (root != null) {
    if (visitor instanceof ITreeVisitor) {
      root.accept((ITreeVisitor)visitor);
    }
  }
}