You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "tisonkun (via GitHub)" <gi...@apache.org> on 2023/09/27 03:39:13 UTC

[GitHub] [incubator-opendal] tisonkun commented on a diff in pull request #3195: fix(binding/java): decode Java’s modified UTF-8 format

tisonkun commented on code in PR #3195:
URL: https://github.com/apache/incubator-opendal/pull/3195#discussion_r1338005971


##########
bindings/java/src/lib.rs:
##########
@@ -221,3 +221,8 @@ fn make_capability<'a>(env: &mut JNIEnv<'a>, cap: Capability) -> Result<JObject<
     )?;
     Ok(capability)
 }
+
+fn jstring_to_string(env: &mut JNIEnv, s: &JString) -> Result<String> {

Review Comment:
   This is unsafe of course. The safety assumption is:
   
   ```suggestion
   /// # Safety
   ///
   /// The caller must guarantee that the Object passed in is an instance
   /// of `java.lang.String`, passing in anything else will lead to undefined behavior.
   fn jstring_to_string(env: &mut JNIEnv, s: &JString) -> Result<String> {
   ```
   
   ... and we ensure that all JNI calls passing `String` as stated.



-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org