summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-11-18 08:52:53 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2018-11-18 08:52:53 +0200
commit1760d9e810315afcc81946cd012b367d4e8d1b32 (patch)
tree9a7e9eff1102370cf83daf4f4028df6dc6ddfb13 /src
parent07600cce74f41fb59f3a523a2190f2e3f6b0236a (diff)
libjvm-java: implement java/lang/String/getBytes
Diffstat (limited to 'src')
-rw-r--r--src/libjvm-java.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libjvm-java.c b/src/libjvm-java.c
index c641124..b1d8cbd 100644
--- a/src/libjvm-java.c
+++ b/src/libjvm-java.c
@@ -125,6 +125,17 @@ java_lang_String_equals(JNIEnv *env, jobject object, va_list args)
return equal;
}
+jbyteArray
+java_lang_String_getBytes(JNIEnv *env, jobject object, va_list args)
+{
+ assert(env && object);
+ const char *utf = (*env)->GetStringUTFChars(env, object, NULL);
+ const size_t len = strlen(utf);
+ jbyteArray bytes = (*env)->NewByteArray(env, len);
+ (*env)->SetByteArrayRegion(env, bytes, 0, len, utf);
+ return bytes;
+}
+
jclass
java_lang_Class_forName(JNIEnv *env, jobject object, va_list args)
{