Skip to content

chore: bump jni from 0.21.1 to 0.22.4 - #6274

Open
dependabot[bot] wants to merge 2 commits into
mainfrom
dependabot/cargo/jni-0.22.4
Open

chore: bump jni from 0.21.1 to 0.22.4#6274
dependabot[bot] wants to merge 2 commits into
mainfrom
dependabot/cargo/jni-0.22.4

Conversation

@dependabot

@dependabot dependabot Bot commented on behalf of github Sep 3, 2026

Copy link
Copy Markdown
Contributor

Bumps jni from 0.21.1 to 0.22.4.

Release notes

Sourced from jni's releases.

Release JNI 0.22.4

Added

  • JCharSequence bindings for java.lang.CharSequence (including AsRef<JCharSequence> + .as_char_sequence() for JString) (#793)
  • bind_java_type supports non_null qualifier/property for methods and fields to map null references to Error::NullPtr (#795)
  • bind_java_type supports #[cfg()] attributes on methods and fields, to conditionally compile them based on features or other cfg conditions (#797)
  • JValueOwned::check_null() + ::is_null() methods for ergonomic null checks on owned (returned) values (#798)
  • More readable type accessors for JValueOwned, like .into_bool() instead of .z(), .into_object() instead of .l(), etc (#798)

Fixed

  • jni_mangle now includes docs/macros/jni_mangle.md in the crate documentation, so the macro's documentation is visible on docs.rs and in IDEs (#799)

Full Changelog: jni-rs/jni-rs@v0.22.3...v0.22.4

Release JNI 0.22.3

No functional change in this release but it fixes the docs.rs build by bumping the simd_cesu8 dep to >= 1.1.1 which no longer has an automatically-enabled "nightly" feature that may affect the docs.rs build (1.1.x is now also MSRV compatible).

Note: Technically we shouldn't need this release (since the simd_cesu8 release alone will have fixed the build issue) but the other reason for the release is that the crates.io feature for queuing docs.rs rebuilds is not currently usable in our situation. docs.rs is currently fighting through a huge backlog of low-priority build jobs that will likely to take over a week to clear (we moved about 500 spots in two days, out of ~3k crates queued).

Release JNI 0.22.2

Note: although no breaking API change was made in this release there were some important fixes made, including a few non-trivial changes to how exceptions are handled and some important safety / soundness fixes made in the re-exported jni-macros.

For these reasons I'm going to again yank the previous 0.22.1 release after this is published, again taking into account that 0.22.1 was itself only released very recently and it should still be relatively unlikely that anyone has strictly locked in a 0.22.1 dependency.

Another benefit to yanking 0.22.1 is that it allows me to pin the jni-macros dependency via =0.22.2 in this release so that in future releases I don't need to be worried that a new jni-macros release needs to be backwards compatible with all prior jni releases (so macros can take advantage of new jni features).

Hopefully things will be smoother moving forward, now that more people have been starting to update to 0.22.x and there are more people testing it.

Added

Adds bindings for the following java.lang errors / exceptions (#767):

  • JArrayIndexOutOfBoundsException (java.lang.ArrayIndexOutOfBoundsException)
  • JArrayStoreException (java.lang.ArrayStoreException)
  • JClassCircularityError (java.lang.ClassCircularityError)
  • JClassFormatError (java.lang.ClassFormatError)
  • JExceptionInInitializerError (java.lang.ExceptionInInitializerError)
  • JClassNotFoundException (java.lang.ClassNotFoundException)
  • JIllegalArgumentException (java.lang.IllegalArgumentException)
  • JIllegalMonitorStateException (java.lang.IllegalMonitorStateException)
  • JInstantiationException (java.lang.InstantiationException)
  • JLinkageError (java.lang.LinkageError)
  • JNoClassDefFoundError (java.lang.NoClassDefFoundError)
  • JNoSuchFieldError (java.lang.NoSuchFieldError)
  • JNoSuchMethodError (java.lang.NoSuchMethodError)
  • JNumberFormatException (java.lang.NumberFormatException)
  • JOutOfMemoryError (java.lang.OutOfMemoryError)
  • JRuntimeException (java.lang.RuntimeException)
  • JSecurityException (java.lang.SecurityException)

... (truncated)

Changelog

Sourced from jni's changelog.

[0.22.4] — 2026-03-16

Added

  • JCharSequence bindings for java.lang.CharSequence (including AsRef<JCharSequence> + .as_char_sequence() for JString) (#793)
  • bind_java_type supports non_null qualifier/property for methods and fields to map null references to Error::NullPtr (#795)
  • bind_java_type supports #[cfg()] attributes on methods and fields, to conditionally compile them based on features or other cfg conditions (#797)
  • JValueOwned::check_null() + ::is_null() methods for ergonomic null checks on owned (returned) values (#798)
  • More readable type accessors for JValueOwned, like .into_bool() instead of .z(), .into_object() instead of .l(), etc (#798)

Fixed

  • jni_mangle now includes docs/macros/jni_mangle.md in the crate documentation, so the macro's documentation is visible on docs.rs and in IDEs (#799)

[0.22.3] — 2026-03-05

Fixed

  • docs.rs build: Bumps simd_cesu8 dep to >= 1.1.1 which no longer has an automatically-enabled "nightly" feature that may affect the docs.rs build (1.1.x is now also MSRV compatible) (#790)

[0.22.2] — 2026-03-01

Note: although no breaking API change was made in this release there were some important fixes made, including a few non-trivial changes to how exceptions are handled and some important safety / soundness fixes made in the re-exported jni-macros.

For these reasons I'm going to again yank the previous 0.22.1 release after this is published, again taking into account that 0.22.1 was itself only released very recently and it should still be relatively unlikely that anyone has strictly locked in a 0.22.1 dependency.

Another benefit to yanking 0.22.1 is that it allows me to pin the jni-macros dependency via =0.22.2 in this release so that in future releases I don't need to be worried that a new jni-macros release needs to be backwards compatible with all prior jni releases (so macros can take advantage of new jni features).

Hopefully things will be smoother moving forward, now that more people have been starting to update to 0.22.x and there are more people testing it.

Added

Adds bindings for the following java.lang errors / exceptions (#767):

  • JArrayIndexOutOfBoundsException (java.lang.ArrayIndexOutOfBoundsException)
  • JArrayStoreException (java.lang.ArrayStoreException)
  • JClassCircularityError (java.lang.ClassCircularityError)
  • JClassFormatError (java.lang.ClassFormatError)
  • JExceptionInInitializerError (java.lang.ExceptionInInitializerError)
  • JClassNotFoundException (java.lang.ClassNotFoundException)
  • JIllegalArgumentException (java.lang.IllegalArgumentException)
  • JIllegalMonitorStateException (java.lang.IllegalMonitorStateException)

... (truncated)

Commits
  • 5ae9458 Release jni 0.22.4
  • 2f954cd Fix copy&paste error s/JString::collection/JString::as_char_sequence/
  • 33045a1 Release jni-macros 0.22.4
  • 527703e No longer recommend passing &mut Env as the last argument
  • ce7130b Import docs/macros/jni_mangle.md docs for jni_mangle macro
  • d80bf23 Add more-ergonomic JValueOwned accessors
  • 5ffd96a bind_java_type: Support #[cfg()] guarded methods/fields
  • b498e9f bind_java_type: support non_null methods/fields
  • 1f74e4b Add objects::JCharSequence binding
  • 25f810d Release jni 0.22.3
  • Additional commits viewable in compare view

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Bumps [jni](https://github.com/jni-rs/jni-rs) from 0.21.1 to 0.22.4.
- [Release notes](https://github.com/jni-rs/jni-rs/releases)
- [Changelog](https://github.com/jni-rs/jni-rs/blob/master/CHANGELOG.md)
- [Commits](jni-rs/jni-rs@v0.21.1...v0.22.4)

---
updated-dependencies:
- dependency-name: jni
  dependency-version: 0.22.4
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot Bot added dependencies rust Pull requests that update Rust code labels Sep 3, 2026

@prql-bot prql-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The version bump on its own doesn't compile — jni 0.22 is a breaking API redesign, and prqlc/bindings/java/src/lib.rs still uses the 0.21 shapes. cargo check -p prql-java on this branch fails with 9 errors; the same command on the merge base (b3fbb00e) is clean, so this is the bump rather than something pre-existing.

Two independent breaks:

  • JNIEnv is now EnvUnowned, an FFI-only wrapper with none of the JNI methods on it. get_string, new_string, find_class and throw_new moved to Env, which you can only reach inside an EnvUnowned::with_env(...) closure whose outcome is mapped through an ErrorPolicy.
  • jni_sys::jboolean changed from u8 to bool (jni-sys #23), so format != 0 and signature != 0 no longer type-check.

I'm pushing the migration to this branch rather than just describing it — Dependabot won't act on a review. Java-visible behavior is unchanged: an unknown target dialect still throws IllegalArgumentException, a compile error still throws java.lang.Exception, and the native methods still return a null reference in both cases (JString::default() is JObject::null()). One incidental improvement falls out of with_env: a panic inside prqlc::compile is now caught and converted to a Java exception instead of unwinding out of an extern "system" function and aborting the process.

Verified with cargo check, cargo clippy -p prql-java --all-targets -- -D warnings, and ./mvnw test in prqlc/bindings/java/java/ — 3 tests pass, including a new one asserting the IllegalArgumentException path, since that's the exception type the migration re-implements by hand.

Holding approval until CI is green on the pushed commit.

Notes and alternatives

Alternative worth a maintainer's call: the Java bindings are publish = false and the publish-prql-java release job is commented out, so staying on jni 0.21 and telling Dependabot to ignore this crate is a defensible option too. I went with migrating because the rest of the tree tracks dependencies forward, but closing this in favour of an ignore entry is a reasonable call.

jboolean as bool. This is an upstream soundness tightening rather than something the bindings control: JNI's jboolean is an 8-bit value where the spec only guarantees JNI_FALSE == 0, so a JVM passing something other than 0 or 1 for a native-method argument would now be constructing an invalid bool. HotSpot normalises native-method jboolean arguments to 0/1, and there is no way to opt out short of pinning jni 0.21, so this is noted rather than actionable.

MSRV. jni 0.22.4 declares rust-version = "1.85.0", matching the workspace's rust-version, so test-msrv shouldn't be affected.

Why CI didn't say this first. Every job on the tests run for this commit is CANCELLED or SKIPPED — the run was replaced while the Dependabot batch was opening. test-java is gated on the prqlc/bindings/java/** path filter, which prqlc/bindings/java/Cargo.toml matches, so a run that isn't cancelled would have caught this.

jni 0.22 replaces the `JNIEnv` native-method argument with `EnvUnowned`,
which exposes no JNI methods; the methods now live on `Env`, reachable
only inside an `EnvUnowned::with_env` closure whose outcome is mapped
through an `ErrorPolicy`. `jni_sys::jboolean` also became `bool` rather
than `u8`, so the `!= 0` conversions no longer type-check.

Java-visible behavior is unchanged: an unknown target dialect still
throws IllegalArgumentException, a compile error still throws
java.lang.Exception, and both paths still return a null reference
(`JString::default()` is `JObject::null()`). Panics inside the compiler
are now caught by `with_env` and converted to a Java exception rather
than unwinding out of an `extern "system"` function.

Adds a test for the IllegalArgumentException path, which the migration
re-implements by hand.

@prql-bot prql-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

test-java is green on both runners at 4fedae9, and the workspace-wide clippy step in test-rust (--all-targets ... -D warnings) covers prql-java as a workspace member — so the migration is lint-clean under CI, not just locally. That clears the hold I put on this earlier.

One cleanup left, inline. java_string_with_exception resolves java/lang/Exception with find_class before throwing it, but Env::throw_new takes a class descriptor directly — throw_illegal_argument, fourteen lines above, already throws that way. The find_class call and the local reference it creates are redundant, and the Ok(())/Err(e) mapping around it is a second copy of that helper's body. I verified the replacement locally: cargo fmt --check and cargo clippy -p prql-java --all-targets -- -D warnings are clean, and ./mvnw test still passes 3/3 — including compileWithError, which is the test that exercises this exact throw path. I'm not pushing it: CI is already green, so a cleanup commit would cost a full review round for a cosmetic gain.

Not approving, and this one is my judgment rather than a repo rule. The substantive code here is a commit I pushed, so an approval from this account would restate my own confidence rather than add an independent one — and the migrate-here-or-pin-jni question from my earlier review is still an open maintainer call. Leaving the verdict to a human.

Error paths I traced against the jni 0.22.4 source

Java-visible behaviour is preserved on every path I could construct:

  • null String argumentJString::try_to_string returns Error::NullPtr for a null reference (documented on mutf8_chars), same as 0.21's get_string, so jstring_to_string still throws IllegalArgumentException.
  • unknown targetIllegalArgumentException, now covered by the new compileWithUnknownTarget test.
  • compile errorjava.lang.Exception, unchanged.
  • panic in prqlc::compilewith_env wraps the closure in catch_unwind, and ThrowRuntimeExAndDefault::on_panic converts it to a RuntimeException. Previously this unwound out of an extern "system" fn and aborted the JVM.
  • return value on errorJString's Default is JObject::null(), so the native methods still hand back a null reference alongside the pending exception.

ThrowRuntimeExAndDefault::on_error calls env.exception_check() first and returns the default without throwing when an exception is already pending, so the specific exception thrown inside the closure is the one Java sees. The doc comment on throw_illegal_argument is accurate about that.

One note on the Ok(()) => arms: throw_new delegates to throw_new_optional, which returns Err(Error::JavaException) on success and Err(Error::ThrowFailed(res)) on failure — it has no Ok path at all in 0.22.4. So those arms are unreachable. They're harmless defensive code and the comment above them already states the real contract, so I've left them alone rather than suggesting a change that only removes a branch the type system still requires.

Comment on lines 112 to 119
Err(err) => {
let message = err.to_string();
match env.find_class("java/lang/Exception") {
Ok(exception) => {
if let Err(e) = env.throw_new(exception, message) {
eprintln!("Error throwing exception: {e:?}");
}
}
Err(e) => {
eprintln!("Error finding java/lang/Exception: {e:?}");
}
}
std::ptr::null_mut()
let exception = env.find_class(jni_str!("java/lang/Exception"))?;
Err(match env.throw_new(exception, JNIString::from(message)) {
Ok(()) => JniError::JavaException,
Err(e) => e,
})
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

throw_new accepts anything that implements Desc<JClass>, which includes the &JNIStr that jni_str! produces — that's how throw_illegal_argument throws java/lang/IllegalArgumentException a few lines up. So the find_class lookup and the JClass local reference it returns aren't needed here.

Suggested change
Err(err) => {
let message = err.to_string();
match env.find_class("java/lang/Exception") {
Ok(exception) => {
if let Err(e) = env.throw_new(exception, message) {
eprintln!("Error throwing exception: {e:?}");
}
}
Err(e) => {
eprintln!("Error finding java/lang/Exception: {e:?}");
}
}
std::ptr::null_mut()
let exception = env.find_class(jni_str!("java/lang/Exception"))?;
Err(match env.throw_new(exception, JNIString::from(message)) {
Ok(()) => JniError::JavaException,
Err(e) => e,
})
}
Err(err) => {
let class = jni_str!("java/lang/Exception");
let message = JNIString::from(err.to_string());
Err(match env.throw_new(class, message) {
Ok(()) => JniError::JavaException,
Err(e) => e,
})
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant