Skip to content

Commit 8aecafa

Browse files
committed
[GR-54756] Implement JVM_ArrayCopy on Darwin
PullRequest: graal/18273
2 parents 372721a + 26050ec commit 8aecafa

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationPrefs.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ private static void handlePreferencesClassReachable(@SuppressWarnings("unused")
9898
if (isDarwin()) {
9999
/* Darwin allocates a string array from native code */
100100
RuntimeJNIAccess.register(String[].class);
101+
/* Called by libprefs on Darwin */
102+
RuntimeJNIAccess.register(method(access, "java.lang.System", "arraycopy", Object.class, int.class, Object.class, int.class, int.class));
101103
}
102104
}
103105
}

substratevm/src/com.oracle.svm.native.jvm.posix/src/JvmFuncs.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,19 @@ JNIEXPORT jlong JNICALL Java_jdk_internal_misc_VM_getNanoTimeAdjustment(void *en
277277
return JVM_GetNanoTimeAdjustment(env, ignored, offset_secs);
278278
}
279279

280+
JNIEXPORT void JNICALL JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos, jobject dst, jint dst_pos, jint length) {
281+
jclass systemClass = (*env)->FindClass(env, "java/lang/System");
282+
if (systemClass != NULL && !(*env)->ExceptionCheck(env)) {
283+
jmethodID arraycopy = (*env)->GetStaticMethodID(env, systemClass, "arraycopy", "(Ljava/lang/Object;ILjava/lang/Object;II)V");
284+
if (arraycopy != NULL && !(*env)->ExceptionCheck(env)) {
285+
(*env)->CallStaticVoidMethod(env, systemClass, arraycopy, src, src_pos, dst, dst_pos, length);
286+
return;
287+
}
288+
}
289+
290+
(*env)->FatalError(env, "JVM_ArrayCopy called: Could not find System#arraycopy");
291+
}
292+
280293
JNIEXPORT void JNICALL JVM_Halt(int retcode) {
281294
exit(retcode);
282295
}

0 commit comments

Comments
 (0)