From 346cefbed4b181105c1c76e1328dade03decc825 Mon Sep 17 00:00:00 2001 From: Lukas Stadler <lukas.stadler@oracle.com> Date: Fri, 23 Mar 2018 09:06:23 +0100 Subject: [PATCH] more debug info for embedding --- .../fficall/src/truffle_nfi/Rembedded.c | 15 +++++++++------ com.oracle.truffle.r.test.native/embedded/test.sh | 5 +++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Rembedded.c b/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Rembedded.c index 770deeca72..945eba892a 100644 --- a/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Rembedded.c +++ b/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Rembedded.c @@ -60,7 +60,7 @@ static void setupOverrides(void); static void *dlopen_jvmlib(char *libpath); static JNIEnv* getEnv(); static jmethodID checkGetMethodID(JNIEnv *env, jclass klass, const char *name, const char *sig, int isStatic); -static jclass checkFindClass(JNIEnv *env, const char *name); +static jclass checkFindClass(JNIEnv *env, const char *name, const char* vm_cp); static int process_vmargs(int argc, char *argv[], char *vmargv[], char *uargv[]); static char **update_environ_with_java_home(void); static void print_environ(char **env); @@ -224,9 +224,9 @@ static int initializeFastR(int argc, char *argv[], int setupRmainloop) { return 1; } - rInterfaceCallbacksClass = checkFindClass(jniEnv, "com/oracle/truffle/r/runtime/RInterfaceCallbacks"); - rembeddedClass = checkFindClass(jniEnv, "com/oracle/truffle/r/engine/shell/REmbedded"); - jclass stringClass = checkFindClass(jniEnv, "java/lang/String"); + rInterfaceCallbacksClass = checkFindClass(jniEnv, "com/oracle/truffle/r/runtime/RInterfaceCallbacks", vm_cp); + rembeddedClass = checkFindClass(jniEnv, "com/oracle/truffle/r/engine/shell/REmbedded", vm_cp); + jclass stringClass = checkFindClass(jniEnv, "java/lang/String", vm_cp); jmethodID initializeMethod = checkGetMethodID(jniEnv, rembeddedClass, "initializeR", "([Ljava/lang/String;Z)V", 1); jobjectArray argsArray = (*jniEnv)->NewObjectArray(jniEnv, argc, stringClass, NULL); for (int i = 0; i < argc; i++) { @@ -578,13 +578,16 @@ static jmethodID checkGetMethodID(JNIEnv *env, jclass klass, const char *name, c return methodID; } -static jclass checkFindClass(JNIEnv *env, const char *name) { +static jclass checkFindClass(JNIEnv *env, const char *name, const char* vm_cp) { jclass klass = (*env)->FindClass(env, name); if (klass == NULL) { - char buf[1024]; + char buf[16384]; strcpy(buf, "failed to find class "); strcat(buf, name); + strcat(buf, " in classpath "); + strcat(buf, vm_cp); strcat(buf, ".\nDid you set R_HOME to the correct location?"); + (*env)->ExceptionDescribe(env); (*env)->FatalError(env, buf); } return (*env)->NewGlobalRef(env, klass); diff --git a/com.oracle.truffle.r.test.native/embedded/test.sh b/com.oracle.truffle.r.test.native/embedded/test.sh index 38f05584f4..8dc334a042 100755 --- a/com.oracle.truffle.r.test.native/embedded/test.sh +++ b/com.oracle.truffle.r.test.native/embedded/test.sh @@ -40,6 +40,11 @@ dir="$( cd -P "$( dirname "$source" )" && pwd )" : ${R_HOME?"R_HOME must point to FastR directory"} : ${NFI_LIB?"NFI_LIB must point to libtrufflenfi.so located in mxbuild directory of Truffle"} +echo "R_HOME: $R_HOME" +echo "NFI_LIB: $NFI_LIB" +echo "Rclasspath: " +$dir/../../bin/execRextras/Rclasspath + echo "Testing 'main' embedding example..." (cd $dir/bin; ./main -Dtruffle.nfi.library=$NFI_LIB --vanilla < $dir/src/main.input > $dir/main.actual.output 2>&1) if ! diff -q $dir/main.actual.output $dir/src/main.expected.output > /dev/null 2>&1; then -- GitLab