diff options
author | Jari Vetoniemi <mailroxas@gmail.com> | 2018-11-18 08:52:53 +0200 |
---|---|---|
committer | Jari Vetoniemi <mailroxas@gmail.com> | 2018-11-18 08:52:53 +0200 |
commit | 1760d9e810315afcc81946cd012b367d4e8d1b32 (patch) | |
tree | 9a7e9eff1102370cf83daf4f4028df6dc6ddfb13 /src | |
parent | 07600cce74f41fb59f3a523a2190f2e3f6b0236a (diff) |
libjvm-java: implement java/lang/String/getBytes
Diffstat (limited to 'src')
-rw-r--r-- | src/libjvm-java.c | 11 |
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) { |