Buggy code:
public QueryContext getContext ( ) { } public void setContext ( QueryContext qctx ) { } public boolean setQuery ( Object query ) { } public FilterListener getFilterListener ( String tag ) { } public AggregateListener getAggregateListener ( String tag ) { } public Object newCompilationKey ( ) { } public Object newCompilation ( ) { } public void populateFromCompilation ( Object comp ) { } public void invalidateCompilation ( ) { } public boolean supportsDataStoreExecution ( ) { } public boolean supportsInMemoryExecution ( ) { } public Executor newInMemoryExecutor ( ClassMetaData meta , boolean subs ) { } public Executor newDataStoreExecutor ( ClassMetaData meta , boolean subs ) { } public boolean supportsAbstractExecutors ( ) { } public boolean requiresCandidateType ( ) { } public boolean requiresParameterDeclarations ( ) { } public boolean supportsParameterDeclarations ( ) { } public Object evaluate ( Object value , Object ob , Object [ ] params , OpenJPAStateManager sm ) { } private static class QueryCacheExecutor implements Executor { private final Executor _ex ; private final Class < ? > _candidate ; private final boolean _subs ; private final FetchConfiguration _fc ; public QueryCacheExecutor ( Executor ex , ClassMetaData meta , boolean subs , FetchConfiguration fc ) { } public ResultObjectProvider executeQuery ( StoreQuery q , Object [ ] params , Range range ) { } public QueryExpressions [ ] getQueryExpressions ( ) { } private void clearAccessPath ( StoreQuery q ) { } public Number executeDelete ( StoreQuery q , Object [ ] params ) { } public Number executeUpdate ( StoreQuery q , Object [ ] params ) { } public String [ ] getDataStoreActions ( StoreQuery q , Object [ ] params , Range range ) { } public void validate ( StoreQuery q ) { } public void getRange ( StoreQuery q , Object [ ] params , Range range ) { } public Object getOrderingValue ( StoreQuery q , Object [ ] params , Object resultObject , int orderIndex ) { } public boolean [ ] getAscending ( StoreQuery q ) { } public boolean isPacking ( StoreQuery q ) { } public String getAlias ( StoreQuery q ) { } public Class < ? > getResultClass ( StoreQuery q ) { } public ResultShape < ? > getResultShape ( StoreQuery q ) { } public String [ ] getProjectionAliases ( StoreQuery q ) { } public Class < ? > [ ] getProjectionTypes ( StoreQuery q ) { } public ClassMetaData [ ] getAccessPathMetaDatas ( StoreQuery q ) { } public int getOperation ( StoreQuery q ) { } public boolean isAggregate ( StoreQuery q ) { } public boolean isDistinct ( StoreQuery q ) { } public boolean hasGrouping ( StoreQuery q ) { } public OrderedMap < Object , Class < ? > > getOrderedParameterTypes ( StoreQuery q ) { } public LinkedMap getParameterTypes ( StoreQuery q ) { } public Object [ ] toParameterArray ( StoreQuery q , Map userParams ) { } public Map getUpdates ( StoreQuery q ) { } private static StoreQuery unwrap ( StoreQuery q ) { } } public static class CachedList extends AbstractList < Object > implements Serializable { private final QueryResult _res ; private final boolean _proj ; private final StoreContext _sctx ; public CachedList ( QueryResult res , boolean proj , StoreContext ctx ) { } public Object get ( int idx ) { } public int size ( ) { } public Object writeReplace ( ) throws ObjectStreamException { } } private class CachingResultObjectProvider implements TypesChangedListener , ResultObjectProvider { private final ResultObjectProvider _rop ; private final boolean _proj ; private final QueryKey _qk ; private final TreeMap < Integer , Object > _data = new TreeMap < Integer , Object > ( ) ; private boolean _maintainCache = true ; private int _pos = - 1 ; private int _max = - 1 ; private int _size = Integer . MAX_VALUE ; public CachingResultObjectProvider ( ResultObjectProvider rop , boolean proj , QueryKey key ) { } private void abortCaching ( ) { } private void checkFinished ( Object obj , boolean result ) { boolean finished = false ; synchronized ( this ) { if ( _maintainCache ) { if ( result ) { <START_BUG> Integer index = Numbers . valueOf ( _pos ) ; <END_BUG> if ( ! ( _data . containsKey ( index ) ) ) { Object cached ; if ( obj == null ) cached = null ; else if ( ! ( _proj ) ) cached = _sctx . getObjectId ( obj ) ; else { Object [ ] arr = ( ( Object [ ] ) ( obj ) ) ; Object [ ] cp = new Object [ arr . length ] ; for ( int i = 0 ; i < ( arr . length ) ; i ++ ) cp [ i ] = QueryCacheStoreQuery . copyProjection ( arr [ i ] , _sctx ) ; cached = cp ; } if ( cached != null ) _data . put ( index , cached ) ; } } finished = ( _size ) == ( _data . size ( ) ) ; } } if ( finished ) { _cache . writeLock ( ) ; try { if ( _maintainCache ) { QueryResult res = null ; synchronized ( this ) { res = new QueryResult ( _qk , _data . values ( ) ) ; res . setTimestamp ( System . currentTimeMillis ( ) ) ; } _cache . put ( _qk , res ) ; abortCaching ( ) ; } } finally { _cache . writeUnlock ( ) ; } } } public boolean supportsRandomAccess ( ) { } public void open ( ) throws Exception { } public Object getResultObject ( ) throws Exception { } public boolean next ( ) throws Exception { } public boolean absolute ( int pos ) throws Exception { }

Fix:
Integer index = _pos ;