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

[deps]: Update Rust crate jni to >=0.19, <0.22 #57

Closed
wants to merge 1 commit into from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Dec 9, 2024

This PR contains the following updates:

Package Type Update Change
jni dependencies minor >=0.19, <0.20 -> >=0.19, <0.22

Release Notes

jni-rs/jni-rs (jni)

v0.21.1

Compare Source

Fixes
  • Compilation is fixed for architectures with a C ABI that has unsigned char types. (#​419)

v0.21.0

Compare Source

This release makes extensive breaking changes in order to improve safety. Most projects that use this library will need to be changed. Please see the migration guide.

Added
  • JavaStr::into_raw() which drops the JavaStr and releases ownership of the raw string pointer (#​374)
  • JavaStr::from_raw() which takes ownership of a raw string pointer to create a JavaStr (#​374)
  • JNIEnv::get_string_unchecked is a cheaper, unsafe alternative to get_string that doesn't check the given object is a java.lang.String instance. (#​328)
  • WeakRef and JNIEnv#new_weak_ref. (#​304)
  • define_class_bytearray method that takes an AutoElements<jbyte> rather than a &[u8] (#​244)
  • JObject now has an as_raw method that borrows the JObject instead of taking ownership like into_raw. Needed because JObject no longer has the Copy trait. (#​392)
  • JavaVM::destroy() (unsafe) as a way to try and unload a JavaVM on supported platforms (#​391)
  • JavaVM::detach_current_thread() (unsafe) as a way to explicitly detach a thread (normally this is automatic on thread exit). Needed to detach daemon threads manually if using JavaVM::destroy() (#​391)
  • JPrimitiveArray<T: TypeArray> and type-specific aliases like JByteArray, JIntArray etc now provide safe, reference wrappers for the sys types jarray and jbyteArray etc with a lifetime like JObject (#​400)
  • JObjectArray provides a reference wrapper for a jobjectArray with a lifetime like JObject. (#​400)
  • AutoElements and AutoElementsCritical (previously AutoArray/AutoPrimitiveArray) implement Deref<Target=[T]> and DerefMut so array elements can be accessed via slices without needing additional unsafe code. (#​400)
  • AsJArrayRaw trait which enables JNIEnv::get_array_length() to work with JPrimitiveArray or JObjectArray types (#​400)
  • InitArgsBuilder now has try_option and option_encoded methods. (#​414)
Changed
  • JNIEnv::get_string checks that the given object is a java.lang.String instance to avoid undefined behaviour from the JNI implementation potentially aborting the program. (#​328)
  • JNIEnv::call_*method_unchecked was marked unsafe, as passing improper argument types, or a bad number of arguments, can cause a JVM crash. (#​385)
  • The JNIEnv::new_object_unchecked function now takes arguments as &[jni::sys::jvalue] to avoid allocating, putting it inline with changes to JniEnv::call_*_unchecked from 0.20.0 (#​382)
  • The get_superclass function now returns an Option instead of a null pointer if the class has no superclass (#​151)
  • The invocation feature now locates the JVM implementation dynamically at runtime (via the java-locator crate by default) instead of linking with the JVM at build time (#​293)
  • Most JNIEnv methods now require &mut self. This improves safety by preventing JObjects from getting an invalid lifetime. Most native method implementations (that is, #[no_mangle] extern "system" fns) must now make the JNIEnv parameter mut. See the example on the crate documentation. (#​392)
  • JByteBuffer, JClass, JNIEnv, JObject, JString, and JThrowable no longer have the Clone or Copy traits. This improves safety by preventing object references from being used after the JVM deletes them. Most functions that take one of these types as a parameter (except extern fns that are directly called by the JVM) should now borrow it instead, e.g. &JObject instead of JObject. (#​392)
  • AutoLocal is now generic in the type of object reference (JString, etc). (#​392)
  • The closure passed to JNIEnv::with_local_frame must now take a &mut JNIEnv parameter, which has a different lifetime. This improves safety by preventing local references from escaping the closure, which would cause a use-after-free bug. Executor::with_attached and Executor::with_attached_capacity have been similarly changed. (#​392)
  • The closure passed to JNIEnv::with_local_frame can now return a generic Result<T, E> so long as the error implements From<jni::errors::Error> (#​399)
  • JNIEnv::with_local_frame now returns the same type that the given closure returns (#​399)
  • JNIEnv::with_local_frame no longer supports returning a local reference directly to the calling scope (see with_local_frame_returning_local) (#​399)
  • Executor::with_attached and Executor::with_attached_capacity have been changed in the same way as JNIEnv::with_local_frame (they are thin wrappers) (#​399)
  • Desc, JNIEnv::pop_local_frame, and TypeArray are now unsafe. (#​392)
  • The Desc trait now has an associated type Output. Many implementations now return AutoLocal, so if you call Desc::lookup yourself and then call as_raw on the returned object, make sure the AutoLocal isn't dropped too soon (see the Desc::lookup documentation for examples). (#​392)
  • The Desc<JClass> trait is no longer implemented for JObject or &JObject. The previous implementation that called .get_object_class() was surprising and a simpler cast would make it easy to mistakenly pass instances where a class is required. (#​118)
  • Named lifetimes in the documentation have more descriptive names (like 'local instead of 'a). The new naming convention is explained in the JNIEnv documentation. (#​392)
  • Object reference types (JObject, JClass, AutoLocal, GlobalRef, etc) now implement AsRef<JObject> and Deref<Target = JObject>. Typed wrappers like JClass also implement Into<JObject>, but GlobalRef does not. (#​392)
  • Most JList and JMap methods now require a &mut JNIEnv parameter. JListIter and JMapIter no longer implement Iterator, and instead have a next method that requires a &mut JNIEnv parameter (use while let loops instead of for). (#​392)
  • JValue has been changed in several ways: (#​392)
    • It is now a generic type named JValueGen. JValue is now a type alias for JValueGen<&JObject>, that is, it borrows an object reference. JValueOwned is a type alias for JValueGen<JObject>, that is, it owns an object reference.
    • JValueOwned does not have the Copy trait.
    • The to_jni method is now named as_jni, and it borrows the JValueGen instead of taking ownership.
    • JObject can no longer be converted directly to JValue, which was commonly done when calling Java methods or constructors. Instead of obj.into(), use (&obj).into().
  • All JNIEnv array APIs now work in terms of JPrimitiveArray and JObjectArray (reference wrappers with a lifetime) instead of sys types like jarray and jbyteArray (#​400)
  • AutoArray and AutoPrimitiveArray have been renamed AutoElements and AutoElementsCritical to show their connection and differentiate from new JPrimitiveArray API (#​400)
  • get_primitive_array_critical is now unsafe and has been renamed to get_array_elements_critical (consistent with the rename of AutoPrimitiveArray) with more detailed safety documentation (#​400)
  • get_array_elements is now also unsafe (for many of the same reasons as get_array_elements_critical) and has detailed safety documentation (#​400)
  • AutoArray/AutoArrayCritical::size() has been replaced with .len() which can't fail and returns a usize (#​400)
  • The TypeArray trait is now a private / sealed trait, that is considered to be an implementation detail for the AutoArray API.
  • JvmError has several more variants and is now non_exhaustive. (#​414)
  • InitArgsBuilder::option raises an error on Windows if the string is too long. The limit is currently 1048576 bytes. (#​414)
Fixed
  • Trying to use an object reference after it has been deleted now causes a compile error instead of undefined behavior. As a result, it is now safe to use AutoLocal, JNIEnv::delete_local_ref, and JNIEnv::with_local_frame. (Most of the limitations added in #​392, listed above, were needed to make this work.) (#​381, #​392)
  • Class lookups via the Desc trait now return AutoLocals, which prevents them from leaking. (#​109, #​392)
  • InitArgsBuilder::option properly encodes non-ASCII characters on Windows. (#​414)
Removed
  • get_string_utf_chars and release_string_utf_chars from JNIEnv (See JavaStr::into_raw() and JavaStr::from_raw() instead) (#​372)
  • All JNIEnv::get_<type>_array_elements() methods have been removed as redundant since they would all be equivalent to get_array_elements() with the introduction of JPrimitiveArray (#​400)

v0.20.0

Compare Source

Added
  • Default trait implemented for JObject, JString, JClass, and JByteBuffer (#​199)
  • Debug trait implemented for JavaVM, GlobalRef, GlobalRefGuard, JStaticMethodID and ReleaseMode (#​345)
  • ReturnType for specifying object return types without a String allocation. (#​329)
Changed
  • The release_string_utf_chars function has been marked as unsafe. (#​334)
  • Mark JNIEnv::new_direct_byte_buffer as unsafe (#​320)
  • JNIEnv::new_direct_byte_buffer now takes a raw pointer and size instead of a slice (#​351 and #​364)
  • JNIEnv::direct_buffer_address returns a raw pointer instead of a slice (#​364)
  • The lifetime of AutoArray is no longer tied to the lifetime of a particular JNIEnv reference. (#​302)
  • Relaxed lifetime restrictions on JNIEnv::new_local_ref. Now it can be used to create a local
    reference from a global reference. (#​301 / #​319)
  • JMethodID and JStaticMethodID implement Send + Sync and no longer has a lifetime parameter, making method
    IDs cacheable (with a documented 'Safety' note about ensuring they remain valid). (#​346)
  • JFieldID and JStaticFieldID implement Send + Sync and no longer has a lifetime parameter, making field
    IDs cacheable (with a documented 'Safety' note about ensuring they remain valid). (#​346)
  • The call_*_method_unchecked functions now take jni:sys::jvalue arguments to avoid allocating
    a Vec on each call to map + collect JValues as sys:jvalues (#​329)
  • The From trait implementations converting jni_sys types like jobject to JObject have been replaced
    with unsafe ::from_raw functions and corresponding ::into_raw methods. Existing ::into_inner APIs were
    renamed ::into_raw for symmetry. (#​197)
  • The APIs JNIEnv::set_rust_field, JNIEnv::get_rust_field and JNIEnv::take_rust_field have been marked as unsafe (#​219)

Configuration

📅 Schedule: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

Copy link
Contributor Author

renovate bot commented Dec 9, 2024

⚠️ Artifact update problem

Renovate failed to update an artifact related to this branch. You probably do not want to merge this PR as-is.

♻ Renovate will retry this branch, including artifacts, only when one of the following happens:

  • any of the package files in this branch needs updating, or
  • the branch becomes conflicted, or
  • you click the rebase/retry checkbox if found above, or
  • you rename this PR's title to start with "rebase!" to trigger it manually

The artifact failure details are included below:

File name: Cargo.lock
Command failed: cargo update --config net.git-fetch-with-cli=true --manifest-path crates/bitwarden-uniffi/Cargo.toml --package [email protected] --precise 0.21.1
    Updating crates.io index
error: failed to select a version for the requirement `jni = "^0.19"`
candidate versions found which didn't match: 0.21.1
location searched: crates.io index
required by package `rustls-platform-verifier v0.3.4`
    ... which satisfies dependency `rustls-platform-verifier = "^0.3.4"` (locked to 0.3.4) of package `bitwarden-core v1.0.0 (/tmp/renovate/repos/github/bitwarden/sdk-internal/crates/bitwarden-core)`

@bitwarden-bot bitwarden-bot changed the title [deps]: Update Rust crate jni to >=0.19, <0.22 [PM-15733] [deps]: Update Rust crate jni to >=0.19, <0.22 Dec 9, 2024
@bitwarden-bot
Copy link

Internal tracking:

Copy link

codecov bot commented Dec 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.89%. Comparing base (ceba460) to head (a12c59e).
Report is 14 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #57   +/-   ##
=======================================
  Coverage   63.89%   63.89%           
=======================================
  Files         186      186           
  Lines       12905    12905           
=======================================
  Hits         8246     8246           
  Misses       4659     4659           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@renovate renovate bot changed the title [PM-15733] [deps]: Update Rust crate jni to >=0.19, <0.22 [deps]: Update Rust crate jni to >=0.19, <0.22 Dec 9, 2024
@Hinton Hinton requested a review from dani-garcia December 9, 2024 13:48
@dani-garcia
Copy link
Member

This needs to be updated to be in sync with rustls-platform-verifier, which as of version 0.4.0 is still using jni 0.19, so closing this for now.

@dani-garcia dani-garcia closed this Dec 9, 2024
Copy link
Contributor Author

renovate bot commented Dec 9, 2024

Renovate Ignore Notification

Because you closed this PR without merging, Renovate will ignore this update (>=0.19, <0.22). You will get a PR once a newer version is released. To ignore this dependency forever, add it to the ignoreDeps array of your Renovate config.

If you accidentally closed this PR, or if you changed your mind: rename this PR to get a fresh replacement PR.

@renovate renovate bot deleted the renovate/jni-0.x branch December 9, 2024 16:53
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

Successfully merging this pull request may close these issues.

2 participants