Skip to content

Commit

Permalink
8318363: Foreign benchmarks fail to build on some platforms
Browse files Browse the repository at this point in the history
Reviewed-by: jvernee, mcimadamore
  • Loading branch information
shipilev committed Oct 18, 2023
1 parent 31ef400 commit 6fc3514
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

0 comments on commit 6fc3514

Please sign in to comment.