ShadowySpirits commented on code in PR #2209:
URL:
https://github.com/apache/incubator-opendal/pull/2209#discussion_r1186660866
##########
bindings/java/src/macros.rs:
##########
Review Comment:
> To address this, we need to create a shim between the Rust and Java code.
For example:
> xxx_inner() -> Result<T, Error>
> xxx() -> T: This would call xxx_inner() and raise an exception.
Ok, I'll do this to make the code clearer.
```rust
// generated by macros call_from_java
let ret_value: Expr = syn::parse_str(
r#"match instance_to_return {
Ok(i) => {
i.java_object()
// i.as_java_ptr_with_local_ref(jni_env).unwrap()
},
Err(error) => {
let message = format!("{}", error);
let _ = jvm.throw_invocation_exception(&message);
ptr::null_mut()
},
}"#).unwrap();
ret_value
```
The `j4rs` way, to be honest, is exactly what I did.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]