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

how to get java list on rust #444

Closed
popeye2022 opened this issue Apr 4, 2023 · 2 comments
Closed

how to get java list on rust #444

popeye2022 opened this issue Apr 4, 2023 · 2 comments

Comments

@popeye2022
Copy link

popeye2022 commented Apr 4, 2023

let elem = env.get_object_array_element(&_list_params, i).expect("msg"); let witness_object = env.get_field(&elem, "name", "J").expect("witness field not found");
java will crash ,this is error log

Internal exceptions (2 events):
Event: 0.201 Thread 0x00007fae26809000 Exception <a 'java/lang/NoSuchMethodError': Method sun.misc.Unsafe.defineClass(Ljava/lang/String;[BII)Ljava/lang/Class; name or signature does not match> (0x000000076ab07ce0) thrown at [/System/Volumes/Data/jenkins/workspace/8-2-build-macosx-x64/jdk8u361/
Event: 0.201 Thread 0x00007fae26809000 Exception <a 'java/lang/NoSuchMethodError': Method sun.misc.Unsafe.prefetchRead(Ljava/lang/Object;J)V name or signature does not match> (0x000000076ab07fc8) thrown at [/System/Volumes/Data/jenkins/workspace/8-2-build-macosx-x64/jdk8u361/3183/hotspot/src/s

@argv-minus-one
Copy link
Contributor

If _list_params is a reference to a java.util.List rather than a Java array, then yes, this is incorrect. Use jni::objects::JList to access the contents of a java.util.List.

@rib
Copy link
Contributor

rib commented Jan 1, 2024

Going to close this, while guessing that get_object_array_element wasn't being passed a JObjectArray - judging by the name of the variable and exception.

I guess this may have also been tested with a version of jni -rs before #400 landed which improved the type safety of this API.

Please re-open if can provide more details.

@rib rib closed this as completed Jan 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants