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

Guarantee that JNIEnv::fatal_error will not panic or allocate. Expa… #480

Merged
merged 1 commit into from
Dec 31, 2023

Conversation

argv-minus-one
Copy link
Contributor

@argv-minus-one argv-minus-one commented Jul 29, 2023

Overview

This PR adds a guarantee that JNIEnv::fatal_error will not panic or allocate.

This is needed in order to write a panic handler for native methods without the “fatal_error can panic” problem described in #432 (comment).

This has the downside (and breaking change) that fatal_error now takes a parameter of the exact type &JNIStr, which makes it somewhat more cumbersome to use. This PR expands fatal_error's documentation to explain how to use it the easy way (like in the current version of the jni crate), as well as how to prepare an error message string in a way that's unsafe but panic- and allocation-free.

This PR also expands the documentation of JNIStr and JNIString.

Note that CI testing has failed on this PR because jni-sys 0.4 is not in crates.io yet.

Definition of Done

  • There are no TODOs left in the code
  • Change is covered by automated tests
  • The coding guidelines are followed
  • Public API has documentation
  • User-visible changes are mentioned in the Changelog
  • The continuous integration build passes (NA; see above)

@argv-minus-one argv-minus-one added enhancement breaking A patch that introduces breaking changes (or an issue requiring such patch) labels Jul 29, 2023
@argv-minus-one argv-minus-one marked this pull request as ready for review July 29, 2023 01:09
@rib rib force-pushed the rib/pr/jni-sys-0-4-port branch 4 times, most recently from 9be0bcd to 538e94b Compare November 20, 2023 02:03
This also expands on the `JNIStr{,ing}` documentation.
@rib rib changed the base branch from rib/pr/jni-sys-0-4-port to master December 31, 2023 20:29
Copy link
Contributor

@rib rib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, thanks!

@rib rib merged commit 7bab0a7 into jni-rs:master Dec 31, 2023
6 checks passed
@argv-minus-one argv-minus-one deleted the fatal-error-no-panic branch January 10, 2024 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking A patch that introduces breaking changes (or an issue requiring such patch) enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants