8318363: Foreign benchmarks fail to build on some platforms

Reviewed-by: jvernee, mcimadamore
This commit is contained in:
Aleksey Shipilev 2023-10-18 10:30:45 +00:00
parent 31ef400f31
commit 6fc3514231
2 changed files with 4 additions and 2 deletions

View File

@ -21,13 +21,14 @@
* questions.
*/
#include <jlong.h>
#include <jni.h>
#include <stdlib.h>
#include <string.h>
JNIEXPORT jlong JNICALL Java_org_openjdk_bench_java_lang_foreign_ToCStringTest_writeString(JNIEnv *const env, const jclass cls, const jstring text) {
const char *str = (*env)->GetStringUTFChars(env, text, NULL);
jlong addr = (jlong)(void*)str;
jlong addr = ptr_to_jlong(str);
(*env)->ReleaseStringUTFChars(env, text, str);
return addr;
}

View File

@ -23,10 +23,11 @@
* questions.
*/
#include <jlong.h>
#include <jni.h>
#include <stdlib.h>
#include <string.h>
JNIEXPORT jstring JNICALL Java_org_openjdk_bench_java_lang_foreign_ToJavaStringTest_readString(JNIEnv *const env, const jclass cls, jlong addr) {
return (*env)->NewStringUTF(env, (char*)(void*)addr);
return (*env)->NewStringUTF(env, jlong_to_ptr(addr));
}