Program: 16518
Project: 16518
Buggy source:
/** 
 * Deselects all of the currently selected items and selects the item with the given index.
 */
public void setSelectedIndex(int jsel){
  final int isz=_items.size();
  final int tsz=_model != null ? _model.getSize() : isz;
  if (jsel >= tsz)   throw new UiException("String_Node_Str" + jsel + "String_Node_Str"+ tsz);
  if (jsel < -1)   jsel=-1;
  if (jsel < 0) {
    clearSelection();
  }
 else   if (jsel != _jsel || (_multiple && _selItems.size() > 1)) {
    for (Iterator it=_selItems.iterator(); it.hasNext(); ) {
      final Listitem item=(Listitem)it.next();
      item.setSelectedDirectly(false);
    }
    _selItems.clear();
    _jsel=jsel;
    Listitem item=getItemAtIndex(_jsel);
    if (item == null) {
      if (inPagingMold()) {
        final int offset=_jsel - _jsel % getPageSize();
        final int limit=getPageSize();
        getDataLoader().syncModel(offset,limit);
      }
 else {
        final int offset=_jsel - 10;
        final int limit=getDataLoader().getLimit();
        getDataLoader().syncModel(offset < 0 ? 0 : offset,limit);
        _topPad=-1;
        _currentTop=0;
        _currentLeft=0;
        invalidate();
      }
      item=getItemAtIndex(_jsel);
    }
    item.setSelectedDirectly(true);
    _selItems.add(item);
    if (_model instanceof Selectable) {
      if (!isLoadingModel()) {
        ((Selectable)_model).clearSelection();
      }
      ((Selectable)_model).addSelection(_model.getElementAt(_jsel));
    }
    if (inSelectMold()) {
      smartUpdate("String_Node_Str",_jsel);
    }
 else     smartUpdate("String_Node_Str",item.getUuid());
  }
  if (_jsel >= 0 && inPagingMold()) {
    final Listitem item=getItemAtIndex(_jsel);
    int size=getDataLoader().getOffset();
    for (Iterator it=new VisibleChildrenIterator(true); it.hasNext(); size++)     if (item.equals(it.next()))     break;
    final int pg=size / getPageSize();
    if (pg != getActivePage())     setActivePage(pg);
  }
}

Fixed version (ground truth):
/** 
 * Deselects all of the currently selected items and selects the item with the given index.
 */
public void setSelectedIndex(int jsel){
  final int isz=_items.size();
  final int tsz=_model != null ? _model.getSize() : isz;
  if (jsel >= tsz)   throw new UiException("String_Node_Str" + jsel + "String_Node_Str"+ tsz);
  if (jsel < -1)   jsel=-1;
  if (jsel < 0) {
    clearSelection();
  }
 else   if (jsel != _jsel || (_multiple && _selItems.size() > 1) || !_selItems.contains(getItemAtIndex(_jsel))) {
    for (Iterator it=_selItems.iterator(); it.hasNext(); ) {
      final Listitem item=(Listitem)it.next();
      item.setSelectedDirectly(false);
    }
    _selItems.clear();
    _jsel=jsel;
    Listitem item=getItemAtIndex(_jsel);
    if (item == null) {
      if (inPagingMold()) {
        final int offset=_jsel - _jsel % getPageSize();
        final int limit=getPageSize();
        getDataLoader().syncModel(offset,limit);
      }
 else {
        smartUpdate("String_Node_Str",_jsel);
      }
    }
 else {
      item.setSelectedDirectly(true);
      _selItems.add(item);
    }
    if (_model instanceof Selectable) {
      if (!isLoadingModel()) {
        ((Selectable)_model).clearSelection();
      }
      ((Selectable)_model).addSelection(_model.getElementAt(_jsel));
    }
    if (inSelectMold()) {
      smartUpdate("String_Node_Str",_jsel);
    }
 else     if (item != null)     smartUpdate("String_Node_Str",item.getUuid());
  }
  if (_jsel >= 0 && inPagingMold()) {
    final Listitem item=getItemAtIndex(_jsel);
    int size=getDataLoader().getOffset();
    for (Iterator it=new VisibleChildrenIterator(true); it.hasNext(); size++)     if (item.equals(it.next()))     break;
    final int pg=size / getPageSize();
    if (pg != getActivePage())     setActivePage(pg);
  }
}