fix(jni): report Sapling parameter initialization failures

Draft
FE
3d ago
+436-16

Parameter-file I/O errors, invalid contents and digest mismatches currently reach a void Rust initializer that can abort the JVM. Call librustzcash_init_zksnark_params_checked and propagate failures as Java exceptions while preserving the existing Java method descriptor.

The JNI implementation rejects null/invalid arguments, uses standard UTF-8 and byte lengths for Unix paths (including supplementary Unicode characters), retains UTF-16 path units on Windows, and releases string/array leases on all exits. Native I/O, size, hash, parsing and initialization-state errors become IllegalStateException; invalid representations become IllegalArgumentException. A failure cannot return normally and allow the caller to mark initialization complete.

The Rust submodule is pinned to 0e03e8e, on the independent fix/checked-sapling-parameter-init branch based on release_vm_zksnarks_4.1. That revision publishes parameters and verification keys atomically, permits retry after failure, accepts repeated identical digests, and rejects replacement with different digests. The submodule branch hint now follows release_vm_zksnarks_4.1. A fresh submodule checkout from the configured tronprotocol/librustzcash URL successfully fetched this exact revision.

Validation on macOS x86_64 with a freshly rebuilt release Rust/JNI library and JDK 8:

  • All 35 SDK tests passed: 33 existing tests plus two new child-JVM regression cases.
  • Both new regression cases also passed using java-tron's production parameter files and fixed expected hashes.
  • Coverage includes nulls, malformed hashes/paths, missing and oversized files, digest/parse failures, failure after loading the first file, retry, eight concurrent initializers, duplicate/conflicting requests, and Chinese/emoji paths.
  • Child JVMs use -Xcheck:jni, a timeout, and private fixture directories. No CheckJNI warnings occurred during initialization calls. Old-JDK launcher/NIO warnings outside those calls were independently reproduced without the SDK.
  • The pinned Rust source passed all 15 ordinary library tests. Existing tests verify successful Java flows; the new tests verify actual native failure propagation.
  • Reproduction instructions: cpp/tests/parameter-initialization.md. The new tests require init.test.library and skip when it is absent.

Draft / remaining release work: the four bundled native libraries have not been replaced. Default Maven tests still use old resources and cannot establish that this fix ships. Merge/adopt the Rust initialization change, rebuild Linux/macOS x86_64/arm64 JNI libraries, rerun the regressions, replace the resources, and verify the exact libraries in the packaged SDK JAR before release. Windows and Linux JNI execution were not validated locally.

This PR is independently based on develop. It does not include or modify the entropy changes in #20, Rust #13, or the separate changes in #17/#19. Combining these fixes later requires a Rust revision containing the desired changes and a fresh native rebuild.