Skip to content

Commit a3918af

Browse files
committed
test: passing env and JString
1 parent 1389f71 commit a3918af

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/test/java/toolbox/Main.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class Main {
1414
static native String concat(String a, String b);
1515
static native String[] to_vec(String a, String b, String c);
1616
static native boolean maybe(String optional);
17+
static native String raw();
1718

1819
@Test
1920
public void argumentsByValue() {
@@ -47,5 +48,10 @@ public void optional() {
4748
assertEquals(Main.maybe(null), false);
4849
assertEquals(Main.maybe("aa"), true);
4950
}
51+
52+
@Test
53+
public void passEnv() {
54+
assertEquals(Main.raw(), "hello world!");
55+
}
5056

5157
}

src/test/test.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@ fn to_vec(a: String, b: String, c: String) -> Vec<String> {
1919
fn maybe(idk: Option<String>) -> bool {
2020
idk.is_some()
2121
}
22+
23+
#[jni(package = "toolbox", class = "Main")]
24+
fn raw<'local>(env: &mut jni::JNIEnv<'local>) -> Result<jni::objects::JString<'local>, jni::errors::Error> {
25+
env.new_string("hello world!")
26+
}

0 commit comments

Comments
 (0)