nus-yam/ex-repair huggingface dataset:
Program: 64734
Project: 64734
Buggy source:
/** 
 * Writes the decision encodings.variable values of the <code>Solution</code> solutions objects into the set in a file.
 * @param path The output file name
 */
public void printVariablesToFile(String path) throws IOException {
  FileOutputStream fos=new FileOutputStream(path);
  OutputStreamWriter osw=new OutputStreamWriter(fos);
  BufferedWriter bw=new BufferedWriter(osw);
  if (isEmtpy()) {
    int numberOfVariables=solutionsList_.get(0).getDecisionVariables().length;
    for (    Solution aSolutionsList : solutionsList_) {
      for (int j=0; j < numberOfVariables; j++) {
        bw.write(aSolutionsList.getDecisionVariables()[j].toString() + "String_Node_Str");
      }
      bw.newLine();
    }
  }
  bw.close();
}

Fixed version (ground truth):
/** 
 * Writes the decision encodings.variable values of the <code>Solution</code> solutions objects into the set in a file.
 * @param path The output file name
 */
public void printVariablesToFile(String path) throws IOException {
  FileOutputStream fos=new FileOutputStream(path);
  OutputStreamWriter osw=new OutputStreamWriter(fos);
  BufferedWriter bw=new BufferedWriter(osw);
  if (!isEmtpy()) {
    int numberOfVariables=solutionsList_.get(0).getDecisionVariables().length;
    for (    Solution aSolutionsList : solutionsList_) {
      for (int j=0; j < numberOfVariables; j++) {
        bw.write(aSolutionsList.getDecisionVariables()[j].toString() + "String_Node_Str");
      }
      bw.newLine();
    }
  }
  bw.close();
}
Program: 64735
Project: 64735
Buggy source:
/** 
 * Constructor
 */
public SMPSO_Settings(String problem){
  super(problem);
  Object[] problemParams={"String_Node_Str"};
  try {
    problem_=(new ProblemFactory()).getProblem(problemName_,problemParams);
  }
 catch (  JMException e) {
    Configuration.logger_.log(Level.SEVERE,"String_Node_Str",e);
  }
  swarmSize_=100;
  maxIterations_=250;
  archiveSize_=100;
  mutationDistributionIndex_=20.0;
  mutationProbability_=1.0 / problem_.getNumberOfVariables();
  c1Max_=2.5;
  c1Min_=1.5;
  c2Max_=2.5;
  c2Min_=1.5;
  weightMax_=0.1;
  weightMin_=0.1;
  changeVelocity1=-1;
  changeVelocity2=-1;
}

Fixed version (ground truth):
/** 
 * Constructor
 */
public SMPSO_Settings(String problem){
  super(problem);
  Object[] problemParams={"String_Node_Str"};
  try {
    problem_=(new ProblemFactory()).getProblem(problemName_,problemParams);
  }
 catch (  JMException e) {
    Configuration.logger_.log(Level.SEVERE,"String_Node_Str",e);
  }
  swarmSize_=100;
  maxIterations_=250;
  archiveSize_=100;
  mutationDistributionIndex_=20.0;
  mutationProbability_=1.0 / problem_.getNumberOfVariables();
  c1Max_=2.5;
  c1Min_=1.5;
  c2Max_=2.5;
  c2Min_=1.5;
  weightMax_=0.1;
  weightMin_=0.1;
  changeVelocity1_=-1;
  changeVelocity2_=-1;
}
Program: 64737
Project: 64737
Buggy source:
@Test public void testDeletingNodesWithTwoLeaves() throws Exception {
  AvlNode<Integer> node;
  node=new AvlNode<Integer>(20);
  avlTree_.insertAvlNode(node);
  node=new AvlNode<Integer>(8);
  avlTree_.insertAvlNode(node);
  node=new AvlNode<Integer>(22);
  avlTree_.insertAvlNode(node);
  node=new AvlNode<Integer>(4);
  avlTree_.insertAvlNode(node);
  node=new AvlNode<Integer>(12);
  avlTree_.insertAvlNode(node);
  node=new AvlNode<Integer>(24);
  avlTree_.insertAvlNode(node);
  node=new AvlNode<Integer>(10);
  avlTree_.insertAvlNode(node);
  node=new AvlNode<Integer>(14);
  avlTree_.insertAvlNode(node);
  String expected="String_Node_Str";
  assertEquals("String_Node_Str",expected,avlTree_.toString());
  avlTree_.delete(12);
  node=avlTree_.search(8);
  assertEquals("String_Node_Str",14,node.getRight().getItem());
  assertEquals("String_Node_Str","String_Node_Str",avlTree_.toString());
  avlTree_.delete(8);
  assertEquals("String_Node_Str",10,avlTree_.getTop().getLeft().getItem());
  assertEquals("String_Node_Str","String_Node_Str",avlTree_.toString());
}

Fixed version (ground truth):
@Test public void testDeletingNodesWithTwoLeaves() throws Exception {
  AvlNode<Integer> node;
  node=new AvlNode<Integer>(20);
  avlTree_.insertAvlNode(node);
  node=new AvlNode<Integer>(8);
  avlTree_.insertAvlNode(node);
  node=new AvlNode<Integer>(22);
  avlTree_.insertAvlNode(node);
  node=new AvlNode<Integer>(4);
  avlTree_.insertAvlNode(node);
  node=new AvlNode<Integer>(12);
  avlTree_.insertAvlNode(node);
  node=new AvlNode<Integer>(24);
  avlTree_.insertAvlNode(node);
  node=new AvlNode<Integer>(10);
  avlTree_.insertAvlNode(node);
  node=new AvlNode<Integer>(14);
  avlTree_.insertAvlNode(node);
  String expected="String_Node_Str";
  assertEquals("String_Node_Str",expected,avlTree_.toString());
  avlTree_.delete(12);
  node=avlTree_.search(8);
  assertEquals("String_Node_Str",14,(int)node.getRight().getItem());
  assertEquals("String_Node_Str","String_Node_Str",avlTree_.toString());
  avlTree_.delete(8);
  assertEquals("String_Node_Str",10,(int)avlTree_.getTop().getLeft().getItem());
  assertEquals("String_Node_Str","String_Node_Str",avlTree_.toString());
}
Program: 64738
Project: 64738
Buggy source:
/** 
 * Constructor
 */
public dMOPSO_Settings(String problem){
  super(problem);
  Object[] problemParams={"String_Node_Str"};
  try {
    problem_=(new ProblemFactory()).getProblem(problemName_,problemParams);
  }
 catch (  JMException e) {
    e.printStackTrace();
  }
  swarmSize_=300;
  maxIterations_=250;
  maxAge_=2;
  functionType_="String_Node_Str";
  dataDirectory_="String_Node_Str";
}

Fixed version (ground truth):
/** 
 * Constructor
 */
public dMOPSO_Settings(String problem){
  super(problem);
  Object[] problemParams={"String_Node_Str"};
  try {
    problem_=(new ProblemFactory()).getProblem(problemName_,problemParams);
  }
 catch (  JMException e) {
    e.printStackTrace();
  }
  swarmSize_=100;
  maxIterations_=250;
  maxAge_=2;
  functionType_="String_Node_Str";
  dataDirectory_="String_Node_Str";
}
Program: 64739
Project: 64739
Buggy source:
/** 
 * Evaluates a solution
 * @param solution The solution to evaluate
 * @throws jmetal.util.JMException
 */
public void evaluate(Solution solution) throws JMException {
  Variable[] decisionVariables=solution.getDecisionVariables();
  double[] x=new double[decisionVariables.length];
  double[] f=new double[10];
  for (int i=0; i < decisionVariables.length; i++) {
    x[i]=decisionVariables[i].getValue();
  }
  try {
    testFunc_.test_func(x,f,numberOfVariables_,populationSize_,problemID_);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  solution.setObjective(0,f[0]);
}

Fixed version (ground truth):
/** 
 * Evaluates a solution
 * @param solution The solution to evaluate
 * @throws jmetal.util.JMException
 */
public void evaluate(Solution solution) throws JMException {
  Variable[] decisionVariables=solution.getDecisionVariables();
  double[] x=new double[decisionVariables.length];
  double[] f=new double[10];
  for (int i=0; i < decisionVariables.length; i++) {
    x[i]=decisionVariables[i].getValue();
  }
  try {
    testFunc_.test_func(x,f,numberOfVariables_,3,problemID_);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  solution.setObjective(0,f[0]);
}
Program: 64741
Project: 64741
Buggy source:
@Test public void initParamsTest(){
  assertEquals("String_Node_Str",40,(int)standardPSO_.getInputParameter("String_Node_Str"));
  assertEquals("String_Node_Str",5000,(int)standardPSO_.getInputParameter("String_Node_Str"));
  assertEquals("String_Node_Str",3,(int)standardPSO_.getInputParameter("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void initParamsTest(){
  assertEquals("String_Node_Str",40,((Integer)standardPSO_.getInputParameter("String_Node_Str")).intValue());
  assertEquals("String_Node_Str",5000,((Integer)standardPSO_.getInputParameter("String_Node_Str")).intValue());
  assertEquals("String_Node_Str",3,((Integer)standardPSO_.getInputParameter("String_Node_Str")).intValue());
}
Program: 64743
Project: 64743
Buggy source:
/** 
 * Writes the decision variable values of the <code>Solution</code> solutions objects into the set in a file.
 * @param path The output file name
 */
public void printVariablesToFile(String path){
  try {
    FileOutputStream fos=new FileOutputStream(path);
    OutputStreamWriter osw=new OutputStreamWriter(fos);
    BufferedWriter bw=new BufferedWriter(osw);
    int numberOfVariables=solutionsList_.get(0).getDecisionVariables().length;
    for (int i=0; i < solutionsList_.size(); i++) {
      for (int j=0; j < numberOfVariables; j++)       bw.write(solutionsList_.get(i).getDecisionVariables()[j].toString() + "String_Node_Str");
      bw.newLine();
    }
    bw.close();
  }
 catch (  IOException e) {
    Configuration.logger_.severe("String_Node_Str");
    e.printStackTrace();
  }
}

Fixed version (ground truth):
/** 
 * Writes the decision variable values of the <code>Solution</code> solutions objects into the set in a file.
 * @param path The output file name
 */
public void printVariablesToFile(String path){
  try {
    FileOutputStream fos=new FileOutputStream(path);
    OutputStreamWriter osw=new OutputStreamWriter(fos);
    BufferedWriter bw=new BufferedWriter(osw);
    if (size() > 0) {
      int numberOfVariables=solutionsList_.get(0).getDecisionVariables().length;
      for (int i=0; i < solutionsList_.size(); i++) {
        for (int j=0; j < numberOfVariables; j++)         bw.write(solutionsList_.get(i).getDecisionVariables()[j].toString() + "String_Node_Str");
        bw.newLine();
      }
    }
    bw.close();
  }
 catch (  IOException e) {
    Configuration.logger_.severe("String_Node_Str");
    e.printStackTrace();
  }
}
Program: 64744
Project: 64744
Buggy source:
/** 
 * Creates a new OneZeroMax problem instance
 * @param numberOfBits Length of the problem
 */
public OneZeroMax(String solutionType,Integer numberOfBits) throws ClassNotFoundException {
  numberOfVariables_=1;
  numberOfObjectives_=2;
  numberOfConstraints_=0;
  problemName_="String_Node_Str";
  solutionType_=new BinarySolutionType(this);
  length_=new int[numberOfVariables_];
  length_[0]=numberOfBits;
  if (solutionType.compareTo("String_Node_Str") == 0)   solutionType_=new BinarySolutionType(this);
 else {
    System.out.println("String_Node_Str" + solutionType + "String_Node_Str");
    System.exit(-1);
  }
}

Fixed version (ground truth):
/** 
 * Creates a new OneZeroMax problem instance
 * @param solutionType Solution type
 * @param numberOfBits Length of the problem
 */
public OneZeroMax(String solutionType,Integer numberOfBits) throws ClassNotFoundException {
  numberOfVariables_=1;
  numberOfObjectives_=2;
  numberOfConstraints_=0;
  problemName_="String_Node_Str";
  solutionType_=new BinarySolutionType(this);
  length_=new int[numberOfVariables_];
  length_[0]=numberOfBits;
  if (solutionType.compareTo("String_Node_Str") == 0)   solutionType_=new BinarySolutionType(this);
 else {
    System.out.println("String_Node_Str" + solutionType + "String_Node_Str");
    System.exit(-1);
  }
}
Program: 64745
Project: 64745
Buggy source:
/** 
 * Evaluates a solution 
 * @param solution The solution to evaluate
 */
public void evaluate(Solution solution){
  Binary variable;
  int counterOnes;
  int counterZeroes;
  variable=((Binary)solution.getDecisionVariables()[0]);
  counterOnes=0;
  counterZeroes=0;
  for (int i=0; i < variable.getNumberOfBits(); i++)   if (variable.bits_.get(i) == true)   counterOnes++;
 else   counterZeroes++;
  solution.setObjective(0,-1.0 * counterOnes);
  solution.setObjective(0,-1.0 * counterZeroes);
}

Fixed version (ground truth):
/** 
 * Evaluates a solution 
 * @param solution The solution to evaluate
 */
public void evaluate(Solution solution){
  Binary variable;
  int counterOnes;
  int counterZeroes;
  variable=((Binary)solution.getDecisionVariables()[0]);
  counterOnes=0;
  counterZeroes=0;
  for (int i=0; i < variable.getNumberOfBits(); i++)   if (variable.bits_.get(i) == true)   counterOnes++;
 else   counterZeroes++;
  solution.setObjective(0,-1.0 * counterOnes);
  solution.setObjective(1,-1.0 * counterZeroes);
}
Program: 64749
Project: 64749
Buggy source:
public boolean validateData(){
  boolean isTransfer=mCommon.transactionEntity.getTransactionType().equals(TransactionTypes.Transfer);
  Core core=new Core(mContext);
  if (isTransfer) {
    if (mCommon.transactionEntity.getAccountToId() == Constants.NOT_SET) {
      return false;
    }
    if (mCommon.transactionEntity.getAccountToId().equals(mCommon.transactionEntity.getAccountId())) {
      return false;
    }
    if (this.mCommon.transactionEntity.getAmountTo().toDouble() <= 0) {
      return false;
    }
  }
 else {
    if (!mCommon.transactionEntity.hasPayee()) {
      return false;
    }
  }
  if (mCommon.transactionEntity.getAmount().toDouble() <= 0) {
    return false;
  }
  boolean hasCategory=mCommon.transactionEntity.hasCategory();
  if (!hasCategory && !isTransfer) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
public boolean validateData(){
  boolean isTransfer=mCommon.transactionEntity.getTransactionType().equals(TransactionTypes.Transfer);
  Core core=new Core(mContext);
  if (mCommon.transactionEntity.getAccountId() == Constants.NOT_SET) {
    return false;
  }
  if (isTransfer) {
    if (mCommon.transactionEntity.getAccountToId() == Constants.NOT_SET) {
      return false;
    }
    if (mCommon.transactionEntity.getAccountToId().equals(mCommon.transactionEntity.getAccountId())) {
      return false;
    }
    if (this.mCommon.transactionEntity.getAmountTo().toDouble() <= 0) {
      return false;
    }
  }
 else {
    if (!mCommon.transactionEntity.hasPayee()) {
      return false;
    }
  }
  if (mCommon.transactionEntity.getAmount().toDouble() <= 0) {
    return false;
  }
  boolean hasCategory=mCommon.transactionEntity.hasCategory();
  if (!hasCategory && !isTransfer) {
    return false;
  }
  return true;
}
Program: 64752
Project: 64752
Buggy source:
private void showDuplicateTransactionView(ArrayList<Integer> transIds){
  int transactionCount=transIds.size();
  if (transactionCount <= 0)   return;
  int[] ids=convertArrayListToArray(transIds);
  Intent[] intents=new Intent[transactionCount];
  for (int i=0; i < transactionCount; i++) {
    intents[i]=new Intent(getActivity(),CheckingTransactionEditActivity.class);
    intents[i].putExtra(EditTransactionActivityConstants.KEY_TRANS_ID,ids[i]);
    intents[i].setAction(Intent.ACTION_PASTE);
  }
  getActivity().startActivities(intents);
}

Fixed version (ground truth):
private void showDuplicateTransactionView(ArrayList<Integer> transIds){
  int transactionCount=transIds.size();
  if (transactionCount <= 0)   return;
  int[] ids=convertArrayListToArray(transIds);
  Intent[] intents=new Intent[transactionCount];
  for (int i=0; i < transactionCount; i++) {
    intents[i]=new Intent(getActivity(),CheckingTransactionEditActivity.class);
    intents[i].putExtra(EditTransactionActivityConstants.KEY_TRANS_ID,ids[i]);
    intents[i].setAction(Intent.ACTION_PASTE);
    intents[i].putExtra(EditTransactionActivityConstants.KEY_TRANS_SOURCE,"String_Node_Str");
  }
  getActivity().startActivities(intents);
}
Program: 64753
Project: 64753
Buggy source:
/** 
 * start the activity of transaction management
 * @param transId null set if you want to do a new transaction, or transaction id
 */
private void startEditAccountTransactionActivity(Integer transId){
  Intent intent=new Intent(getActivity(),CheckingTransactionEditActivity.class);
  if (transId != null) {
    intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_ID,transId);
    intent.setAction(Intent.ACTION_EDIT);
  }
 else {
    intent.putExtra(EditTransactionActivityConstants.KEY_ACCOUNT_ID,this.AccountId);
    intent.setAction(Intent.ACTION_INSERT);
  }
  startActivity(intent);
}

Fixed version (ground truth):
/** 
 * start the activity of transaction management
 * @param transId null set if you want to do a new transaction, or transaction id
 */
private void startEditAccountTransactionActivity(Integer transId){
  Intent intent=new Intent(getActivity(),CheckingTransactionEditActivity.class);
  intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_SOURCE,"String_Node_Str");
  if (transId != null) {
    intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_ID,transId);
    intent.setAction(Intent.ACTION_EDIT);
  }
 else {
    intent.putExtra(EditTransactionActivityConstants.KEY_ACCOUNT_ID,this.AccountId);
    intent.setAction(Intent.ACTION_INSERT);
  }
  startActivity(intent);
}
Program: 64754
Project: 64754
Buggy source:
@Subscribe public void onEvent(AmountEnteredEvent event){
  QueryAccountBills account=this.getAccountBeingBalanced();
  Money currentBalance=MoneyFactory.fromDouble(account.getTotal());
  Money newBalance=event.amount;
  if (newBalance.compareTo(currentBalance) == 0)   return;
  Money difference;
  TransactionTypes transactionType;
  if (newBalance.compareTo(currentBalance) > 0) {
    difference=newBalance.subtract(currentBalance);
    transactionType=TransactionTypes.Deposit;
  }
 else {
    difference=currentBalance.subtract(newBalance);
    transactionType=TransactionTypes.Withdrawal;
  }
  Intent intent=new Intent(getContext(),CheckingTransactionEditActivity.class);
  intent.setAction(Intent.ACTION_INSERT);
  IntentDataParameters params=new IntentDataParameters();
  params.accountName=account.getAccountName();
  params.transactionType=transactionType;
  params.payeeName=getContext().getString(R.string.balance_adjustment);
  params.amount=difference;
  params.categoryName=getContext().getString(R.string.cash);
  intent.setData(params.toUri());
  getContext().startActivity(intent);
}

Fixed version (ground truth):
@Subscribe public void onEvent(AmountEnteredEvent event){
  QueryAccountBills account=this.getAccountBeingBalanced();
  Money currentBalance=MoneyFactory.fromDouble(account.getTotal());
  Money newBalance=event.amount;
  if (newBalance.compareTo(currentBalance) == 0)   return;
  Money difference;
  TransactionTypes transactionType;
  if (newBalance.compareTo(currentBalance) > 0) {
    difference=newBalance.subtract(currentBalance);
    transactionType=TransactionTypes.Deposit;
  }
 else {
    difference=currentBalance.subtract(newBalance);
    transactionType=TransactionTypes.Withdrawal;
  }
  Intent intent=new Intent(getContext(),CheckingTransactionEditActivity.class);
  intent.setAction(Intent.ACTION_INSERT);
  intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_SOURCE,"String_Node_Str");
  IntentDataParameters params=new IntentDataParameters();
  params.accountName=account.getAccountName();
  params.transactionType=transactionType;
  params.payeeName=getContext().getString(R.string.balance_adjustment);
  params.amount=difference;
  params.categoryName=getContext().getString(R.string.cash);
  intent.setData(params.toUri());
  getContext().startActivity(intent);
}
Program: 64755
Project: 64755
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  if (container == null)   return null;
  View view=inflater.inflate(R.layout.home_fragment,container,false);
  linearHome=(FrameLayout)view.findViewById(R.id.linearLayoutHome);
  txtTotalAccounts=(TextView)view.findViewById(R.id.textViewTotalAccounts);
  createWelcomeView(view);
  setUpAccountsList(view);
  prgAccountBills=(ProgressBar)view.findViewById(R.id.progressAccountBills);
  mFloatingActionButton=(FloatingActionButton)view.findViewById(R.id.fab);
  mFloatingActionButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      Intent intent=new Intent(getActivity(),CheckingTransactionEditActivity.class);
      intent.setAction(Intent.ACTION_INSERT);
      startActivity(intent);
    }
  }
);
  return view;
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  if (container == null)   return null;
  View view=inflater.inflate(R.layout.home_fragment,container,false);
  linearHome=(FrameLayout)view.findViewById(R.id.linearLayoutHome);
  txtTotalAccounts=(TextView)view.findViewById(R.id.textViewTotalAccounts);
  createWelcomeView(view);
  setUpAccountsList(view);
  prgAccountBills=(ProgressBar)view.findViewById(R.id.progressAccountBills);
  mFloatingActionButton=(FloatingActionButton)view.findViewById(R.id.fab);
  mFloatingActionButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      Intent intent=new Intent(getActivity(),CheckingTransactionEditActivity.class);
      intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_SOURCE,"String_Node_Str");
      intent.setAction(Intent.ACTION_INSERT);
      startActivity(intent);
    }
  }
);
  return view;
}
Program: 64757
Project: 64757
Buggy source:
private void showCreateTransactionActivity(int recurringTransactionId){
  RecurringTransactionRepository repo=new RecurringTransactionRepository(getActivity());
  RecurringTransaction tx=repo.load(recurringTransactionId);
  if (tx == null)   return;
  Intent intent=new Intent(getActivity(),CheckingTransactionEditActivity.class);
  intent.setAction(Intent.ACTION_INSERT);
  intent.putExtra(EditTransactionActivityConstants.KEY_BDID_ID,recurringTransactionId);
  startActivityForResult(intent,REQUEST_ADD_TRANSACTION);
}

Fixed version (ground truth):
private void showCreateTransactionActivity(int recurringTransactionId){
  RecurringTransactionRepository repo=new RecurringTransactionRepository(getActivity());
  RecurringTransaction tx=repo.load(recurringTransactionId);
  if (tx == null)   return;
  Intent intent=new Intent(getActivity(),CheckingTransactionEditActivity.class);
  intent.setAction(Intent.ACTION_INSERT);
  intent.putExtra(EditTransactionActivityConstants.KEY_BDID_ID,recurringTransactionId);
  intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_SOURCE,"String_Node_Str");
  startActivityForResult(intent,REQUEST_ADD_TRANSACTION);
}
Program: 64759
Project: 64759
Buggy source:
@Override public void onUpdate(Context context,AppWidgetManager appWidgetManager,int[] appWidgetIds){
  for (int i=0; i < appWidgetIds.length; ++i) {
    RemoteViews remoteViews=new RemoteViews(context.getPackageName(),R.layout.widget_button_add_transaction);
    Intent intent=new Intent(context,CheckingTransactionEditActivity.class);
    intent.setAction(Intent.ACTION_INSERT);
    PendingIntent pendingIntent=PendingIntent.getActivity(context,0,intent,0);
    remoteViews.setOnClickPendingIntent(R.id.buttonNewOperation,pendingIntent);
    appWidgetManager.updateAppWidget(appWidgetIds[i],remoteViews);
  }
  super.onUpdate(context,appWidgetManager,appWidgetIds);
}

Fixed version (ground truth):
@Override public void onUpdate(Context context,AppWidgetManager appWidgetManager,int[] appWidgetIds){
  for (int i=0; i < appWidgetIds.length; ++i) {
    RemoteViews remoteViews=new RemoteViews(context.getPackageName(),R.layout.widget_button_add_transaction);
    Intent intent=new Intent(context,CheckingTransactionEditActivity.class);
    intent.setAction(Intent.ACTION_INSERT);
    intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_SOURCE,"String_Node_Str");
    PendingIntent pendingIntent=PendingIntent.getActivity(context,0,intent,0);
    remoteViews.setOnClickPendingIntent(R.id.buttonNewOperation,pendingIntent);
    appWidgetManager.updateAppWidget(appWidgetIds[i],remoteViews);
  }
  super.onUpdate(context,appWidgetManager,appWidgetIds);
}
Program: 64760
Project: 64760
Buggy source:
private void initializeNewTransactionCommand(Context context,RemoteViews views){
  Intent intent=new Intent(context,CheckingTransactionEditActivity.class);
  intent.setAction(Intent.ACTION_INSERT);
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
  intent.addCategory(Intent.CATEGORY_LAUNCHER);
  PendingIntent pendingIntent=PendingIntent.getActivity(context,0,intent,0);
  views.setOnClickPendingIntent(R.id.newTransactionPanel,pendingIntent);
  views.setOnClickPendingIntent(R.id.newTransactionButton,pendingIntent);
}

Fixed version (ground truth):
private void initializeNewTransactionCommand(Context context,RemoteViews views){
  Intent intent=new Intent(context,CheckingTransactionEditActivity.class);
  intent.setAction(Intent.ACTION_INSERT);
  intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_SOURCE,"String_Node_Str");
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
  intent.addCategory(Intent.CATEGORY_LAUNCHER);
  PendingIntent pendingIntent=PendingIntent.getActivity(context,0,intent,0);
  views.setOnClickPendingIntent(R.id.newTransactionPanel,pendingIntent);
  views.setOnClickPendingIntent(R.id.newTransactionButton,pendingIntent);
}
Program: 64761
Project: 64761
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_edit_recurring_transaction);
  initializeModel();
  mCommonFunctions=new EditTransactionCommonFunctions(this,mRecurringTransaction);
  showStandardToolbarActions();
  if (savedInstanceState != null) {
    restoreInstanceState(savedInstanceState);
  }
  if (getIntent() != null) {
    if (savedInstanceState == null) {
      String action=getIntent().getAction();
      if (action != null && action.equals(Intent.ACTION_EDIT)) {
        int id=getIntent().getIntExtra(KEY_BILL_DEPOSITS_ID,Constants.NOT_SET);
        loadRecurringTransaction(id);
      }
 else {
        mRecurringTransaction.setAccountId(getIntent().getIntExtra(KEY_ACCOUNT_ID,Constants.NOT_SET));
      }
    }
    mIntentAction=getIntent().getAction();
    if (getSupportActionBar() != null) {
      getSupportActionBar().setTitle(Intent.ACTION_INSERT.equals(mIntentAction) ? R.string.new_repeating_transaction : R.string.edit_repeating_transaction);
    }
  }
  initializeViewHolder();
  initializeControls();
  mCommonFunctions.onTransactionTypeChanged(mCommonFunctions.transactionEntity.getTransactionType());
  mCommonFunctions.refreshPayeeName();
  mCommonFunctions.displayCategoryName();
  showPaymentsLeft();
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_edit_recurring_transaction);
  initializeModel();
  mCommonFunctions=new EditTransactionCommonFunctions(this,mRecurringTransaction);
  showStandardToolbarActions();
  if (savedInstanceState != null) {
    restoreInstanceState(savedInstanceState);
  }
  if (getIntent() != null) {
    if (savedInstanceState == null) {
      String action=getIntent().getAction();
      if (action != null && action.equals(Intent.ACTION_EDIT)) {
        int id=getIntent().getIntExtra(KEY_BILL_DEPOSITS_ID,Constants.NOT_SET);
        loadRecurringTransaction(id);
      }
 else {
        mRecurringTransaction.setAccountId(getIntent().getIntExtra(KEY_ACCOUNT_ID,Constants.NOT_SET));
      }
    }
    mIntentAction=getIntent().getAction();
    if (getSupportActionBar() != null) {
      getSupportActionBar().setTitle(Intent.ACTION_INSERT.equals(mIntentAction) ? R.string.new_repeating_transaction : R.string.edit_repeating_transaction);
    }
  }
  initializeViewHolder();
  initializeControls();
  mCommonFunctions.onTransactionTypeChanged(mCommonFunctions.transactionEntity.getTransactionType());
  mCommonFunctions.showPayeeName();
  mCommonFunctions.displayCategoryName();
  showPaymentsLeft();
}
Program: 64762
Project: 64762
Buggy source:
/** 
 * this method allows you to search the transaction data
 * @param recurringTransactionId transaction id
 * @return true if data selected, false nothing
 */
private boolean loadRecurringTransaction(int recurringTransactionId){
  RecurringTransactionRepository repo=new RecurringTransactionRepository(this);
  mRecurringTransaction=repo.load(recurringTransactionId);
  if (mRecurringTransaction == null)   return false;
  mCommonFunctions.transactionEntity=mRecurringTransaction;
  String transCode=mRecurringTransaction.getTransactionCode();
  mCommonFunctions.transactionEntity.setTransactionType(TransactionTypes.valueOf(transCode));
  if (!mCommonFunctions.transactionEntity.hasCategory() && mCommonFunctions.mSplitTransactions == null) {
    RecurringTransactionService recurringTransaction=new RecurringTransactionService(recurringTransactionId,this);
    mCommonFunctions.mSplitTransactions=recurringTransaction.loadSplitTransactions();
  }
  AccountRepository accountRepository=new AccountRepository(this);
  mCommonFunctions.mToAccountName=accountRepository.loadName(mCommonFunctions.transactionEntity.getAccountToId());
  mCommonFunctions.selectPayeeName(mCommonFunctions.transactionEntity.getPayeeId());
  mCommonFunctions.loadCategoryName();
  return true;
}

Fixed version (ground truth):
/** 
 * this method allows you to search the transaction data
 * @param recurringTransactionId transaction id
 * @return true if data selected, false nothing
 */
private boolean loadRecurringTransaction(int recurringTransactionId){
  RecurringTransactionRepository repo=new RecurringTransactionRepository(this);
  mRecurringTransaction=repo.load(recurringTransactionId);
  if (mRecurringTransaction == null)   return false;
  mCommonFunctions.transactionEntity=mRecurringTransaction;
  String transCode=mRecurringTransaction.getTransactionCode();
  mCommonFunctions.transactionEntity.setTransactionType(TransactionTypes.valueOf(transCode));
  if (!mCommonFunctions.transactionEntity.hasCategory() && mCommonFunctions.mSplitTransactions == null) {
    RecurringTransactionService recurringTransaction=new RecurringTransactionService(recurringTransactionId,this);
    mCommonFunctions.mSplitTransactions=recurringTransaction.loadSplitTransactions();
  }
  AccountRepository accountRepository=new AccountRepository(this);
  mCommonFunctions.mToAccountName=accountRepository.loadName(mCommonFunctions.transactionEntity.getAccountToId());
  mCommonFunctions.loadPayeeName(mCommonFunctions.transactionEntity.getPayeeId());
  mCommonFunctions.loadCategoryName();
  return true;
}
Program: 64763
Project: 64763
Buggy source:
/** 
 * update data into database
 * @return true if update data successful
 */
private boolean saveData(){
  collectDataFromUI();
  if (!validateData())   return false;
  boolean isTransfer=mCommonFunctions.transactionEntity.getTransactionType().equals(TransactionTypes.Transfer);
  if (!isTransfer) {
    mCommonFunctions.resetTransfer();
  }
  if (!saveTransaction())   return false;
  if (mCommonFunctions.handleOneSplit()) {
    saveTransaction();
  }
  if (!mCommonFunctions.isSplitSelected()) {
    mCommonFunctions.removeAllSplitCategories();
  }
  if (!saveSplitCategories())   return false;
  return true;
}

Fixed version (ground truth):
/** 
 * update data into database
 * @return true if update data successful
 */
private boolean saveData(){
  collectDataFromUI();
  if (!validateData())   return false;
  boolean isTransfer=mCommonFunctions.transactionEntity.getTransactionType().equals(TransactionTypes.Transfer);
  if (!isTransfer) {
    mCommonFunctions.resetTransfer();
  }
  if (!saveTransaction())   return false;
  if (mCommonFunctions.convertOneSplitIntoRegularTransaction()) {
    saveTransaction();
  }
  if (!mCommonFunctions.isSplitSelected()) {
    mCommonFunctions.removeAllSplitCategories();
  }
  if (!saveSplitCategories())   return false;
  return true;
}
Program: 64764
Project: 64764
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_edit_checking_account_transaction);
  showStandardToolbarActions();
  ITransactionEntity model=AccountTransaction.create();
  mCommonFunctions=new EditTransactionCommonFunctions(this,model);
  if ((savedInstanceState != null)) {
    restoreInstanceState(savedInstanceState);
  }
  mCommonFunctions.findControls(this);
  if (getIntent() != null) {
    boolean handled=handleIntent(savedInstanceState);
    if (!handled) {
      finish();
      return;
    }
  }
  initializeInputControls();
  mCommonFunctions.onTransactionTypeChanged(mCommonFunctions.transactionEntity.getTransactionType());
  mCommonFunctions.refreshPayeeName();
  mCommonFunctions.displayCategoryName();
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_edit_checking_account_transaction);
  showStandardToolbarActions();
  ITransactionEntity model=AccountTransaction.create();
  mCommonFunctions=new EditTransactionCommonFunctions(this,model);
  if ((savedInstanceState != null)) {
    restoreInstanceState(savedInstanceState);
  }
  mCommonFunctions.findControls(this);
  if (getIntent() != null) {
    boolean handled=handleIntent(savedInstanceState);
    if (!handled) {
      finish();
      return;
    }
  }
  initializeInputControls();
  mCommonFunctions.onTransactionTypeChanged(mCommonFunctions.transactionEntity.getTransactionType());
  mCommonFunctions.showPayeeName();
  mCommonFunctions.displayCategoryName();
}
Program: 64767
Project: 64767
Buggy source:
private boolean loadCheckingAccount(int transId){
  AccountTransactionRepository repo=new AccountTransactionRepository(this);
  AccountTransaction tx=repo.load(transId);
  if (tx == null)   return false;
  mCommonFunctions.transactionEntity=tx;
  if (mCommonFunctions.mSplitTransactions == null) {
    SplitCategoriesRepository splitRepo=new SplitCategoriesRepository(this);
    mCommonFunctions.mSplitTransactions=splitRepo.loadSplitCategoriesFor(transId);
  }
  AccountRepository accountRepository=new AccountRepository(this);
  mCommonFunctions.mToAccountName=accountRepository.loadName(mCommonFunctions.transactionEntity.getAccountToId());
  mCommonFunctions.selectPayeeName(mCommonFunctions.transactionEntity.getPayeeId());
  mCommonFunctions.loadCategoryName();
  return true;
}

Fixed version (ground truth):
private boolean loadCheckingAccount(int transId){
  AccountTransactionRepository repo=new AccountTransactionRepository(this);
  AccountTransaction tx=repo.load(transId);
  if (tx == null)   return false;
  mCommonFunctions.transactionEntity=tx;
  if (mCommonFunctions.mSplitTransactions == null) {
    SplitCategoriesRepository splitRepo=new SplitCategoriesRepository(this);
    mCommonFunctions.mSplitTransactions=splitRepo.loadSplitCategoriesFor(transId);
  }
  AccountRepository accountRepository=new AccountRepository(this);
  mCommonFunctions.mToAccountName=accountRepository.loadName(mCommonFunctions.transactionEntity.getAccountToId());
  mCommonFunctions.loadPayeeName(mCommonFunctions.transactionEntity.getPayeeId());
  mCommonFunctions.loadCategoryName();
  return true;
}
Program: 64768
Project: 64768
Buggy source:
/** 
 * Save data to the database.
 * @return true if update data successful
 */
private boolean saveData(){
  if (!mCommonFunctions.validateData())   return false;
  boolean isTransfer=mCommonFunctions.transactionEntity.getTransactionType().equals(TransactionTypes.Transfer);
  if (!isTransfer) {
    mCommonFunctions.resetTransfer();
  }
  if (!saveTransaction())   return false;
  if (mCommonFunctions.handleOneSplit()) {
    saveTransaction();
  }
  if (!mCommonFunctions.isSplitSelected()) {
    mCommonFunctions.removeAllSplitCategories();
  }
  if (!saveSplitCategories())   return false;
  saveDefaultPayee(isTransfer);
  if (mRecurringTransactionId != Constants.NOT_SET) {
    RecurringTransactionService service=new RecurringTransactionService(mRecurringTransactionId,this);
    service.moveNextOccurrence();
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Save data to the database.
 * @return true if update data successful
 */
private boolean saveData(){
  if (!mCommonFunctions.validateData())   return false;
  boolean isTransfer=mCommonFunctions.transactionEntity.getTransactionType().equals(TransactionTypes.Transfer);
  if (!isTransfer) {
    mCommonFunctions.resetTransfer();
  }
  if (!saveTransaction())   return false;
  if (mCommonFunctions.convertOneSplitIntoRegularTransaction()) {
    saveTransaction();
  }
  if (!mCommonFunctions.isSplitSelected()) {
    mCommonFunctions.removeAllSplitCategories();
  }
  if (!saveSplitCategories())   return false;
  saveDefaultPayee(isTransfer);
  if (mRecurringTransactionId != Constants.NOT_SET) {
    RecurringTransactionService service=new RecurringTransactionService(mRecurringTransactionId,this);
    service.moveNextOccurrence();
  }
  return true;
}
Program: 64769
Project: 64769
Buggy source:
@Override protected void onPostExecute(Boolean result){
  super.onPostExecute(result);
  if (result) {
    try {
      mCommonFunctions.refreshPayeeName();
      mCommonFunctions.displayCategoryName();
    }
 catch (    Exception e) {
      Log.e(EditTransactionActivityConstants.LOGCAT,e.getMessage());
    }
  }
}

Fixed version (ground truth):
@Override protected void onPostExecute(Boolean result){
  super.onPostExecute(result);
  if (result) {
    try {
      mCommonFunctions.showPayeeName();
      mCommonFunctions.displayCategoryName();
    }
 catch (    Exception e) {
      Log.e(EditTransactionActivityConstants.LOGCAT,e.getMessage());
    }
  }
}
Program: 64770
Project: 64770
Buggy source:
/** 
 * Fast single pass parser, should correctly process most of positive/negative values fitting into <code>long</code>
 * @param str Floating point number to parse
 * @return Money object or null (if can't parse)
 * @throws java.lang.IllegalArgumentException If a value has more than one decimal digit
 */
private static Money parseFast(final CharSequence str){
  if (str.length() >= MAX_LONG_LENGTH)   return null;
  long res=0;
  int start=0;
  long sign=1;
  int precision=0;
  if (str.charAt(0) == '-') {
    sign=-1;
    start=1;
  }
 else   if (str.charAt(0) == '+') {
    sign=1;
    start=1;
  }
  for (int i=start; i < str.length(); ++i) {
    final char c=str.charAt(i);
    if (c == '.') {
      if (precision > 0)       throw new IllegalArgumentException("String_Node_Str" + str);
      precision=str.length() - i - 1;
    }
 else     if (c >= '0' && c <= '9')     res=res * 10 + (c - '0');
 else     return null;
  }
  return new MoneyLong(res * sign,precision).normalize();
}

Fixed version (ground truth):
/** 
 * Fast single pass parser, should correctly process most of positive/negative values fitting into <code>long</code>
 * @param str Floating point number to parse
 * @return Money object or null (if can't parse)
 * @throws java.lang.IllegalArgumentException If a value has more than one decimal digit
 */
private static Money parseFast(final CharSequence str){
  if (str.length() >= MAX_LONG_LENGTH)   return null;
  long res=0;
  int start=0;
  long sign=1;
  int precision=0;
  if (str.charAt(0) == '-') {
    sign=-1;
    start=1;
  }
 else   if (str.charAt(0) == '+') {
    sign=1;
    start=1;
  }
  for (int i=start; i < str.length(); ++i) {
    final char c=str.charAt(i);
    if (c == '.') {
      if (precision > 0)       throw new IllegalArgumentException("String_Node_Str" + str);
      precision=str.length() - i - 1;
    }
 else     if (c >= '0' && c <= '9')     res=res * 10 + (c - '0');
 else     return null;
  }
  if (precision >= 0 && precision <= MAX_ALLOWED_PRECISION)   return new MoneyLong(res * sign,precision).normalize();
 else   return new MoneyBigDecimal(str.toString());
}
Program: 64771
Project: 64771
Buggy source:
/** 
 * Divide the current object by the given <code>long</code> divider.
 * @param divider   Divider
 * @param precision Maximal precision to keep. We will round the next digit.
 * @return A new Money object normalized to the efficient representation if possible
 */
public Money divide(final double divider,final int precision){
  final double unscaledRes=m_units / divider;
  final long destRes;
  if (m_precision < precision) {
    destRes=Math.round(unscaledRes * MoneyFactory.MULTIPLIERS[precision - m_precision]);
  }
 else   if (m_precision == precision) {
    destRes=Math.round(unscaledRes);
  }
 else {
    destRes=Math.round(unscaledRes * MoneyFactory.MULTIPLIERS_NEG[m_precision - precision]);
  }
  return new MoneyLong(destRes,precision).normalize();
}

Fixed version (ground truth):
/** 
 * Divide the current object by the given <code>long</code> divider.
 * @param divider   Divider
 * @param precision Maximal precision to keep. We will round the next digit.
 * @return A new Money object normalized to the efficient representation if possible
 */
public Money divide(final double divider,final int precision){
  if (precision > MoneyFactory.MAX_ALLOWED_PRECISION)   return new MoneyBigDecimal(toBigDecimal()).divide(divider,precision);
  final double unscaledRes=m_units / divider;
  final long destRes;
  if (m_precision < precision) {
    destRes=Math.round(unscaledRes * MoneyFactory.MULTIPLIERS[precision - m_precision]);
  }
 else   if (m_precision == precision) {
    destRes=Math.round(unscaledRes);
  }
 else {
    destRes=Math.round(unscaledRes * MoneyFactory.MULTIPLIERS_NEG[m_precision - precision]);
  }
  return new MoneyLong(destRes,precision).normalize();
}
Program: 64772
Project: 64772
Buggy source:
@Override protected void onStart(){
  super.onStart();
  if (!isAuthenticated) {
    Passcode passcode=new Passcode(this);
    if (passcode.hasPasscode() && !isInAuthentication) {
      Intent intent=new Intent(this,PasscodeActivity.class);
      intent.setAction(PasscodeActivity.INTENT_REQUEST_PASSWORD);
      intent.putExtra(PasscodeActivity.INTENT_MESSAGE_TEXT,getString(R.string.enter_your_passcode));
      startActivityForResult(intent,REQUEST_PASSCODE);
      isInAuthentication=true;
    }
  }
}

Fixed version (ground truth):
@Override protected void onStart(){
  super.onStart();
  if (!isAuthenticated) {
    Passcode passcode=new Passcode(getApplicationContext());
    if (passcode.hasPasscode() && !isInAuthentication) {
      Intent intent=new Intent(this,PasscodeActivity.class);
      intent.setAction(PasscodeActivity.INTENT_REQUEST_PASSWORD);
      intent.putExtra(PasscodeActivity.INTENT_MESSAGE_TEXT,getString(R.string.enter_your_passcode));
      startActivityForResult(intent,REQUEST_PASSCODE);
      isInAuthentication=true;
    }
  }
}
Program: 64773
Project: 64773
Buggy source:
@Override public void onRemoveItem(ISplitTransactionsDataset object){
  if (mSplitDeleted == null) {
    mSplitDeleted=new ArrayList<>();
  }
  if (object.getSplitTransId() != -1)   mSplitDeleted.add(object);
}

Fixed version (ground truth):
@Override public void onRemoveItem(ISplitTransactionsDataset object){
  if (mSplitDeleted == null) {
    mSplitDeleted=new ArrayList<>();
  }
  if (object.getSplitTransId() != -1) {
    mSplitDeleted.add(object);
  }
}
Program: 64774
Project: 64774
Buggy source:
@Override public boolean onActionDoneClick(){
  ArrayList<ISplitTransactionsDataset> allSplitTransactions=getAllTableSplitTransaction();
  for (int i=0; i < allSplitTransactions.size(); i++) {
    ISplitTransactionsDataset splitTransactions=allSplitTransactions.get(i);
    if (splitTransactions.getCategId() == -1 && splitTransactions.getCategId() == -1) {
      Core.alertDialog(SplitTransactionsActivity.this,R.string.error_category_not_selected).show();
      return false;
    }
  }
  Intent result=new Intent();
  result.putParcelableArrayListExtra(INTENT_RESULT_SPLIT_TRANSACTION,allSplitTransactions);
  result.putParcelableArrayListExtra(INTENT_RESULT_SPLIT_TRANSACTION_DELETED,mSplitDeleted);
  setResult(RESULT_OK,result);
  finish();
  return true;
}

Fixed version (ground truth):
@Override public boolean onActionDoneClick(){
  ArrayList<ISplitTransactionsDataset> allSplitTransactions=getAllSplitCategories();
  for (int i=0; i < allSplitTransactions.size(); i++) {
    ISplitTransactionsDataset splitTransactions=allSplitTransactions.get(i);
    if (splitTransactions.getCategId() == -1 && splitTransactions.getSubCategId() == -1) {
      Core.alertDialog(SplitTransactionsActivity.this,R.string.error_category_not_selected).show();
      return false;
    }
  }
  Intent result=new Intent();
  result.putParcelableArrayListExtra(INTENT_RESULT_SPLIT_TRANSACTION,allSplitTransactions);
  result.putParcelableArrayListExtra(INTENT_RESULT_SPLIT_TRANSACTION_DELETED,mSplitDeleted);
  setResult(RESULT_OK,result);
  finish();
  return true;
}
Program: 64776
Project: 64776
Buggy source:
@Override public void onCreateOptionsMenu(Menu menu,MenuInflater inflater){
  super.onCreateOptionsMenu(menu,inflater);
  Core core=new Core(getActivity().getApplicationContext());
  MenuItem itemOption=menu.findItem(R.id.menu_option1);
  if (itemOption != null) {
    itemOption.setVisible(true);
    itemOption.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    itemOption.setIcon(getActivity().getResources().getDrawable(core.resolveIdAttribute(R.attr.ic_action_list)));
    itemOption.setTitle(R.string.categories);
    SubMenu subMenu=itemOption.getSubMenu();
    if (subMenu != null) {
      MoneyManagerOpenHelper helper=MoneyManagerOpenHelper.getInstance(getActivity().getApplicationContext());
      SQLiteDatabase database=helper.getReadableDatabase();
      TableCategory category=new TableCategory();
      Cursor cursor=database.query(category.getSource(),new String[]{TableCategory.CATEGID,TableCategory.CATEGNAME},null,null,null,null,TableCategory.CATEGNAME);
      if (cursor != null && cursor.moveToFirst()) {
        int order=0;
        while (!cursor.isAfterLast()) {
          subMenu.add(GROUP_ID_CATEGORY,-cursor.getInt(cursor.getColumnIndex(TableCategory.CATEGID)),order++,cursor.getString(cursor.getColumnIndex(TableCategory.CATEGNAME)));
          cursor.moveToNext();
        }
      }
    }
  }
  MenuItem itemChart=menu.findItem(R.id.menu_chart);
  if (itemChart != null) {
    itemChart.setVisible(!(((CategoriesReportActivity)getActivity()).mIsDualPanel));
    itemChart.setIcon(core.resolveIdAttribute(R.attr.ic_action_pie_chart));
  }
}

Fixed version (ground truth):
@Override public void onCreateOptionsMenu(Menu menu,MenuInflater inflater){
  super.onCreateOptionsMenu(menu,inflater);
  Core core=new Core(getActivity());
  MenuItem itemOption=menu.findItem(R.id.menu_option1);
  if (itemOption != null) {
    itemOption.setVisible(true);
    itemOption.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    itemOption.setIcon(getActivity().getResources().getDrawable(core.resolveIdAttribute(R.attr.ic_action_list)));
    itemOption.setTitle(R.string.categories);
    SubMenu subMenu=itemOption.getSubMenu();
    if (subMenu != null) {
      MoneyManagerOpenHelper helper=MoneyManagerOpenHelper.getInstance(getActivity().getApplicationContext());
      SQLiteDatabase database=helper.getReadableDatabase();
      TableCategory category=new TableCategory();
      Cursor cursor=database.query(category.getSource(),new String[]{TableCategory.CATEGID,TableCategory.CATEGNAME},null,null,null,null,TableCategory.CATEGNAME);
      if (cursor != null && cursor.moveToFirst()) {
        int order=0;
        while (!cursor.isAfterLast()) {
          subMenu.add(GROUP_ID_CATEGORY,-cursor.getInt(cursor.getColumnIndex(TableCategory.CATEGID)),order++,cursor.getString(cursor.getColumnIndex(TableCategory.CATEGNAME)));
          cursor.moveToNext();
        }
      }
    }
  }
  MenuItem itemChart=menu.findItem(R.id.menu_chart);
  if (itemChart != null) {
    itemChart.setVisible(!(((CategoriesReportActivity)getActivity()).mIsDualPanel));
    itemChart.setIcon(core.resolveIdAttribute(R.attr.ic_action_pie_chart));
  }
}