This is on Android.
In one of my bug report I often see this
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Object.hashCode()' on a null object reference at java.util.concurrent.ConcurrentHashMap.replaceNode(ConcurrentHashMap.java:942) at java.util.concurrent.ConcurrentHashMap.remove(ConcurrentHashMap.java:933) at xxxx.MyActivity$1.handleMessage(MyActivity.java:261) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7229) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
The code at line 261 is
handler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(Message inputMessage) {
switch (inputMessage.what) {
case 'test':
Object[] args = (Object[]) inputMessage.obj;
LatLng latLng = (LatLng) args[0];
// This is the line where the error is thrown
Circle circle = mapCircles.remove(latLng);
}
}
Basically my threads send a message to the UI handler. mapCircles is a ConcurentHashMap
I know it is hard to help, but does any one know what causes the java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Object.hashCode()' ?
Does the latLng object becomes null at some points in its lifetime? if latLng WAS null the errorwould have been something else mapCircles is definitely not null