Program: 184610
Project: 184610
Buggy source:
static MenuItemsResult addImageMenuItems(Menu menu,int inclusions,final boolean isImage,final Activity activity,final Handler handler,final Runnable onDelete,final MenuInvoker onInvoke){
  final ArrayList<MenuItem> requiresWriteAccessItems=new ArrayList<MenuItem>();
  final ArrayList<MenuItem> requiresNoDrmAccessItems=new ArrayList<MenuItem>();
  if (isImage && ((inclusions & INCLUDE_ROTATE_MENU) != 0)) {
    SubMenu rotateSubmenu=menu.addSubMenu(IMAGE_SAVING_ITEM,MENU_IMAGE_ROTATE,40,R.string.rotate).setIcon(android.R.drawable.ic_menu_rotate);
    requiresWriteAccessItems.add(rotateSubmenu.getItem());
    if (rotateSubmenu != null) {
      requiresWriteAccessItems.add(rotateSubmenu.add(0,MENU_IMAGE_ROTATE_LEFT,50,R.string.rotate_left).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener(){
        public boolean onMenuItemClick(        MenuItem item){
          return onRotateClicked(onInvoke,-90);
        }
      }
).setAlphabeticShortcut('l'));
      requiresWriteAccessItems.add(rotateSubmenu.add(0,MENU_IMAGE_ROTATE_RIGHT,60,R.string.rotate_right).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener(){
        public boolean onMenuItemClick(        MenuItem item){
          return onRotateClicked(onInvoke,90);
        }
      }
).setAlphabeticShortcut('r'));
    }
  }
  if (isImage && ((inclusions & INCLUDE_CROP_MENU) != 0)) {
    MenuItem autoCrop=menu.add(IMAGE_SAVING_ITEM,MENU_IMAGE_CROP,73,R.string.camera_crop);
    autoCrop.setIcon(android.R.drawable.ic_menu_crop);
    autoCrop.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener(){
      public boolean onMenuItemClick(      MenuItem item){
        return onCropClicked(onInvoke,activity);
      }
    }
);
    requiresWriteAccessItems.add(autoCrop);
  }
  if (isImage && ((inclusions & INCLUDE_SET_MENU) != 0)) {
    MenuItem setMenu=menu.add(IMAGE_SAVING_ITEM,MENU_IMAGE_SET,75,R.string.camera_set);
    setMenu.setIcon(android.R.drawable.ic_menu_set_as);
    setMenu.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener(){
      public boolean onMenuItemClick(      MenuItem item){
        return onSetAsClicked(onInvoke,activity);
      }
    }
);
  }
  if ((inclusions & INCLUDE_SHARE_MENU) != 0) {
    MenuItem item1=menu.add(IMAGE_SAVING_ITEM,MENU_IMAGE_SHARE,10,R.string.camera_share).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener(){
      public boolean onMenuItemClick(      MenuItem item){
        return onImageShareClicked(onInvoke,activity,isImage);
      }
    }
);
    item1.setIcon(android.R.drawable.ic_menu_share);
    MenuItem item=item1;
    requiresNoDrmAccessItems.add(item);
  }
  if ((inclusions & INCLUDE_DELETE_MENU) != 0) {
    MenuItem deleteItem=menu.add(IMAGE_SAVING_ITEM,MENU_IMAGE_TOSS,70,R.string.camera_toss);
    requiresWriteAccessItems.add(deleteItem);
    deleteItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener(){
      public boolean onMenuItemClick(      MenuItem item){
        deleteImpl(activity,onDelete,isImage);
        return true;
      }
    }
).setAlphabeticShortcut('d').setIcon(android.R.drawable.ic_menu_delete);
  }
  if ((inclusions & INCLUDE_DETAILS_MENU) != 0) {
    MenuItem detailsMenu=menu.add(0,0,80,R.string.details).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener(){
      public boolean onMenuItemClick(      MenuItem item){
        return onDetailsClicked(onInvoke,handler,activity,isImage);
      }
    }
);
    detailsMenu.setIcon(R.drawable.ic_menu_view_details);
  }
  if ((isImage) && ((inclusions & INCLUDE_SHOWMAP_MENU) != 0)) {
    menu.add(0,0,80,R.string.show_on_map).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener(){
      public boolean onMenuItemClick(      MenuItem item){
        return onShowMapClicked(onInvoke,handler,activity);
      }
    }
).setIcon(R.drawable.ic_menu_3d_globe);
  }
  if ((!isImage) && ((inclusions & INCLUDE_VIEWPLAY_MENU) != 0)) {
    menu.add(VIDEO_SAVING_ITEM,MENU_VIDEO_PLAY,0,R.string.video_play).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener(){
      public boolean onMenuItemClick(      MenuItem item){
        return onViewPlayClicked(onInvoke,activity);
      }
    }
);
  }
  return new MenuItemsResult(){
    public void gettingReadyToOpen(    Menu menu,    IImage image){
      if (image == null) {
        return;
      }
      boolean readOnly=image.isReadonly();
      boolean isDrm=image.isDrm();
      for (      MenuItem item : requiresWriteAccessItems) {
        item.setVisible(!readOnly);
        item.setEnabled(!readOnly);
      }
      for (      MenuItem item : requiresNoDrmAccessItems) {
        item.setVisible(!isDrm);
        item.setEnabled(!isDrm);
      }
    }
    public void aboutToCall(    MenuItem menu,    IImage image){
    }
  }
;
}

Fixed version (ground truth):
static MenuItemsResult addImageMenuItems(Menu menu,int inclusions,final boolean isImage,final Activity activity,final Handler handler,final Runnable onDelete,final MenuInvoker onInvoke){
  final ArrayList<MenuItem> requiresWriteAccessItems=new ArrayList<MenuItem>();
  final ArrayList<MenuItem> requiresNoDrmAccessItems=new ArrayList<MenuItem>();
  if (isImage && ((inclusions & INCLUDE_ROTATE_MENU) != 0)) {
    SubMenu rotateSubmenu=menu.addSubMenu(IMAGE_SAVING_ITEM,MENU_IMAGE_ROTATE,40,R.string.rotate).setIcon(android.R.drawable.ic_menu_rotate);
    requiresWriteAccessItems.add(rotateSubmenu.getItem());
    requiresWriteAccessItems.add(rotateSubmenu.add(0,MENU_IMAGE_ROTATE_LEFT,50,R.string.rotate_left).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener(){
      public boolean onMenuItemClick(      MenuItem item){
        return onRotateClicked(onInvoke,-90);
      }
    }
).setAlphabeticShortcut('l'));
    requiresWriteAccessItems.add(rotateSubmenu.add(0,MENU_IMAGE_ROTATE_RIGHT,60,R.string.rotate_right).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener(){
      public boolean onMenuItemClick(      MenuItem item){
        return onRotateClicked(onInvoke,90);
      }
    }
).setAlphabeticShortcut('r'));
  }
  if (isImage && ((inclusions & INCLUDE_CROP_MENU) != 0)) {
    MenuItem autoCrop=menu.add(IMAGE_SAVING_ITEM,MENU_IMAGE_CROP,73,R.string.camera_crop);
    autoCrop.setIcon(android.R.drawable.ic_menu_crop);
    autoCrop.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener(){
      public boolean onMenuItemClick(      MenuItem item){
        return onCropClicked(onInvoke,activity);
      }
    }
);
    requiresWriteAccessItems.add(autoCrop);
  }
  if (isImage && ((inclusions & INCLUDE_SET_MENU) != 0)) {
    MenuItem setMenu=menu.add(IMAGE_SAVING_ITEM,MENU_IMAGE_SET,75,R.string.camera_set);
    setMenu.setIcon(android.R.drawable.ic_menu_set_as);
    setMenu.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener(){
      public boolean onMenuItemClick(      MenuItem item){
        return onSetAsClicked(onInvoke,activity);
      }
    }
);
  }
  if ((inclusions & INCLUDE_SHARE_MENU) != 0) {
    MenuItem item1=menu.add(IMAGE_SAVING_ITEM,MENU_IMAGE_SHARE,10,R.string.camera_share).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener(){
      public boolean onMenuItemClick(      MenuItem item){
        return onImageShareClicked(onInvoke,activity,isImage);
      }
    }
);
    item1.setIcon(android.R.drawable.ic_menu_share);
    MenuItem item=item1;
    requiresNoDrmAccessItems.add(item);
  }
  if ((inclusions & INCLUDE_DELETE_MENU) != 0) {
    MenuItem deleteItem=menu.add(IMAGE_SAVING_ITEM,MENU_IMAGE_TOSS,70,R.string.camera_toss);
    requiresWriteAccessItems.add(deleteItem);
    deleteItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener(){
      public boolean onMenuItemClick(      MenuItem item){
        deleteImpl(activity,onDelete,isImage);
        return true;
      }
    }
).setAlphabeticShortcut('d').setIcon(android.R.drawable.ic_menu_delete);
  }
  if ((inclusions & INCLUDE_DETAILS_MENU) != 0) {
    MenuItem detailsMenu=menu.add(0,0,80,R.string.details).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener(){
      public boolean onMenuItemClick(      MenuItem item){
        return onDetailsClicked(onInvoke,handler,activity,isImage);
      }
    }
);
    detailsMenu.setIcon(R.drawable.ic_menu_view_details);
  }
  if ((isImage) && ((inclusions & INCLUDE_SHOWMAP_MENU) != 0)) {
    menu.add(0,0,80,R.string.show_on_map).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener(){
      public boolean onMenuItemClick(      MenuItem item){
        return onShowMapClicked(onInvoke,handler,activity);
      }
    }
).setIcon(R.drawable.ic_menu_3d_globe);
  }
  if ((!isImage) && ((inclusions & INCLUDE_VIEWPLAY_MENU) != 0)) {
    menu.add(VIDEO_SAVING_ITEM,MENU_VIDEO_PLAY,0,R.string.video_play).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener(){
      public boolean onMenuItemClick(      MenuItem item){
        return onViewPlayClicked(onInvoke,activity);
      }
    }
);
  }
  return new MenuItemsResult(){
    public void gettingReadyToOpen(    Menu menu,    IImage image){
      if (image == null) {
        return;
      }
      boolean readOnly=image.isReadonly();
      boolean isDrm=image.isDrm();
      for (      MenuItem item : requiresWriteAccessItems) {
        item.setVisible(!readOnly);
        item.setEnabled(!readOnly);
      }
      for (      MenuItem item : requiresNoDrmAccessItems) {
        item.setVisible(!isDrm);
        item.setEnabled(!isDrm);
      }
    }
    public void aboutToCall(    MenuItem menu,    IImage image){
    }
  }
;
}