From 2388b47f180989abd14a39188b1d4f80f221bdcf Mon Sep 17 00:00:00 2001
From: Michael Bien <mbien@fh-landshut.de>
Date: Wed, 1 Sep 2010 17:16:46 +0200
Subject: better exception message if libOpenCL could not be loaded.

---
 src/com/jogamp/opencl/CLPlatform.java       | 18 ++++++++++++++----
 src/com/jogamp/opencl/JOCLJNILibLoader.java |  5 +++--
 2 files changed, 17 insertions(+), 6 deletions(-)

(limited to 'src')

diff --git a/src/com/jogamp/opencl/CLPlatform.java b/src/com/jogamp/opencl/CLPlatform.java
index c12fbd47..70b27a0a 100644
--- a/src/com/jogamp/opencl/CLPlatform.java
+++ b/src/com/jogamp/opencl/CLPlatform.java
@@ -76,11 +76,14 @@ public final class CLPlatform {
             doPrivileged(new PrivilegedAction<Object>() {
                 public Object run() {
 
-                    NativeLibrary lib = JOCLJNILibLoader.loadJOCL();
+                    NativeLibrary libOpenCL = JOCLJNILibLoader.loadOpenCL();
+                    if(libOpenCL == null) {
+                        throw new JogampRuntimeException("OpenCL library not found.");
+                    }
 
-                    //eagerly init funciton to query extension addresses (used in reset())
-                    table.initEntry("clGetExtensionFunctionAddressImpl", lib);
-                    table.reset(lib);
+                    //eagerly init function to query extension addresses (used in reset())
+                    table.initEntry("clGetExtensionFunctionAddressImpl", libOpenCL);
+                    table.reset(libOpenCL);
                     return null;
                 }
             });
@@ -98,6 +101,13 @@ public final class CLPlatform {
         this.version = new CLVersion(getInfoString(CL_PLATFORM_VERSION));
     }
 
+    /**
+     * Eagerly initializes JOCL. Subsequent calls do nothing.
+     */
+    public static void initialize() throws JogampRuntimeException {
+        //see static initializer
+    }
+
     /**
      * Returns the default OpenCL platform or null when no platform found.
      */
diff --git a/src/com/jogamp/opencl/JOCLJNILibLoader.java b/src/com/jogamp/opencl/JOCLJNILibLoader.java
index 61436aa5..5e2eae37 100644
--- a/src/com/jogamp/opencl/JOCLJNILibLoader.java
+++ b/src/com/jogamp/opencl/JOCLJNILibLoader.java
@@ -12,9 +12,10 @@ class JOCLJNILibLoader extends JNILibLoaderBase {
 
     /**
      * Loads the native binding and returns the OpenCL library for dynamic linking.
+     * @return Returns libOpenCL represented as NativeLibrary.
      */
-    static NativeLibrary loadJOCL() {
-        loadLibrary("jocl", null, true);
+    static NativeLibrary loadOpenCL() {
+        loadLibrary("jocl", null, false);
         return NativeLibrary.open("OpenCL", JOCLJNILibLoader.class.getClassLoader());
     }
 }
-- 
cgit v1.2.3