Buggy code:
public class IntOpenHashMap < V > implements Externalizable { private static final long serialVersionUID = - 8162355845665353513L ; protected static final byte FREE = 0 ; protected static final byte FULL = 1 ; protected static final byte REMOVED = 2 ; private static final float DEFAULT_LOAD_FACTOR = 0.7F ; private static final float DEFAULT_GROW_FACTOR = 2.0F ; protected final transient float _loadFactor ; protected final transient float _growFactor ; protected int _used = 0 ; protected int _threshold ; protected int [ ] _keys ; protected V [ ] _values ; protected byte [ ] _states ; @ SuppressWarnings ( "unchecked" ) protected IntOpenHashMap ( int size , float loadFactor , float growFactor , boolean forcePrime ) { } public IntOpenHashMap ( int size , float loadFactor , float growFactor ) { } public IntOpenHashMap ( int size ) { } public IntOpenHashMap ( ) { } public boolean containsKey ( int key ) { } public final V get ( final int key ) { } public V put ( final int key , final V value ) { } public V putIfAbsent ( final int key , final V value ) { } protected boolean isFree ( int index , int key ) { } protected boolean preAddEntry ( int index ) { } protected void postAddEntry ( int index ) { } private int findKey ( int key ) { } public V remove ( int key ) { } public int size ( ) { } public void clear ( ) { } @ SuppressWarnings ( "unchecked" ) public IntOpenHashMap . IMapIterator < V > entries ( ) { } @ Override public String toString ( ) { } private void ensureCapacity ( int newCapacity ) { } @ SuppressWarnings ( "unchecked" ) protected void rehash ( int newCapacity ) { } private static int keyHash ( int key ) { } protected void recordAccess ( int idx ) { } protected void recordRemoval ( int idx ) { } public void writeExternal ( ObjectOutput out ) throws IOException { } @ SuppressWarnings ( "unchecked" ) public void readExternal ( ObjectInput in ) throws IOException , ClassNotFoundException { this . _threshold = in . readInt ( ) ; this . _used = in . readInt ( ) ; int keylen = in . readInt ( ) ; int [ ] keys = new int [ keylen ] ; V [ ] values = ( ( V [ ] ) ( new Object [ keylen ] ) ) ; byte [ ] states = new byte [ keylen ] ; for ( int i = 0 ; i < ( _used ) ; i ++ ) { int k = in . readInt ( ) ; V v = ( ( V ) ( in . readObject ( ) ) ) ; int hash = IntOpenHashMap . keyHash ( k ) ; int keyIdx = hash % keylen ; if ( ( states [ keyIdx ] ) != ( IntOpenHashMap . FREE ) ) { int decr = 1 + ( hash % ( keylen - 2 ) ) ; for ( ; ; ) { keyIdx -= decr ; <START_BUG> if ( i < 0 ) { <END_BUG> keyIdx += keylen ; } if ( ( states [ keyIdx ] ) == ( IntOpenHashMap . FREE ) ) { break ; } } } states [ keyIdx ] = IntOpenHashMap . FULL ; keys [ keyIdx ] = k ; values [ keyIdx ] = v ; } this . _keys = keys ; this . _values = values ; this . _states = states ; } public interface IMapIterator < V > { public boolean hasNext ( ) { } public int next ( ) { } public int getKey ( ) { } public V getValue ( ) { } } @ SuppressWarnings ( "rawtypes" ) private final class MapIterator implements IntOpenHashMap . IMapIterator { int nextEntry ; int lastEntry = - 1 ; MapIterator ( ) { } int nextEntry ( int index ) { } public boolean hasNext ( ) { } public int next ( ) { } public int getKey ( ) { } public V getValue ( ) { } } public static final class IntOpenLRUMap < V > extends IntOpenHashMap < V > { private static final long serialVersionUID = - 1884240205310136433L ; private final int maxCapacity ; private final IntOpenHashMap . IntOpenLRUMap . ChainEntry evictChainHeader ; private boolean reachedLimit = false ; private IntOpenHashMap . IntOpenLRUMap . ChainEntry [ ] _entries ; public IntOpenLRUMap ( int limit ) { } public IntOpenLRUMap ( int init , int limit ) { } private IntOpenHashMap . IntOpenLRUMap . ChainEntry initEntryChain ( ) { } @ Override protected boolean preAddEntry ( int index ) { } private V directRemove ( int index ) { } @ Override protected void postAddEntry ( int idx ) { } @ Override protected void recordAccess ( int idx ) { } @ Override protected void recordRemoval ( int idx ) { } private boolean removeEldestEntry ( ) { } @ Override protected boolean isFree ( int index , int key ) { } @ Override public int size ( ) { } @ SuppressWarnings ( "unchecked" ) @ Override public IntOpenHashMap . IMapIterator < V > entries ( ) { } @ SuppressWarnings ( "unchecked" ) @ Override protected final void rehash ( int newCapacity ) { } static final class ChainEntry { final int entryIndex ; IntOpenHashMap . IntOpenLRUMap . ChainEntry prev = null ; IntOpenHashMap . IntOpenLRUMap . ChainEntry next = null ; public ChainEntry ( int index ) { } private void remove ( ) { } private void addBefore ( IntOpenHashMap . IntOpenLRUMap . ChainEntry existingEntry ) { } } @ SuppressWarnings ( "rawtypes" ) final class OrderedMapIterator implements IntOpenHashMap . IMapIterator { private IntOpenHashMap . IntOpenLRUMap . ChainEntry entry ;

Fix:
if ( keyIdx < 0 ) {