appstore: convert JNI surface to shared jni_fn! macro
- Commit
6417f556cbc06881ffc2d5b56413444894768fa1- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-01 19:53 UTC (4 days ago)
- Parents
b04d0e1
LOC Phase 5 rollout. The single appstore_signify JNI function repeated the EnvUnowned / with_env / LogErrorAndDefault scaffold and converts to jni_bridge::jni_fn!. The body is verbatim (verified token-for-token); handles and null checks stay in it, and the now-unused EnvUnowned import is dropped. Lines: jni_bridge.rs 32 -> 21 (-11, -34.4%); structure_check appstore module counted after (structure: OK). Cargo.lock gains only the jni_bridge edge for appstore_signify. Verified: nm -D on libappstore_signify.so before/after - exported symbol set identical (1/1 Java_ SignifyNative symbol); cargo test -p appstore_signify: 35 passed; no JVM test class loads SignifyNative, so no JVM bridge test exists to run; cargo fmt --check -p appstore_signify clean.
Diff
Cargo.lock
diff --git a/Cargo.lock b/Cargo.lockindex 27c55e8aa7..bce02e3c01 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -299,6 +299,7 @@ dependencies = [ "base64 0.23.1", "ed25519-dalek 3.0.0", "jni",+ "jni_bridge", ] [[package]]
appstore/src/main/rust/Cargo.toml
diff --git a/appstore/src/main/rust/Cargo.toml b/appstore/src/main/rust/Cargo.tomlindex 69012fd70a..71357bdfbb 100644--- a/appstore/src/main/rust/Cargo.toml+++ b/appstore/src/main/rust/Cargo.toml@@ -11,6 +11,7 @@ crate-type = ["cdylib", "rlib"] base64.workspace = true ed25519-dalek.workspace = true jni.workspace = true+jni_bridge = { path = "../../../../library/jni-bridge/src/main/rust" } [dev-dependencies] # Test-only: the checked-in vectors are the real signify files, so the tests do # the same base64 + offset extraction the Kotlin caller does.
appstore/src/main/rust/src/jni_bridge.rs
diff --git a/appstore/src/main/rust/src/jni_bridge.rs b/appstore/src/main/rust/src/jni_bridge.rsindex d07f4c4c42..cfe650ba66 100644--- a/appstore/src/main/rust/src/jni_bridge.rs+++ b/appstore/src/main/rust/src/jni_bridge.rs@@ -5,28 +5,17 @@ use crate::verify_inputs; use jni::objects::{JByteArray, JClass}; use jni::sys::jboolean;-use jni::{Env, EnvUnowned};+use jni::Env;+use jni_bridge::jni_fn; fn bytes_in(env: &Env, arr: &JByteArray) -> Option<Vec<u8>> { env.convert_byte_array(arr).ok() } -/// Returns `1` only for a valid signature; `0` for everything else, including-/// a failed array read. Never throws — the Kotlin caller treats `false` as-/// "not verified", so a thrown exception would only turn a clean rejection-/// into a crash.-#[no_mangle]-pub extern "system" fn Java_com_vayunmathur_appstore_data_accrescent_SignifyNative_nativeVerify<- 'l,->(- mut env: EnvUnowned<'l>,- _class: JClass<'l>,- pubkey: JByteArray<'l>,- msg: JByteArray<'l>,- sig: JByteArray<'l>,-) -> jboolean {- env.with_env(|env| -> jni::errors::Result<jboolean> {- Ok(verify_inputs(bytes_in(env, &pubkey), bytes_in(env, &msg), bytes_in(env, &sig)))- })- .resolve::<jni::errors::LogErrorAndDefault>()-}+// Returns `1` only for a valid signature; `0` for everything else, including+// a failed array read. Never throws — the Kotlin caller treats `false` as+// "not verified", so a thrown exception would only turn a clean rejection+// into a crash.+jni_fn! { Java_com_vayunmathur_appstore_data_accrescent_SignifyNative_nativeVerify -> jboolean; (_class: JClass<'l>, pubkey: JByteArray<'l>, msg: JByteArray<'l>, sig: JByteArray<'l>) |env| {+ Ok(verify_inputs(bytes_in(env, &pubkey), bytes_in(env, &msg), bytes_in(env, &sig)))+} }