Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dealing with HashMap objects #488

ArnoldCell opened this issue May 1, 2018 · 2 comments


Copy link

commented May 1, 2018

I am trying to print the values of an object with a type of
HashMap<String, Long>

When I try to use obj.get(someString) i get an error:
TypeError: undefined not callable (property 'get' of [object Object])

When i'm trying to cast the object with Java.cast()
i get an invalid argument value error.

How can i handle an object type of HashMap?


This comment has been minimized.

Copy link

commented Jul 17, 2018

well i really dont know how to iterate it yet but my workaround to at least be able to print it using console.log is

var HashMap = Java.use("java.util.HashMap");
var c = Java.cast(b,HashMap);

where b is the [Object object] thats is supposed to be a hashmap object.


This comment has been minimized.

Copy link

commented May 7, 2019

Commenting in case anyone else encounters issues with this. I've found using Java iterators the best way to print keys/values of a HashMap. Assuming you have a hashmap variable already, you can do something like this:

var HashMapNode = Java.use('java.util.HashMap$Node');

var iterator = hashmap.entrySet().iterator();
while (iterator.hasNext()) {
  var entry = Java.cast(, HashMapNode);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.