Skip to content

HashMap null key crashes program #7

Open
@Erhannis

Description

From what I can infer, HashMaps are replaced at runtime by a custom implementation, probably for better logging. However, it fails to account for null keys (which are valid for HashMaps, and not for the Hashtables, though I'm not certain if a true Hashtable is used anywhere). The following is a (slightly anonymized) stack trace:

.Debugger com.myprogram.Main
ODB: 28.Mar.07
ODB: Reading .debuggerDefaults file...
In target program2:
class com.myprogram.Main.main threw java.lang.NullPointerException
java.lang.NullPointerException
        at com.lambda.Debugger.Shadow.hashtablePut(Shadow.java:1977)
        at com.lambda.Debugger.D.hashMapPut(D.java:683)
        at com.lambda.Debugger.MyHashMap.put(MyHashMap.java:30)
        at com.myprogram.Main.main(Main.java:66)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.lambda.Debugger.Debugger.runTarget(Debugger.java:1141)
        at com.lambda.Debugger.Debugger$1.run(Debugger.java:1199)
        at java.lang.Thread.run(Thread.java:748)
ODB: 28.Mar.07 run complete.

The relevant lines of code in Main.main() would be:

HashMap<Integer, Integer> blah = new HashMap<>();
blah.put(5, 6);
blah.put(null, 1);
blah.put(7, 8);

which would crash on the third line, the one with a null key.

I'm attempting to fix the bug, but depending on how deep the rabbit hole goes, I may not make it.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions