@@ -21,7 +21,39 @@ fn main() {
2121 . handle_locks ( true ) // Enable handle locks (default, thread-safe)
2222 . source_module ( pq ! ( zenoh_flat) ) // how to prefix prebindgen-marked items (functions, types
2323 . package_prefix ( "io.zenoh.jni" ) // the package of the generated JNI bindings
24- . data_class ( pq ! ( Error ) ) // structured Kotlin data class for the Result error type
24+ // Error model: zenoh's native `ZError` is the `E` of every fallible
25+ // `Result<_, ZError>`. It never crosses as a value — a CONVERTER
26+ // (`z_error_message -> String`) marked `.default()` auto-applies a
27+ // `convert_error` to EVERY declared fn returning `Result<_, ZError>`, so
28+ // the generated wrapper's `onError` callback receives the error string as
29+ // its single `ze` param (after the fixed binding `je: String?`). No throw
30+ // from zenoh-flat-jni; the caller's `onError` decides (zenoh-java throws
31+ // `ZError`).
32+ . converter ( pq ! ( ZError ) , pq ! ( z_error_message) )
33+ . default ( )
34+ // `ZError` has no value-crossing of its own — but the rank-2
35+ // `Result<T, ZError>` resolver still requires an output converter for the
36+ // `E` position. Register the same `→ String` lowering so `Result` types
37+ // resolve; for fallible fns the error plan peels the `Result` in the
38+ // extern, so this converter is resolved-but-unused (the error reaches the
39+ // callback via `convert_error`). Harmless and semantically correct.
40+ . output_wrapper ( pq ! ( ZError ) , |_: & Registry < _ > | {
41+ Some ( ( pq ! ( String ) , None , pq ! ( zenoh_flat:: z_error_message( & v) ) ) )
42+ } )
43+ // Symmetric input side: required by the resolver's propagation through
44+ // the fallible constructors' `Result<_, ZError>` signatures, but **never
45+ // actually crossed** (no fn takes `ZError` from the JVM). A terminal that
46+ // ignores the wire and yields a dummy `ZError` satisfies resolution; it is
47+ // dead code (no extern param has `ZError` input).
48+ . input_wrapper ( pq ! ( ZError ) , |_: & Registry < _ > | {
49+ Some ( (
50+ pq ! ( ZError ) ,
51+ None ,
52+ pq ! ( <zenoh_flat:: ZError as :: core:: convert:: From <:: std:: string:: String >>:: from(
53+ :: std:: string:: String :: new( )
54+ ) ) ,
55+ ) )
56+ } )
2557 . package ( "keyexpr" )
2658 . ptr_class ( pq ! ( ZKeyExpr ) )
2759 . package_fun ( pq ! ( z_keyexpr_try_from) )
0 commit comments