Upgrade JNI (jni crate) 0.21.1 → 0.22.4#166
Draft
emmanuel-keller wants to merge 1 commit into
Draft
Conversation
Migrate the native layer to the jni crate 0.22.4 (a major API overhaul). The Java public API, JNI ABI / native method symbols, JDK 8 minimum, and the structured ServerException hierarchy are all unchanged. - Native methods now take EnvUnowned and run their body via Env::with_env (the new EnvUnowned/Env split). A with_env_body! macro + resolve_outcome helper keep the existing raw jobject/jstring/jlong return types and the SurrealError::exception sink (resolve() needs T: Default, which raw pointers are not, so the outcome is resolved via into_outcome()). - String method/constructor signatures -> jni_sig!; class and method names -> jni_str! (or JNIString for dynamic names); Env::get_string (deprecated) -> JString::try_to_string. - jni-sys 0.4 makes jboolean = bool: JValue::Bool and the jboolean default closures/params were adjusted accordingly. - JObject -> JThrowable via Env::cast_local; typed JObjectArray<JString>; array length/region/element APIs via JObjectArray/JPrimitiveArray. Explicit #[no_mangle] export names are kept (not #[jni_mangle]) so the 189 Java_com_surrealdb_* symbols stay byte-identical. Verified: cargo build/clippy/fmt clean, 189 export symbols unchanged, 288 Java tests pass (2 skipped, OS-specific).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Upgrades the native layer to the
jniRust crate0.22.4(latest), a major API overhaul, in preparation for the 2.1.0 driver release. This is a Rust-side-only change — the Java public API, JNI ABI / native method symbols, JDK 8 minimum, and the structuredServerExceptionhierarchy are all unchanged.Branched off
main; the unrelated surrealdb 3.1.2 bump is intentionally not included (this PR keeps surrealdb at 3.0.5).Key changes (jni 0.22 is a major overhaul)
JNIEnvsplit intoEnvUnowned+Env. Native methods now takeEnvUnownedand run their body viaEnv::with_env. A smallwith_env_body!macro +resolve_outcomehelper keep the existing rawjobject/jstring/jlongreturn types and theSurrealError::exceptionsink. (EnvOutcome::resolverequiresT: Default, which raw pointers are not, so the outcome is resolved viainto_outcome().)jni_sig!; class/method names →jni_str!(orJNIStringfor dynamic names); deprecatedEnv::get_string→JString::try_to_string.jni-sys 0.4makesjboolean = bool—JValue::Booland thejbooleandefault closures/params were adjusted.JObject→JThrowableviaEnv::cast_local; typedJObjectArray<JString>; array APIs viaJObjectArray/JPrimitiveArray.#[no_mangle]export names are kept (not#[jni_mangle]) so the 189Java_com_surrealdb_*symbols stay byte-identical — zeroUnsatisfiedLinkErrorrisk. (Switching to#[jni_mangle]later is mechanical if preferred.)Verification
cargo build/cargo clippy/cargo fmt --all --check— clean (0 warnings)nm— 189Java_com_surrealdb_*export symbols, names byte-identical