cargo jni 0.22.1
Release JNI 0.22.1

6 hours ago

This release fixes several issues found shortly after releasing 0.22.0 which unfortunately required a few breaking changes.

Instead of bumping to 0.23 though, the assumption 🤞 is that no one will yet be depending on the recently-released
0.22.0 and so we can yank that and have this represent the first 0.22.x release.

In particular this addresses the following issues:

Added

  • Env::exception_catch provides a convenient way of catching pending Java exceptions and mapping them to Error::CaughtJavaException (#736)
  • AttachGuard::detach_with_catch lets you explicitly detach/drop a guard (like ::detach()) and catch any pending Java exception as a Error::CaughtJavaException (#736).
  • JClass::get_name lets you query the binary name for a class, such as java.lang.String (#736)

Changed

The following APIs have had to be made fallible again, in order to safely check for pending exceptions before calling
JNI functions that are not documented as being safe to call with a pending exception:

  • Env::get_java_vm (GetJavaVM is not exception safe)
  • Env::version (GetVersion is not exception safe)
  • Env::is_same_object (IsSameObject is not exception safe)
  • Weak::is_garbage_collected (based on Env::is_same_object)
  • Weak::is_same_object (deprecated) and (based on
    Env::is_same_object)
  • Weak::is_weak_ref_to_same_object (deprecated) (based on
    Env::is_same_object)

Note: These are a breaking change.

Fixed in #733

  • JavaVM::attach_current_thread* APIs all finish by calling AttachGuard::detach_with_catch to clear pending Java exceptions - mapping to Error::CaughtJavaException (#736)
  • Env::throw* APIs now return Error::JavaException after throwing and creating a pending exception that must be handled before using JNI further (#738)

Don't miss a new jni release

NewReleases is sending notifications on new releases.