nus-yam/ex-repair huggingface dataset:
Program: 165336
Project: 165336
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (Utils.hasApi(11))   getActionBar().setDisplayHomeAsUpEnabled(true);
  applist=new AvailableAppListAdapter(this);
  setContentView(R.layout.searchresults);
  setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
  Intent intent=getIntent();
  if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
    mQuery=intent.getStringExtra(SearchManager.QUERY);
  }
  updateView();
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  ActionBarCompat.create(this).setDisplayHomeAsUpEnabled(true);
  applist=new AvailableAppListAdapter(this);
  setContentView(R.layout.searchresults);
  setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
  Intent intent=getIntent();
  if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
    mQuery=intent.getStringExtra(SearchManager.QUERY);
  }
  updateView();
}
Program: 165337
Project: 165337
Buggy source:
public static MenuManager create(Activity activity){
  if (Utils.hasApi(11)) {
    return new HoneycombMenuManagerImpl(activity);
  }
 else {
    return new OldMenuManagerImpl(activity);
  }
}

Fixed version (ground truth):
public static MenuManager create(Activity activity){
  if (hasApi(11)) {
    return new HoneycombMenuManagerImpl(activity);
  }
 else {
    return new OldMenuManagerImpl(activity);
  }
}
Program: 165338
Project: 165338
Buggy source:
public static TabManager create(FDroid parent,ViewPager pager){
  if (Utils.hasApi(11)) {
    return new HoneycombTabManagerImpl(parent,pager);
  }
 else {
    return new OldTabManagerImpl(parent,pager);
  }
}

Fixed version (ground truth):
public static TabManager create(FDroid parent,ViewPager pager){
  if (hasApi(11)) {
    return new HoneycombTabManagerImpl(parent,pager);
  }
 else {
    return new OldTabManagerImpl(parent,pager);
  }
}
Program: 165340
Project: 165340
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  applist=new AvailableAppListAdapter(this);
  setContentView(R.layout.searchresults);
  Intent intent=getIntent();
  if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
    mQuery=intent.getStringExtra(SearchManager.QUERY);
  }
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  applist=new AvailableAppListAdapter(this);
  setContentView(R.layout.searchresults);
  Intent intent=getIntent();
  if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
    mQuery=intent.getStringExtra(SearchManager.QUERY);
  }
  updateView();
}
Program: 165341
Project: 165341
Buggy source:
@Override protected void onNewIntent(Intent intent){
  if (Intent.ACTION_SEARCH.equals(intent.getAction()))   mQuery=intent.getStringExtra(SearchManager.QUERY);
  super.onNewIntent(intent);
}

Fixed version (ground truth):
@Override protected void onNewIntent(Intent intent){
  if (Intent.ACTION_SEARCH.equals(intent.getAction()))   mQuery=intent.getStringExtra(SearchManager.QUERY);
  super.onNewIntent(intent);
  updateView();
}
Program: 165342
Project: 165342
Buggy source:
@Override protected void onResume(){
  updateView();
  super.onResume();
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
}
Program: 165343
Project: 165343
Buggy source:
@Override public void onUpgrade(SQLiteDatabase db,int oldVersion,int newVersion){
  resetTransient(db);
  if (oldVersion < 20) {
    List<Repo> oldrepos=new ArrayList<Repo>();
    Cursor c=db.rawQuery("String_Node_Str" + TABLE_REPO,null);
    c.moveToFirst();
    while (!c.isAfterLast()) {
      Repo repo=new Repo();
      repo.address=c.getString(0);
      repo.inuse=(c.getInt(1) == 1);
      repo.pubkey=c.getString(2);
      oldrepos.add(repo);
      c.moveToNext();
    }
    c.close();
    db.execSQL("String_Node_Str" + TABLE_REPO);
    db.execSQL(CREATE_TABLE_REPO);
    for (    Repo repo : oldrepos) {
      ContentValues values=new ContentValues();
      values.put("String_Node_Str",repo.address);
      values.put("String_Node_Str",repo.inuse);
      values.put("String_Node_Str",10);
      values.put("String_Node_Str",repo.pubkey);
      values.put("String_Node_Str",(String)null);
      db.insert(TABLE_REPO,null,values);
    }
  }
}

Fixed version (ground truth):
@Override public void onUpgrade(SQLiteDatabase db,int oldVersion,int newVersion){
  if (oldVersion < 20) {
    List<Repo> oldrepos=new ArrayList<Repo>();
    Cursor c=db.rawQuery("String_Node_Str" + TABLE_REPO,null);
    c.moveToFirst();
    while (!c.isAfterLast()) {
      Repo repo=new Repo();
      repo.address=c.getString(0);
      repo.inuse=(c.getInt(1) == 1);
      repo.pubkey=c.getString(2);
      oldrepos.add(repo);
      c.moveToNext();
    }
    c.close();
    db.execSQL("String_Node_Str" + TABLE_REPO);
    db.execSQL(CREATE_TABLE_REPO);
    for (    Repo repo : oldrepos) {
      ContentValues values=new ContentValues();
      values.put("String_Node_Str",repo.address);
      values.put("String_Node_Str",repo.inuse);
      values.put("String_Node_Str",10);
      values.put("String_Node_Str",repo.pubkey);
      values.put("String_Node_Str",(String)null);
      db.insert(TABLE_REPO,null,values);
    }
  }
  resetTransient(db);
}
Program: 165344
Project: 165344
Buggy source:
public void selectTab(int index){
  actionBar.setSelectedNavigationItem(index);
}

Fixed version (ground truth):
public void selectTab(int index){
  actionBar.setSelectedNavigationItem(index);
  Spinner actionBarSpinner=getActionBarSpinner();
  if (actionBarSpinner != null) {
    actionBarSpinner.setSelection(index);
  }
}
Program: 165346
Project: 165346
Buggy source:
@Override protected void onResume(){
  super.onResume();
  if (resetRequired) {
    reset();
    resetRequired=false;
  }
  resetViews();
  invalidateOptionsMenu();
  if (downloadHandler != null) {
    downloadHandler.startUpdates();
  }
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  if (resetRequired) {
    reset();
    resetRequired=false;
  }
  resetViews();
  if (Utils.hasApi(11)) {
    invalidateOptionsMenu();
  }
  if (downloadHandler != null) {
    downloadHandler.startUpdates();
  }
}
Program: 165347
Project: 165347
Buggy source:
public boolean isCompatible(Apk apk){
  if (apk.minSdkVersion > SDK_INT)   return false;
  if (apk.features != null) {
    for (    String feat : apk.features) {
      if (ignoreTouchscreen && feat.equals("String_Node_Str")) {
      }
 else       if (!features.contains(feat)) {
        Log.d("String_Node_Str",apk.id + "String_Node_Str" + feat);
        return false;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
public boolean isCompatible(Apk apk){
  if (apk.minSdkVersion > Utils.getApi())   return false;
  if (apk.features != null) {
    for (    String feat : apk.features) {
      if (ignoreTouchscreen && feat.equals("String_Node_Str")) {
      }
 else       if (!features.contains(feat)) {
        Log.d("String_Node_Str",apk.id + "String_Node_Str" + feat);
        return false;
      }
    }
  }
  return true;
}
Program: 165348
Project: 165348
Buggy source:
public static CompatibilityChecker getChecker(Context ctx){
  CompatibilityChecker checker;
  if (SDK_INT >= 5)   checker=new EclairChecker(ctx);
 else   checker=new BasicChecker();
  Log.d("String_Node_Str","String_Node_Str" + SDK_INT + "String_Node_Str"+ checker.getClass().getName());
  return checker;
}

Fixed version (ground truth):
public static CompatibilityChecker getChecker(Context ctx){
  CompatibilityChecker checker;
  if (Utils.hasApi(5))   checker=new EclairChecker(ctx);
 else   checker=new BasicChecker();
  Log.d("String_Node_Str","String_Node_Str" + Utils.getApi() + "String_Node_Str"+ checker.getClass().getName());
  return checker;
}
Program: 165349
Project: 165349
Buggy source:
private void selectTab(int index){
  if (Build.VERSION.SDK_INT >= 11) {
    getActionBar().setSelectedNavigationItem(index);
  }
 else {
    tabHost.setCurrentTab(index);
  }
}

Fixed version (ground truth):
private void selectTab(int index){
  if (Utils.hasApi(11)) {
    getActionBar().setSelectedNavigationItem(index);
  }
 else {
    tabHost.setCurrentTab(index);
  }
}
Program: 165350
Project: 165350
Buggy source:
private void createTabs(){
  if (Build.VERSION.SDK_INT >= 11) {
    createActionBarTabs();
  }
 else {
    createOldTabs();
  }
}

Fixed version (ground truth):
private void createTabs(){
  if (Utils.hasApi(11)) {
    createActionBarTabs();
  }
 else {
    createOldTabs();
  }
}
Program: 165351
Project: 165351
Buggy source:
public void refreshUpdateTabLabel(){
  final int INDEX=2;
  CharSequence text=viewPager.getAdapter().getPageTitle(INDEX);
  if (Build.VERSION.SDK_INT >= 11) {
    getActionBar().getTabAt(INDEX).setText(text);
  }
 else {
    TextView textView=(TextView)tabHost.getTabWidget().getChildAt(2).findViewById(android.R.id.title);
    textView.setText(text);
  }
}

Fixed version (ground truth):
public void refreshUpdateTabLabel(){
  final int INDEX=2;
  CharSequence text=viewPager.getAdapter().getPageTitle(INDEX);
  if (Utils.hasApi(11)) {
    getActionBar().getTabAt(INDEX).setText(text);
  }
 else {
    TextView textView=(TextView)tabHost.getTabWidget().getChildAt(2).findViewById(android.R.id.title);
    textView.setText(text);
  }
}
Program: 165352
Project: 165352
Buggy source:
/** 
 * The first time the app is run, we will have an empty app list. If this is the case, we will attempt to update with the default repo. However, if we have tried this at least once, then don't try to do it automatically again, because the repos or internet connection may be bad.
 */
public boolean updateEmptyRepos(){
  final String TRIED_EMPTY_UPDATE="String_Node_Str";
  boolean hasTriedEmptyUpdate=getPreferences(MODE_PRIVATE).getBoolean(TRIED_EMPTY_UPDATE,false);
  if (!hasTriedEmptyUpdate) {
    Log.d("String_Node_Str","String_Node_Str");
    updateRepos();
    getPreferences(MODE_PRIVATE).edit().putBoolean(TRIED_EMPTY_UPDATE,true);
    return true;
  }
 else {
    Log.d("String_Node_Str","String_Node_Str");
    return false;
  }
}

Fixed version (ground truth):
/** 
 * The first time the app is run, we will have an empty app list. If this is the case, we will attempt to update with the default repo. However, if we have tried this at least once, then don't try to do it automatically again, because the repos or internet connection may be bad.
 */
public boolean updateEmptyRepos(){
  final String TRIED_EMPTY_UPDATE="String_Node_Str";
  boolean hasTriedEmptyUpdate=getPreferences(MODE_PRIVATE).getBoolean(TRIED_EMPTY_UPDATE,false);
  if (!hasTriedEmptyUpdate) {
    Log.d("String_Node_Str","String_Node_Str");
    getPreferences(MODE_PRIVATE).edit().putBoolean(TRIED_EMPTY_UPDATE,true).apply();
    updateRepos();
    return true;
  }
 else {
    Log.d("String_Node_Str","String_Node_Str");
    return false;
  }
}
Program: 165353
Project: 165353
Buggy source:
public void populateDetails(App app,int apkrepo){
  if (app.detail_Populated)   return;
  Cursor c=null;
  try {
    String[] cols=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
    c=db.query(TABLE_APP,cols,"String_Node_Str",new String[]{app.id},null,null,null,null);
    c.moveToFirst();
    app.detail_description=c.getString(0);
    app.detail_webURL=c.getString(1);
    app.detail_trackerURL=c.getString(2);
    app.detail_sourceURL=c.getString(3);
    app.detail_donateURL=c.getString(4);
    c.close();
    c=null;
    cols=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
    for (    Apk apk : app.apks) {
      if (apkrepo == 0 || apkrepo == apk.repo) {
        c=db.query(TABLE_APK,cols,"String_Node_Str",new String[]{apk.id,Integer.toString(apk.vercode)},null,null,null,null);
        c.moveToFirst();
        apk.detail_hash=c.getString(0);
        apk.detail_hashType=c.getString(1);
        apk.detail_size=c.getInt(2);
        apk.detail_permissions=CommaSeparatedList.make(c.getString(3));
        c.close();
        c=null;
      }
    }
    app.detail_Populated=true;
  }
  finally {
    if (c != null)     c.close();
  }
}

Fixed version (ground truth):
public void populateDetails(App app,int apkRepo){
  if (!app.detail_Populated) {
    populateAppDetails(app);
  }
  for (  Apk apk : app.apks) {
    boolean isPopulated=apk.detail_hash != null;
    if (!isPopulated) {
      populateApkDetails(apk,apkRepo);
    }
  }
}
Program: 165354
Project: 165354
Buggy source:
private void updateApkIfDifferent(Apk oldapk,Apk upapk){
  ContentValues values=new ContentValues();
  values.put("String_Node_Str",upapk.id);
  values.put("String_Node_Str",upapk.version);
  values.put("String_Node_Str",upapk.vercode);
  values.put("String_Node_Str",upapk.repo);
  values.put("String_Node_Str",upapk.detail_hash);
  values.put("String_Node_Str",upapk.detail_hashType);
  values.put("String_Node_Str",upapk.sig);
  values.put("String_Node_Str",upapk.srcname);
  values.put("String_Node_Str",upapk.detail_size);
  values.put("String_Node_Str",upapk.apkName);
  values.put("String_Node_Str",upapk.minSdkVersion);
  values.put("String_Node_Str",upapk.added == null ? "String_Node_Str" : mDateFormat.format(upapk.added));
  values.put("String_Node_Str",CommaSeparatedList.str(upapk.detail_permissions));
  values.put("String_Node_Str",CommaSeparatedList.str(upapk.features));
  values.put("String_Node_Str",upapk.compatible ? 1 : 0);
  if (oldapk != null) {
    db.update(TABLE_APK,values,"String_Node_Str" + Integer.toString(oldapk.vercode),new String[]{oldapk.id});
  }
 else {
    db.insert(TABLE_APK,null,values);
  }
}

Fixed version (ground truth):
private void updateApkIfDifferent(Apk oldapk,Apk upapk){
  ContentValues values=new ContentValues();
  values.put("String_Node_Str",upapk.id);
  values.put("String_Node_Str",upapk.version);
  values.put("String_Node_Str",upapk.vercode);
  values.put("String_Node_Str",upapk.repo);
  values.put("String_Node_Str",upapk.detail_hash);
  values.put("String_Node_Str",upapk.detail_hashType);
  values.put("String_Node_Str",upapk.sig);
  values.put("String_Node_Str",upapk.srcname);
  values.put("String_Node_Str",upapk.detail_size);
  values.put("String_Node_Str",upapk.apkName);
  values.put("String_Node_Str",upapk.minSdkVersion);
  values.put("String_Node_Str",upapk.added == null ? "String_Node_Str" : mDateFormat.format(upapk.added));
  values.put("String_Node_Str",CommaSeparatedList.str(upapk.detail_permissions));
  values.put("String_Node_Str",CommaSeparatedList.str(upapk.features));
  values.put("String_Node_Str",upapk.compatible ? 1 : 0);
  if (oldapk != null) {
    Log.d("String_Node_Str","String_Node_Str" + upapk.id + "String_Node_Str"+ upapk.detail_hash+ "String_Node_Str");
    db.update(TABLE_APK,values,"String_Node_Str" + Integer.toString(oldapk.vercode),new String[]{oldapk.id});
  }
 else {
    db.insert(TABLE_APK,null,values);
  }
}
Program: 165357
Project: 165357
Buggy source:
@Override protected void onStart(){
  super.onStart();
  db=new DB(this);
  compatChecker=db.getCompatibilityChecker();
  mPm=getPackageManager();
  ((FDroidApp)getApplication()).inActivity++;
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(getBaseContext());
  pref_cacheDownloaded=prefs.getBoolean("String_Node_Str",false);
  pref_expert=prefs.getBoolean("String_Node_Str",false);
  AppDetails old=(AppDetails)getLastNonConfigurationInstance();
  if (old != null) {
    copyState(old);
  }
 else {
    viewResetRequired=true;
  }
}

Fixed version (ground truth):
@Override protected void onStart(){
  super.onStart();
  db=new DB(this);
  compatChecker=db.getCompatibilityChecker();
  mPm=getPackageManager();
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(getBaseContext());
  pref_cacheDownloaded=prefs.getBoolean("String_Node_Str",false);
  pref_expert=prefs.getBoolean("String_Node_Str",false);
  AppDetails old=(AppDetails)getLastNonConfigurationInstance();
  if (old != null) {
    copyState(old);
  }
 else {
    viewResetRequired=true;
  }
}
Program: 165358
Project: 165358
Buggy source:
@Override protected void onStop(){
  db.close();
  db=null;
  ((FDroidApp)getApplication()).inActivity--;
  super.onStop();
}

Fixed version (ground truth):
@Override protected void onStop(){
  db.close();
  db=null;
  super.onStop();
}
Program: 165359
Project: 165359
Buggy source:
private void updateRepos(){
  pd=ProgressDialog.show(this,getString(R.string.process_wait_title),getString(R.string.process_update_msg),true);
  pd.setIcon(android.R.drawable.ic_dialog_info);
  new Thread(){
    public void run(){
      boolean success=RepoXMLHandler.doUpdates(FDroid.this,db);
      update_handler.sendEmptyMessage(success ? 0 : 1);
    }
  }
.start();
}

Fixed version (ground truth):
private void updateRepos(){
  pd=ProgressDialog.show(this,getString(R.string.process_wait_title),getString(R.string.process_update_msg),true,true);
  pd.setIcon(android.R.drawable.ic_dialog_info);
  Intent intent=new Intent(this,UpdateService.class);
  mUpdateReceiver=new UpdateReceiver(new Handler());
  intent.putExtra("String_Node_Str",mUpdateReceiver);
  startService(intent);
}
Program: 165360
Project: 165360
Buggy source:
@Override protected void onStart(){
  super.onStart();
  ((FDroidApp)getApplication()).inActivity++;
  db=new DB(this);
  triedEmptyUpdate=false;
  populateLists(true);
}

Fixed version (ground truth):
@Override protected void onStart(){
  super.onStart();
  db=new DB(this);
  triedEmptyUpdate=false;
  populateLists(true);
}
Program: 165361
Project: 165361
Buggy source:
@Override protected void onStop(){
  db.close();
  ((FDroidApp)getApplication()).inActivity--;
  super.onStop();
}

Fixed version (ground truth):
@Override protected void onStop(){
  db.close();
  super.onStop();
}
Program: 165363
Project: 165363
Buggy source:
private void updateApp(App oldapp,App upapp){
  ContentValues values=new ContentValues();
  values.put("String_Node_Str",upapp.id);
  values.put("String_Node_Str",upapp.name);
  values.put("String_Node_Str",upapp.summary);
  values.put("String_Node_Str",upapp.icon);
  values.put("String_Node_Str",upapp.description);
  values.put("String_Node_Str",upapp.license);
  values.put("String_Node_Str",upapp.category);
  values.put("String_Node_Str",upapp.webURL);
  values.put("String_Node_Str",upapp.trackerURL);
  values.put("String_Node_Str",upapp.sourceURL);
  values.put("String_Node_Str",upapp.donateURL);
  values.put("String_Node_Str",mDateFormat.format(upapp.added));
  values.put("String_Node_Str",mDateFormat.format(upapp.lastUpdated));
  values.put("String_Node_Str",upapp.marketVersion);
  values.put("String_Node_Str",upapp.marketVercode);
  values.put("String_Node_Str",CommaSeparatedList.str(upapp.antiFeatures));
  values.put("String_Node_Str",CommaSeparatedList.str(upapp.requirements));
  values.put("String_Node_Str",upapp.hasUpdates ? 1 : 0);
  if (oldapp != null) {
    db.update(TABLE_APP,values,"String_Node_Str",new String[]{oldapp.id});
  }
 else {
    db.insert(TABLE_APP,null,values);
  }
}

Fixed version (ground truth):
private void updateApp(App oldapp,App upapp){
  ContentValues values=new ContentValues();
  values.put("String_Node_Str",upapp.id);
  values.put("String_Node_Str",upapp.name);
  values.put("String_Node_Str",upapp.summary);
  values.put("String_Node_Str",upapp.icon);
  values.put("String_Node_Str",upapp.description);
  values.put("String_Node_Str",upapp.license);
  values.put("String_Node_Str",upapp.category);
  values.put("String_Node_Str",upapp.webURL);
  values.put("String_Node_Str",upapp.trackerURL);
  values.put("String_Node_Str",upapp.sourceURL);
  values.put("String_Node_Str",upapp.donateURL);
  values.put("String_Node_Str",upapp.added == null ? "String_Node_Str" : mDateFormat.format(upapp.added));
  values.put("String_Node_Str",upapp.added == null ? "String_Node_Str" : mDateFormat.format(upapp.lastUpdated));
  values.put("String_Node_Str",upapp.marketVersion);
  values.put("String_Node_Str",upapp.marketVercode);
  values.put("String_Node_Str",CommaSeparatedList.str(upapp.antiFeatures));
  values.put("String_Node_Str",CommaSeparatedList.str(upapp.requirements));
  values.put("String_Node_Str",upapp.hasUpdates ? 1 : 0);
  if (oldapp != null) {
    db.update(TABLE_APP,values,"String_Node_Str",new String[]{oldapp.id});
  }
 else {
    db.insert(TABLE_APP,null,values);
  }
}
Program: 165364
Project: 165364
Buggy source:
private void updateApkIfDifferent(Apk oldapk,Apk upapk){
  ContentValues values=new ContentValues();
  values.put("String_Node_Str",upapk.id);
  values.put("String_Node_Str",upapk.version);
  values.put("String_Node_Str",upapk.vercode);
  values.put("String_Node_Str",upapk.server);
  values.put("String_Node_Str",upapk.hash);
  values.put("String_Node_Str",upapk.hashType);
  values.put("String_Node_Str",upapk.sig);
  values.put("String_Node_Str",upapk.srcname);
  values.put("String_Node_Str",upapk.size);
  values.put("String_Node_Str",upapk.apkName);
  values.put("String_Node_Str",upapk.apkSource);
  values.put("String_Node_Str",upapk.minSdkVersion);
  values.put("String_Node_Str",mDateFormat.format(upapk.added));
  values.put("String_Node_Str",CommaSeparatedList.str(upapk.permissions));
  values.put("String_Node_Str",CommaSeparatedList.str(upapk.features));
  if (oldapk != null) {
    db.update(TABLE_APK,values,"String_Node_Str",new String[]{oldapk.id,oldapk.version});
  }
 else {
    db.insert(TABLE_APK,null,values);
  }
}

Fixed version (ground truth):
private void updateApkIfDifferent(Apk oldapk,Apk upapk){
  ContentValues values=new ContentValues();
  values.put("String_Node_Str",upapk.id);
  values.put("String_Node_Str",upapk.version);
  values.put("String_Node_Str",upapk.vercode);
  values.put("String_Node_Str",upapk.server);
  values.put("String_Node_Str",upapk.hash);
  values.put("String_Node_Str",upapk.hashType);
  values.put("String_Node_Str",upapk.sig);
  values.put("String_Node_Str",upapk.srcname);
  values.put("String_Node_Str",upapk.size);
  values.put("String_Node_Str",upapk.apkName);
  values.put("String_Node_Str",upapk.apkSource);
  values.put("String_Node_Str",upapk.minSdkVersion);
  values.put("String_Node_Str",upapk.added == null ? "String_Node_Str" : mDateFormat.format(upapk.added));
  values.put("String_Node_Str",CommaSeparatedList.str(upapk.permissions));
  values.put("String_Node_Str",CommaSeparatedList.str(upapk.features));
  if (oldapk != null) {
    db.update(TABLE_APK,values,"String_Node_Str",new String[]{oldapk.id,oldapk.version});
  }
 else {
    db.insert(TABLE_APK,null,values);
  }
}
Program: 165365
Project: 165365
Buggy source:
private void getUpdates(Vector<DB.App> apps){
  List<PackageInfo> installedPackages=mPm.getInstalledPackages(0);
  Map<String,PackageInfo> systemApks=new HashMap<String,PackageInfo>();
  Log.d("String_Node_Str","String_Node_Str");
  for (  PackageInfo appInfo : installedPackages) {
    systemApks.put(appInfo.packageName,appInfo);
  }
  for (  DB.App app : apps) {
    if (systemApks.containsKey(app.id)) {
      PackageInfo sysapk=systemApks.get(app.id);
      String version=sysapk.versionName;
      int vercode=sysapk.versionCode;
      if (app.installedVersion == null || !app.installedVersion.equals(version)) {
        setInstalledVersion(app.id,version,vercode);
        app.installedVersion=version;
      }
    }
 else {
      if (app.installedVersion != null) {
        setInstalledVersion(app.id,null,0);
        app.installedVersion=null;
      }
    }
  }
}

Fixed version (ground truth):
private void getUpdates(Vector<DB.App> apps){
  List<PackageInfo> installedPackages=mPm.getInstalledPackages(0);
  Map<String,PackageInfo> systemApks=new HashMap<String,PackageInfo>();
  Log.d("String_Node_Str","String_Node_Str");
  for (  PackageInfo appInfo : installedPackages) {
    systemApks.put(appInfo.packageName,appInfo);
  }
  for (  DB.App app : apps) {
    if (systemApks.containsKey(app.id)) {
      PackageInfo sysapk=systemApks.get(app.id);
      String version=sysapk.versionName;
      int vercode=sysapk.versionCode;
      if (app.installedVersion == null || !app.installedVersion.equals(version)) {
        setInstalledVersion(app.id,version,vercode);
        app.installedVersion=version;
        app.installedVerCode=vercode;
      }
    }
 else {
      if (app.installedVersion != null) {
        setInstalledVersion(app.id,null,0);
        app.installedVersion=null;
      }
    }
  }
}
Program: 165366
Project: 165366
Buggy source:
public void updateApplication(App upapp){
  if (updateApps == null) {
    return;
  }
  boolean found=false;
  for (  App app : updateApps) {
    if (app.id.equals(upapp.id)) {
      updateAppIfDifferent(app,upapp);
      app.updated=true;
      found=true;
      for (      Apk upapk : upapp.apks) {
        boolean afound=false;
        for (        Apk apk : app.apks) {
          if (apk.version.equals(upapk.version)) {
            updateApkIfDifferent(apk,upapk);
            apk.updated=true;
            afound=true;
            break;
          }
        }
        if (!afound) {
          updateApkIfDifferent(null,upapk);
          upapk.updated=true;
          app.apks.add(upapk);
        }
      }
      break;
    }
  }
  if (!found) {
    updateAppIfDifferent(null,upapp);
    for (    Apk upapk : upapp.apks) {
      updateApkIfDifferent(null,upapk);
      upapk.updated=true;
    }
    upapp.updated=true;
    updateApps.add(upapp);
  }
}

Fixed version (ground truth):
public void updateApplication(App upapp){
  if (updateApps == null) {
    return;
  }
  boolean found=false;
  for (  App app : updateApps) {
    if (app.id.equals(upapp.id)) {
      updateApp(app,upapp);
      app.updated=true;
      found=true;
      for (      Apk upapk : upapp.apks) {
        boolean afound=false;
        for (        Apk apk : app.apks) {
          if (apk.version.equals(upapk.version)) {
            updateApkIfDifferent(apk,upapk);
            apk.updated=true;
            afound=true;
            break;
          }
        }
        if (!afound) {
          updateApkIfDifferent(null,upapk);
          upapk.updated=true;
          app.apks.add(upapk);
        }
      }
      break;
    }
  }
  if (!found) {
    updateApp(null,upapp);
    for (    Apk upapk : upapp.apks) {
      updateApkIfDifferent(null,upapk);
      upapk.updated=true;
    }
    upapp.updated=true;
    updateApps.add(upapp);
  }
}
Program: 165369
Project: 165369
Buggy source:
private void copyState(AppDetails old){
  download=old.download;
  if (download != null) {
    downloadHandler=new DownloadHandler();
  }
  ApkListAdapter oldAdapter=(ApkListAdapter)old.getListAdapter();
  setListAdapter(new ApkListAdapter(this,oldAdapter.getItems()));
  app=old.app;
  app_currentvercode=old.app_currentvercode;
  mInstalledSignature=old.mInstalledSignature;
  mInstalledSigID=old.mInstalledSigID;
  resetViews();
}

Fixed version (ground truth):
private void copyState(AppDetails old){
  ApkListAdapter oldAdapter=(ApkListAdapter)old.getListAdapter();
  setListAdapter(new ApkListAdapter(this,oldAdapter.getItems()));
  if (old.downloadHandler != null)   downloadHandler=new DownloadHandler(old.downloadHandler);
  app=old.app;
  app_currentvercode=old.app_currentvercode;
  mInstalledSignature=old.mInstalledSignature;
  mInstalledSigID=old.mInstalledSigID;
  resetViews();
}
Program: 165370
Project: 165370
Buggy source:
@Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
switch (requestCode) {
case REQUEST_INSTALL:
    if (!pref_cacheDownloaded && download != null) {
      File file=new File(download.localFile());
      Log.d("String_Node_Str","String_Node_Str" + file);
      file.delete();
      download=null;
    }
  viewResetRequired=true;
break;
case REQUEST_UNINSTALL:
viewResetRequired=true;
break;
}
}

Fixed version (ground truth):
@Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
switch (requestCode) {
case REQUEST_INSTALL:
    if (downloadHandler != null) {
      downloadHandler.cleanUp();
      downloadHandler=null;
    }
  viewResetRequired=true;
break;
case REQUEST_UNINSTALL:
viewResetRequired=true;
break;
}
}
Program: 165371
Project: 165371
Buggy source:
public void onCancel(DialogInterface dialog){
  if (download != null) {
    download.interrupt();
  }
}

Fixed version (ground truth):
public void onCancel(DialogInterface dialog){
  downloadHandler.cancel();
}
Program: 165372
Project: 165372
Buggy source:
@Override protected void onDestroy(){
  if (download != null && !stateRetained) {
    download.interrupt();
  }
  if (downloadHandler != null) {
    downloadHandler.destroy();
  }
  super.onDestroy();
}

Fixed version (ground truth):
@Override protected void onDestroy(){
  if (downloadHandler != null) {
    if (!stateRetained)     downloadHandler.cancel();
    downloadHandler.destroy();
  }
  super.onDestroy();
}
Program: 165373
Project: 165373
Buggy source:
public boolean updateProgress(){
  boolean finished=false;
switch (download.getStatus()) {
case RUNNING:
    if (pd == null) {
      pd=createProgressDialog(download.remoteFile(),download.getProgress(),download.getMax());
    }
 else {
      pd.setProgress(download.getProgress());
    }
  break;
case ERROR:
if (pd != null) pd.dismiss();
String text;
if (download.getErrorType() == Downloader.Error.CORRUPT) text=getString(R.string.corrupt_download);
 else text=download.getErrorMessage();
Toast.makeText(AppDetails.this,text,Toast.LENGTH_LONG).show();
finished=true;
break;
case DONE:
if (pd != null) pd.dismiss();
installApk(download.localFile());
finished=true;
break;
case CANCELLED:
Toast.makeText(AppDetails.this,getString(R.string.download_cancelled),Toast.LENGTH_SHORT).show();
finished=true;
break;
}
return finished;
}

Fixed version (ground truth):
public boolean updateProgress(){
  boolean finished=false;
switch (download.getStatus()) {
case RUNNING:
    if (pd == null) {
      pd=createProgressDialog(download.remoteFile(),download.getProgress(),download.getMax());
    }
 else {
      pd.setProgress(download.getProgress());
    }
  break;
case ERROR:
if (pd != null) pd.dismiss();
String text;
if (download.getErrorType() == Downloader.Error.CORRUPT) text=getString(R.string.corrupt_download);
 else text=download.getErrorMessage();
Toast.makeText(AppDetails.this,text,Toast.LENGTH_LONG).show();
finished=true;
break;
case DONE:
if (pd != null) pd.dismiss();
installApk(localFile=download.localFile());
finished=true;
break;
case CANCELLED:
Toast.makeText(AppDetails.this,getString(R.string.download_cancelled),Toast.LENGTH_SHORT).show();
finished=true;
break;
}
return finished;
}
Program: 165374
Project: 165374
Buggy source:
@Override public void handleMessage(Message msg){
  boolean finished=updateProgress();
  if (!finished) {
    sendMessageDelayed(obtainMessage(),50);
  }
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  if (download == null)   return;
  boolean finished=updateProgress();
  if (finished)   download=null;
 else   sendMessageDelayed(obtainMessage(),50);
}
Program: 165375
Project: 165375
Buggy source:
public DownloadHandler(){
  startUpdates();
}

Fixed version (ground truth):
public DownloadHandler(DownloadHandler oldHandler){
  if (oldHandler != null) {
    download=oldHandler.download;
    localFile=oldHandler.localFile;
  }
  startUpdates();
}
Program: 165376
Project: 165376
Buggy source:
@Override protected void onResume(){
  if (viewResetRequired) {
    reset();
    viewResetRequired=false;
  }
  if (download != null && downloadHandler != null) {
    downloadHandler.startUpdates();
  }
  super.onResume();
}

Fixed version (ground truth):
@Override protected void onResume(){
  if (viewResetRequired) {
    reset();
    viewResetRequired=false;
  }
  if (downloadHandler != null) {
    downloadHandler.startUpdates();
  }
  super.onResume();
}
Program: 165377
Project: 165377
Buggy source:
private ProgressDialog createProgressDialog(String file,int p,int max){
  final ProgressDialog pd=new ProgressDialog(this);
  pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
  pd.setMessage(getString(R.string.download_server) + "String_Node_Str" + file);
  pd.setMax(max);
  pd.setProgress(p);
  pd.setCancelable(true);
  pd.setOnCancelListener(new DialogInterface.OnCancelListener(){
    public void onCancel(    DialogInterface dialog){
      if (download != null) {
        download.interrupt();
      }
    }
  }
);
  pd.setButton(getString(R.string.cancel),new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      pd.cancel();
    }
  }
);
  pd.show();
  return pd;
}

Fixed version (ground truth):
private ProgressDialog createProgressDialog(String file,int p,int max){
  final ProgressDialog pd=new ProgressDialog(this);
  pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
  pd.setMessage(getString(R.string.download_server) + "String_Node_Str" + file);
  pd.setMax(max);
  pd.setProgress(p);
  pd.setCancelable(true);
  pd.setOnCancelListener(new DialogInterface.OnCancelListener(){
    public void onCancel(    DialogInterface dialog){
      downloadHandler.cancel();
    }
  }
);
  pd.setButton(getString(R.string.cancel),new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      pd.cancel();
    }
  }
);
  pd.show();
  return pd;
}
Program: 165378
Project: 165378
Buggy source:
private void install(){
  if (mInstalledSigID != null && curapk.sig != null && !curapk.sig.equals(mInstalledSigID)) {
    AlertDialog.Builder builder=new AlertDialog.Builder(this);
    builder.setMessage(R.string.SignatureMismatch).setPositiveButton(getString(R.string.ok),new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int id){
        dialog.cancel();
      }
    }
);
    AlertDialog alert=builder.create();
    alert.show();
    return;
  }
  download=new Downloader(curapk);
  downloadHandler=new DownloadHandler();
  download.start();
}

Fixed version (ground truth):
private void install(){
  if (mInstalledSigID != null && curapk.sig != null && !curapk.sig.equals(mInstalledSigID)) {
    AlertDialog.Builder builder=new AlertDialog.Builder(this);
    builder.setMessage(R.string.SignatureMismatch).setPositiveButton(getString(R.string.ok),new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int id){
        dialog.cancel();
      }
    }
);
    AlertDialog alert=builder.create();
    alert.show();
    return;
  }
  downloadHandler=new DownloadHandler(curapk);
}
Program: 165380
Project: 165380
Buggy source:
@Override public void characters(char[] ch,int start,int length) throws SAXException {
  super.characters(ch,start,length);
  String str=new String(ch).substring(start,start + length);
  if (curapk != null && curel != null) {
    if (curel == "String_Node_Str") {
      curapk.version=str;
    }
 else     if (curel == "String_Node_Str") {
      try {
        curapk.vercode=Integer.parseInt(str);
      }
 catch (      NumberFormatException ex) {
        curapk.vercode=0;
      }
    }
 else     if (curel == "String_Node_Str") {
      try {
        curapk.size=Integer.parseInt(str);
      }
 catch (      NumberFormatException ex) {
        curapk.size=0;
      }
    }
 else     if (curel == "String_Node_Str") {
      curapk.hash=str;
    }
 else     if (curel == "String_Node_Str") {
      curapk.apkName=str;
    }
  }
 else   if (curapp != null && curel != null) {
    if (curel == "String_Node_Str") {
      curapp.id=str;
    }
 else     if (curel == "String_Node_Str") {
      curapp.name=str;
    }
 else     if (curel == "String_Node_Str") {
      curapp.icon=str;
    }
 else     if (curel == "String_Node_Str") {
      curapp.description=str;
    }
 else     if (curel == "String_Node_Str") {
      curapp.summary=str;
    }
 else     if (curel == "String_Node_Str") {
      curapp.license=str;
    }
 else     if (curel == "String_Node_Str") {
      curapp.sourceURL=str;
    }
 else     if (curel == "String_Node_Str") {
      curapp.webURL=str;
    }
 else     if (curel == "String_Node_Str") {
      curapp.trackerURL=str;
    }
 else     if (curel == "String_Node_Str") {
      curapp.marketVersion=str;
    }
 else     if (curel == "String_Node_Str") {
      try {
        curapp.marketVercode=Integer.parseInt(str);
      }
 catch (      NumberFormatException ex) {
        curapp.marketVercode=0;
      }
    }
  }
}

Fixed version (ground truth):
@Override public void characters(char[] ch,int start,int length) throws SAXException {
  super.characters(ch,start,length);
  String str=new String(ch).substring(start,start + length);
  if (curchars == null)   curchars=str;
 else   curchars+=str;
}
Program: 165381
Project: 165381
Buggy source:
@Override public void endElement(String uri,String localName,String qName) throws SAXException {
  super.endElement(uri,localName,qName);
  if (localName == "String_Node_Str" && curapp != null) {
    Log.d("String_Node_Str","String_Node_Str" + curapp.id);
    db.updateApplication(curapp);
    getIcon(curapp);
    curapp=null;
  }
 else   if (localName == "String_Node_Str" && curapk != null && curapp != null) {
    Log.d("String_Node_Str","String_Node_Str" + curapk.version + "String_Node_Str");
    curapp.apks.add(curapk);
    curapk=null;
  }
 else {
    curel=null;
  }
}

Fixed version (ground truth):
@Override public void endElement(String uri,String localName,String qName) throws SAXException {
  super.endElement(uri,localName,qName);
  String curel=localName;
  String str=curchars;
  if (curel == "String_Node_Str" && curapp != null) {
    Log.d("String_Node_Str","String_Node_Str" + curapp.id);
    db.updateApplication(curapp);
    getIcon(curapp);
    curapp=null;
  }
 else   if (curel == "String_Node_Str" && curapk != null && curapp != null) {
    Log.d("String_Node_Str","String_Node_Str" + curapk.version + "String_Node_Str");
    curapp.apks.add(curapk);
    curapk=null;
  }
 else   if (curapk != null && str != null) {
    if (curel == "String_Node_Str") {
      curapk.version=str;
    }
 else     if (curel == "String_Node_Str") {
      try {
        curapk.vercode=Integer.parseInt(str);
      }
 catch (      NumberFormatException ex) {
        curapk.vercode=0;
      }
    }
 else     if (curel == "String_Node_Str") {
      try {
        curapk.size=Integer.parseInt(str);
      }
 catch (      NumberFormatException ex) {
        curapk.size=0;
      }
    }
 else     if (curel == "String_Node_Str") {
      curapk.hash=str;
    }
 else     if (curel == "String_Node_Str") {
      curapk.apkName=str;
    }
  }
 else   if (curapp != null && str != null) {
    if (curel == "String_Node_Str") {
      Log.d("String_Node_Str","String_Node_Str" + str);
      curapp.id=str;
    }
 else     if (curel == "String_Node_Str") {
      curapp.name=str;
    }
 else     if (curel == "String_Node_Str") {
      curapp.icon=str;
    }
 else     if (curel == "String_Node_Str") {
      curapp.description=str;
    }
 else     if (curel == "String_Node_Str") {
      curapp.summary=str;
    }
 else     if (curel == "String_Node_Str") {
      curapp.license=str;
    }
 else     if (curel == "String_Node_Str") {
      curapp.sourceURL=str;
    }
 else     if (curel == "String_Node_Str") {
      curapp.webURL=str;
    }
 else     if (curel == "String_Node_Str") {
      curapp.trackerURL=str;
    }
 else     if (curel == "String_Node_Str") {
      curapp.marketVersion=str;
    }
 else     if (curel == "String_Node_Str") {
      try {
        curapp.marketVercode=Integer.parseInt(str);
      }
 catch (      NumberFormatException ex) {
        curapp.marketVercode=0;
      }
    }
  }
}
Program: 165382
Project: 165382
Buggy source:
@Override public void startElement(String uri,String localName,String qName,Attributes attributes) throws SAXException {
  super.startElement(uri,localName,qName,attributes);
  if (localName == "String_Node_Str" && curapp == null) {
    Log.d("String_Node_Str","String_Node_Str" + mserver);
    curapp=new DB.App();
  }
 else   if (localName == "String_Node_Str" && curapp != null && curapk == null) {
    Log.d("String_Node_Str","String_Node_Str" + curapp.id);
    curapk=new DB.Apk();
    curapk.id=curapp.id;
    curapk.server=mserver;
  }
 else {
    curel=localName;
  }
}

Fixed version (ground truth):
@Override public void startElement(String uri,String localName,String qName,Attributes attributes) throws SAXException {
  super.startElement(uri,localName,qName,attributes);
  if (localName == "String_Node_Str" && curapp == null) {
    Log.d("String_Node_Str","String_Node_Str" + mserver);
    curapp=new DB.App();
  }
 else   if (localName == "String_Node_Str" && curapp != null && curapk == null) {
    Log.d("String_Node_Str","String_Node_Str" + curapp.id);
    curapk=new DB.Apk();
    curapk.id=curapp.id;
    curapk.server=mserver;
  }
  curchars=null;
}
Program: 165383
Project: 165383
Buggy source:
void runBenchmark(){
  try {
    long start, time;
    generateData();
    OutputStream os=file.openOutputStream();
    start=JVM.monotonicTimeMillis();
    writeUtf8Data(os);
    time=JVM.monotonicTimeMillis() - start;
    System.out.println("String_Node_Str" + time);
    os.flush();
    os.close();
    InputStream is=file.openInputStream();
    start=JVM.monotonicTimeMillis();
    readUtf8Data(is);
    System.out.println("String_Node_Str" + time);
    is.close();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
void runBenchmark(){
  try {
    long start, time;
    generateData();
    OutputStream os=file.openOutputStream();
    start=JVM.monotonicTimeMillis();
    writeUtf8Data(os);
    time=JVM.monotonicTimeMillis() - start;
    System.out.println("String_Node_Str" + time);
    os.flush();
    os.close();
    InputStream is=file.openInputStream();
    start=JVM.monotonicTimeMillis();
    readUtf8Data(is);
    time=JVM.monotonicTimeMillis() - start;
    System.out.println("String_Node_Str" + time);
    is.close();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 165384
Project: 165384
Buggy source:
void runBenchmark(){
  try {
    long start, time;
    generateData();
    OutputStream os=file.openOutputStream();
    start=JVM.monotonicTimeMillis();
    writeUtf8Data(os);
    time=JVM.monotonicTimeMillis() - start;
    System.out.println("String_Node_Str" + time);
    os.flush();
    os.close();
    InputStream is=file.openInputStream();
    start=JVM.monotonicTimeMillis();
    readUtf8Data(is);
    System.out.println("String_Node_Str" + time);
    is.close();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
void runBenchmark(){
  try {
    long start, time;
    generateData();
    OutputStream os=file.openOutputStream();
    start=JVM.monotonicTimeMillis();
    writeUtf8Data(os);
    time=JVM.monotonicTimeMillis() - start;
    System.out.println("String_Node_Str" + time);
    os.flush();
    os.close();
    InputStream is=file.openInputStream();
    start=JVM.monotonicTimeMillis();
    readUtf8Data(is);
    time=JVM.monotonicTimeMillis() - start;
    System.out.println("String_Node_Str" + time);
    is.close();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 165385
Project: 165385
Buggy source:
public static boolean isLowerCase(char ch){
  return DefaultCaseConverter.toLowerCase(ch) == ch;
}

Fixed version (ground truth):
/** 
 * Determines if the specified character is a lowercase character. The default case converter in CLDC only supports the ISO Latin-1  range of characters. <p> Of the ISO Latin-1 characters (character codes 0x0000 through 0x00FF), the following are lowercase: <p> a b c d e f g h i j k l m n o p q r s t u v w x y z &#92;u00DF &#92;u00E0 &#92;u00E1 &#92;u00E2 &#92;u00E3 &#92;u00E4 &#92;u00E5 &#92;u00E6 &#92;u00E7 &#92;u00E8 &#92;u00E9 &#92;u00EA &#92;u00EB &#92;u00EC &#92;u00ED &#92;u00EE &#92;u00EF &#92;u00F0 &#92;u00F1 &#92;u00F2 &#92;u00F3 &#92;u00F4 &#92;u00F5 &#92;u00F6 &#92;u00F8 &#92;u00F9 &#92;u00FA &#92;u00FB &#92;u00FC &#92;u00FD &#92;u00FE &#92;u00FF
 * @param ch   the character to be tested.
 * @return  <code>true</code> if the character is lowercase;<code>false</code> otherwise.
 * @since   JDK1.0
 */
public static boolean isLowerCase(char ch){
  return (ch >= 'a' && ch <= 'z') || (ch >= 0xDF && ch <= 0xF6) || (ch >= 0xF8 && ch <= 0xFF);
}
Program: 165386
Project: 165386
Buggy source:
public static native char toLowerCase(char ch);

Fixed version (ground truth):
/** 
 * The given character is mapped to its lowercase equivalent; if the character has no lowercase equivalent, the character itself is returned.  The default case converter in CLDC only supports the ISO Latin-1 range of characters.
 * @param ch   the character to be converted.
 * @return  the lowercase equivalent of the character, if any;otherwise the character itself.
 * @see java.lang.Character#isLowerCase(char)
 * @see java.lang.Character#isUpperCase(char)
 * @see java.lang.Character#toUpperCase(char)
 * @since   JDK1.0
 */
public static char toLowerCase(char ch){
  if (isUpperCase(ch)) {
    if (ch <= 'Z') {
      return (char)(ch + ('a' - 'A'));
    }
 else {
      return (char)(ch + 0x20);
    }
  }
 else {
    return ch;
  }
}
Program: 165387
Project: 165387
Buggy source:
public static native char toUpperCase(char ch);

Fixed version (ground truth):
/** 
 * Converts the character argument to uppercase; if the character has no lowercase equivalent, the character itself is returned.  The default case converter in CLDC only supports the ISO Latin-1 range of characters.
 * @param ch   the character to be converted.
 * @return  the uppercase equivalent of the character, if any;otherwise the character itself.
 * @see java.lang.Character#isLowerCase(char)
 * @see java.lang.Character#isUpperCase(char)
 * @see java.lang.Character#toLowerCase(char)
 * @since   JDK1.0
 */
public static char toUpperCase(char ch){
  if (isLowerCase(ch)) {
    if (ch <= 'z') {
      return (char)(ch - ('a' - 'A'));
    }
 else {
      return (char)(ch - 0x20);
    }
  }
 else {
    return ch;
  }
}
Program: 165388
Project: 165388
Buggy source:
public static boolean isUpperCase(char ch){
  return DefaultCaseConverter.toUpperCase(ch) == ch;
}

Fixed version (ground truth):
/** 
 * Determines if the specified character is an uppercase character. The default case converter in CLDC only supports the ISO Latin-1  range of characters. <p> Of the ISO Latin-1 characters (character codes 0x0000 through 0x00FF), the following are uppercase: <p> A B C D E F G H I J K L M N O P Q R S T U V W X Y Z &#92;u00C0 &#92;u00C1 &#92;u00C2 &#92;u00C3 &#92;u00C4 &#92;u00C5 &#92;u00C6 &#92;u00C7 &#92;u00C8 &#92;u00C9 &#92;u00CA &#92;u00CB &#92;u00CC &#92;u00CD &#92;u00CE &#92;u00CF &#92;u00D0 &#92;u00D1 &#92;u00D2 &#92;u00D3 &#92;u00D4 &#92;u00D5 &#92;u00D6 &#92;u00D8 &#92;u00D9 &#92;u00DA &#92;u00DB &#92;u00DC &#92;u00DD &#92;u00DE
 * @param ch   the character to be tested.
 * @return  <code>true</code> if the character is uppercase;<code>false</code> otherwise.
 * @see java.lang.Character#isLowerCase(char)
 * @see java.lang.Character#toUpperCase(char)
 * @since   1.0
 */
public static boolean isUpperCase(char ch){
  return (ch >= 'A' && ch <= 'Z') || (ch >= 0xC0 && ch <= 0xD6) || (ch >= 0xD8 && ch <= 0xDE);
}
Program: 165389
Project: 165389
Buggy source:
private byte[] read(InputStream is) throws IOException {
  int l=is.available();
  byte[] buffer=new byte[l + 1];
  int length=0;
  while ((l=is.read(buffer,length,buffer.length - length)) != -1) {
    length+=l;
    if (length == buffer.length) {
      byte[] b=new byte[buffer.length + 4096];
      System.arraycopy(buffer,0,b,0,length);
      buffer=b;
    }
  }
  return buffer;
}

Fixed version (ground truth):
private byte[] read(InputStream is) throws IOException {
  int l=is.available();
  byte[] buffer=new byte[l + 1];
  int length=0;
  while ((l=is.read(buffer,length,buffer.length - length)) != -1) {
    length+=l;
    if (length == buffer.length) {
      byte[] b=new byte[buffer.length + 4096];
      System.arraycopy(buffer,0,b,0,length);
      buffer=b;
    }
  }
  if (length < buffer.length) {
    byte[] b=new byte[length];
    System.arraycopy(buffer,0,b,0,length);
    buffer=b;
  }
  return buffer;
}