From c0ead6fa10280f8076704726d59f482b183fd77e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 2 Sep 2013 20:59:14 +0200 Subject: Fix Bug 810: Moved Julien Gouesse's fix to GlueGen to solve JOGL's optional module dependencies, added more API doc. --- .../com/jogamp/common/jvm/JNILibLoaderBase.java | 74 ++++++++++++++++++---- 1 file changed, 60 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java b/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java index 2023162..caa8702 100644 --- a/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java +++ b/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java @@ -207,6 +207,30 @@ public class JNILibLoaderBase { return false; } + /** + * Loads and adds a JAR file's native library to the TempJarCache, + * calling {@link JNILibLoaderBase#addNativeJarLibs(Class[], String, String[])} + * with default JOGL deployment configuration: + *
+        return JNILibLoaderBase.addNativeJarLibs(classesFromJavaJars, "-all", new String[] { "-noawt", "-mobile", "-core", "-android" } );
+   * 
+ * If Class1.class is contained in a JAR file which name includes singleJarMarker -all, + * implementation will attempt to resolve the native JAR file as follows: + * + * Otherwise the native JAR files will be resolved for each class's JAR file: + * + */ + public static final boolean addNativeJarLibsJoglCfg(final Class[] classesFromJavaJars) { + return addNativeJarLibs(classesFromJavaJars, "-all", joglDeployCfg); + } + private static final String[] joglDeployCfg = new String[] { "-noawt", "-mobile", "-core", "-android" }; + /** * Loads and adds a JAR file's native library to the TempJarCache.
* The native library JAR file's URI is derived as follows: @@ -223,37 +247,59 @@ public class JNILibLoaderBase { *
  • [3] is it's base URI
  • *
  • [4] is the derived native JAR filename
  • * - * - * Examples:
    - *
    + *

    + * Generic description: + *

    +       final ClassLoader cl = GLProfile.class.getClassLoader();
    +       final String newtFactoryClassName = "com.jogamp.newt.NewtFactory";
    +       final Class[] classesFromJavaJars = new Class[] { Class1.class, Class2.class };
    +       JNILibLoaderBase.addNativeJarLibs(classesFromJavaJars, "-all", new String[] { "-suff1", "-suff2" } );
    +   * 
    + * If Class1.class is contained in a JAR file which name includes singleJarMarker, here -all, + * implementation will attempt to resolve the native JAR file as follows: + * + * Otherwise the native JAR files will be resolved for each class's JAR file: + * + *

    + *

    + * Examples: + *

    + *

    * JOCL: *

    -        // only: jocl.jar -> jocl-natives-'os.and.arch'.jar
    +        // only: jocl.jar -> jocl-natives-os.and.arch.jar
             addNativeJarLibs(new Class[] { JOCLJNILibLoader.class }, null, null );
        * 
    * * Newt Only: *
    -       // either: [jogl-all.jar, jogl-all-noawt.jar, jogl-all-mobile.jar] -> jogl-all-natives-.jar
    -       // or:     nativewindow-core.jar                                   -> nativewindow-natives-.jar,
    -       //         newt-core.jar                                           -> newt-natives-.jar
    -       JNILibLoaderBase.addNativeJarLibs(new Class[] { NWJNILibLoader.class, NEWTJNILibLoader.class }, "-all", new String[] { "-noawt", "-mobile", "-core" } );
    +       // either: [jogl-all.jar, jogl-all-noawt.jar, jogl-all-mobile.jar, jogl-all-android.jar] -> jogl-all-natives-os.and.arch.jar
    +       // or:     nativewindow-core.jar                                                         -> nativewindow-natives-os.and.arch.jar,
    +       //         newt-core.jar                                                                 -> newt-natives-os.and.arch.jar
    +       JNILibLoaderBase.addNativeJarLibs(new Class[] { NWJNILibLoader.class, NEWTJNILibLoader.class }, "-all", new String[] { "-noawt", "-mobile", "-core", "-android" } );
        * 
    - * + *

    + *

    * JOGL: *

            final ClassLoader cl = GLProfile.class.getClassLoader();
    -       // either: [jogl-all.jar, jogl-all-noawt.jar, jogl-all-mobile.jar] -> jogl-all-natives-.jar
    -       // or:     nativewindow-core.jar                                   -> nativewindow-natives-.jar,
    -       //         jogl-core.jar                                           -> jogl-natives-.jar,
    -       //        (newt-core.jar                                           -> newt-natives-.jar)? (if available)
    +       // either: [jogl-all.jar, jogl-all-noawt.jar, jogl-all-mobile.jar, jogl-all-android.jar] -> jogl-all-natives-os.and.arch.jar
    +       // or:     nativewindow-core.jar                                                         -> nativewindow-natives-os.and.arch.jar,
    +       //         jogl-core.jar                                                                 -> jogl-natives-os.and.arch.jar,
    +       //        (newt-core.jar                                                                 -> newt-natives-os.and.arch.jar)? (if available)
            final String newtFactoryClassName = "com.jogamp.newt.NewtFactory";
            final Class[] classesFromJavaJars = new Class[] { NWJNILibLoader.class, GLProfile.class, null };
            if( ReflectionUtil.isClassAvailable(newtFactoryClassName, cl) ) {
                classesFromJavaJars[2] = ReflectionUtil.getClass(newtFactoryClassName, false, cl);
            }
    -       JNILibLoaderBase.addNativeJarLibs(classesFromJavaJars, "-all", new String[] { "-noawt", "-mobile", "-core" } );
    +       JNILibLoaderBase.addNativeJarLibs(classesFromJavaJars, "-all", new String[] { "-noawt", "-mobile", "-core", "-android" } );
        * 
    + *

    * * @param classesFromJavaJars For each given Class, load the native library JAR. * @param singleJarMarker Optional string marker like "-all" to identify the single 'all-in-one' JAR file -- cgit v1.2.3