Don't throw an exception the first time we initialize IntHashMap.

This commit is contained in:
Kristian S. Stangeland 2013-08-29 23:57:20 +02:00
parent fc01a61290
commit 8295b951d9

View File

@ -98,9 +98,25 @@ public class WrappedIntHashMap {
* @return The object that was removed, or NULL if the key is not present.
*/
public Object remove(int key) {
initializeGetMethod();
if (REMOVE_METHOD == null)
return removeFallback(key);
return invokeMethod(REMOVE_METHOD, key);
}
/**
* Remove a entry in the IntHashMap using a fallback method.
* @param key - the key of the mapping to remove.
* @return The removed element.
*/
private Object removeFallback(int key) {
Object old = get(key);
invokeMethod(PUT_METHOD, key, null);
return old;
}
/**
* Invoke a particular method on the current handle
* @param method - the current method.
@ -162,7 +178,9 @@ public class WrappedIntHashMap {
// Suppress
}
}
throw new IllegalStateException("Unable to find appropriate GET_METHOD for IntHashMap.");
if (GET_METHOD == null)
throw new IllegalStateException("Unable to find appropriate GET_METHOD for IntHashMap.");
}
}