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

JClass::from, JString::from, JThrowable::from, etc. safety #515

Open
uvlad7 opened this issue Dec 28, 2023 · 2 comments
Open

JClass::from, JString::from, JThrowable::from, etc. safety #515

uvlad7 opened this issue Dec 28, 2023 · 2 comments

Comments

@uvlad7
Copy link

uvlad7 commented Dec 28, 2023

Shouldn't these be unsafe, as there are no is_instance_of/is_assignable_from checks inside?

@rib
Copy link
Contributor

rib commented Jan 1, 2024

In general it's not expected to be a Rust/JNI safety issue to mix up object reference types (e.g. calling methods against the wrong class), since that usually leads to an exception which would be considered safe, even though it likely implies a bug.

Some specific JNI functions are more strict about the object types they are passed and jni-rs should (hopefully) already be using is_instance_of or similar for those cases.

@uvlad7
Copy link
Author

uvlad7 commented Jan 1, 2024

I don't see any of these checks anywhere in the source code other than the tests.

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

2 participants