diff --git a/com.oracle.truffle.r.native/fficall/src/jniboot/jniboot.c b/com.oracle.truffle.r.native/fficall/src/jniboot/jniboot.c index 09796b4e9c08a30ab76c04ae716c6ece2f9e8118..fb7783eb30615359e3632ba3c9ddc86300a9fad2 100644 --- a/com.oracle.truffle.r.native/fficall/src/jniboot/jniboot.c +++ b/com.oracle.truffle.r.native/fficall/src/jniboot/jniboot.c @@ -43,7 +43,7 @@ Java_com_oracle_truffle_r_runtime_ffi_jni_JNI_1DLL_native_1dlopen(JNIEnv *env, j if (handle == NULL) { char *err = dlerror(); initUnsatisfiedLinkError(env); -// (*env)->ReleaseStringUTFChars(env, jpath, path); + // N.B.throw doesn't happen until return, so path is released (*env)->ThrowNew(env, unsatisfiedLinkError, err); } (*env)->ReleaseStringUTFChars(env, jpath, path); @@ -58,7 +58,7 @@ Java_com_oracle_truffle_r_runtime_ffi_jni_JNI_1DLL_native_1dlsym(JNIEnv *env, jc char *err = dlerror(); if (err != NULL) { initUnsatisfiedLinkError(env); -// (*env)->ReleaseStringUTFChars(env, jsymbol, symbol); + // N.B.throw doesn't happen until return, so symbol is released (*env)->ThrowNew(env, unsatisfiedLinkError, err); } } diff --git a/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jni/JNI_Stats.java b/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jni/JNI_Stats.java index fc8d45174a5bc527b2e5e5ae734aaaedba3bdc3e..49ab14598462af4ad3aa27a9b847d5e78a8cc2ab 100644 --- a/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jni/JNI_Stats.java +++ b/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jni/JNI_Stats.java @@ -23,6 +23,7 @@ package com.oracle.truffle.r.runtime.ffi.jni; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.ffi.DLL; import com.oracle.truffle.r.runtime.ffi.DLL.DLLInfo; import com.oracle.truffle.r.runtime.ffi.DLL.SymbolHandle; @@ -33,21 +34,22 @@ import com.oracle.truffle.r.runtime.ffi.StatsRFFI; public class JNI_Stats implements StatsRFFI { public static class JNI_WorkNode extends WorkNode { + private static final String FFT_WORK = "fft_work"; @Child DLLRFFI.DLSymNode dlSymNode = RFFIFactory.getRFFI().getDLLRFFI().createDLSymNode(); - private SymbolHandle fftWorkAddress; @Override @TruffleBoundary public int execute(double[] a, int nseg, int n, int nspn, int isn, double[] work, int[] iwork) { if (fftWorkAddress == null) { - fftWorkAddress = fftAddress("fft_work", dlSymNode); + fftWorkAddress = fftAddress(FFT_WORK, dlSymNode); } return native_fft_work(fftWorkAddress.asAddress(), a, nseg, n, nspn, isn, work, iwork); } } public static class JNI_FactorNode extends FactorNode { + private static final String FFT_FACTOR = "fft_factor"; @Child DLLRFFI.DLSymNode dlSymNode = RFFIFactory.getRFFI().getDLLRFFI().createDLSymNode(); private SymbolHandle fftFactorAddress; @@ -55,7 +57,7 @@ public class JNI_Stats implements StatsRFFI { @TruffleBoundary public void execute(int n, int[] pmaxf, int[] pmaxp) { if (fftFactorAddress == null) { - fftFactorAddress = fftAddress("fft_factor", dlSymNode); + fftFactorAddress = fftAddress(FFT_FACTOR, dlSymNode); } native_fft_factor(fftFactorAddress.asAddress(), n, pmaxf, pmaxp); @@ -67,8 +69,11 @@ public class JNI_Stats implements StatsRFFI { SymbolHandle fftAddress; DLLInfo dllInfo = DLL.findLibrary("stats"); assert dllInfo != null; - fftAddress = dlSymNode.execute(dllInfo.handle, symbol); - assert fftAddress != DLL.SYMBOL_NOT_FOUND; + try { + fftAddress = dlSymNode.execute(dllInfo.handle, symbol); + } catch (UnsatisfiedLinkError ex) { + throw RInternalError.shouldNotReachHere(ex); + } return fftAddress; }