aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-09-22 01:40:28 +0200
committerSven Gothel <[email protected]>2011-09-22 01:40:28 +0200
commita258a199da9ba1351d946ad0379c54e8481e931b (patch)
tree496adeadfae80962d5201bd6f22231d985894f1a /src/java/com
parent0a45d6ca9b9a8d92b5e4c147be94fad8de344816 (diff)
gluegen-rt lib loading: Moved to Platform static init incl. TempJarCache.bootstrapNativeLib(..) usage
- Moving to Platform solves former interdependencies between GlueGenJNILibLoader/Platform - TempJarCache is being setup w/ bootstraping the gluegen-rt native lib jar file. Interesting here is that when using Oracle's JRE w/ Applets/JNLP the current dbg output is: gluegen-rt: url-root http://risa/deployment/test/jau02s/jar/ gluegen-rt: nativeJarURL jar:http://risa/deployment/test/jau02s/jar/gluegen-rt-natives-linux-amd64.jar!/ gluegen-rt: nativeJar /home/sven/.java/deployment/cache/6.0/49/3c6d1e31-2c90f42e IE the JRE implementation already deduces the online link to the Applet/JNLP cache. This makes the implementation much simpler, ie. same for application and Applets/JNLP. Have to verify w/ other Java impl. sure - and add same logic for the JOGL part.
Diffstat (limited to 'src/java/com')
-rw-r--r--src/java/com/jogamp/common/jvm/JVMUtil.java5
-rw-r--r--src/java/com/jogamp/common/nio/AbstractBuffer.java4
-rw-r--r--src/java/com/jogamp/common/nio/PointerBuffer.java4
-rwxr-xr-xsrc/java/com/jogamp/common/os/NativeLibrary.java3
-rw-r--r--src/java/com/jogamp/common/os/Platform.java59
-rwxr-xr-xsrc/java/com/jogamp/gluegen/runtime/GlueGenJNILibLoader.java62
6 files changed, 44 insertions, 93 deletions
diff --git a/src/java/com/jogamp/common/jvm/JVMUtil.java b/src/java/com/jogamp/common/jvm/JVMUtil.java
index 9ad9baf..29c5f57 100644
--- a/src/java/com/jogamp/common/jvm/JVMUtil.java
+++ b/src/java/com/jogamp/common/jvm/JVMUtil.java
@@ -34,10 +34,9 @@ package com.jogamp.common.jvm;
import java.nio.ByteBuffer;
import com.jogamp.common.nio.Buffers;
-import com.jogamp.common.os.NativeLibrary;
+import com.jogamp.common.os.Platform;
import jogamp.common.Debug;
-import com.jogamp.gluegen.runtime.GlueGenJNILibLoader;
/**
* Currently this tool works around the Hotspot race condition bugs:
@@ -54,7 +53,7 @@ public class JVMUtil {
private static final boolean DEBUG = Debug.debug("JVMUtil");
static {
- GlueGenJNILibLoader.loadGlueGenRT();
+ Platform.initSingleton(); // loads native gluegen-rt library
ByteBuffer buffer = Buffers.newDirectByteBuffer(64);
if( ! initialize(buffer) ) {
diff --git a/src/java/com/jogamp/common/nio/AbstractBuffer.java b/src/java/com/jogamp/common/nio/AbstractBuffer.java
index 90e31f8..322a617 100644
--- a/src/java/com/jogamp/common/nio/AbstractBuffer.java
+++ b/src/java/com/jogamp/common/nio/AbstractBuffer.java
@@ -32,10 +32,8 @@
package com.jogamp.common.nio;
import com.jogamp.common.os.*;
-import com.jogamp.gluegen.runtime.GlueGenJNILibLoader;
import java.nio.Buffer;
-import java.nio.ByteBuffer;
/**
* @author Sven Gothel
@@ -49,7 +47,7 @@ public abstract class AbstractBuffer<B extends AbstractBuffer> implements Native
protected int position;
static {
- GlueGenJNILibLoader.loadGlueGenRT();
+ Platform.initSingleton(); // loads native gluegen-rt library
}
/**
diff --git a/src/java/com/jogamp/common/nio/PointerBuffer.java b/src/java/com/jogamp/common/nio/PointerBuffer.java
index d2691d9..f05c6ad 100644
--- a/src/java/com/jogamp/common/nio/PointerBuffer.java
+++ b/src/java/com/jogamp/common/nio/PointerBuffer.java
@@ -36,10 +36,8 @@ import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.nio.LongBuffer;
-import com.jogamp.common.os.NativeLibrary;
import com.jogamp.common.os.Platform;
import com.jogamp.common.util.LongObjectHashMap;
-import com.jogamp.gluegen.runtime.GlueGenJNILibLoader;
/**
* Hardware independent container for native pointer arrays.
@@ -55,7 +53,7 @@ public class PointerBuffer extends AbstractBuffer<PointerBuffer> {
protected LongObjectHashMap dataMap = null;
static {
- GlueGenJNILibLoader.loadGlueGenRT();
+ Platform.initSingleton(); // loads native gluegen-rt library
}
/** no backup array, use for direct usage only */
diff --git a/src/java/com/jogamp/common/os/NativeLibrary.java b/src/java/com/jogamp/common/os/NativeLibrary.java
index c8dfdf1..0c2e5f2 100755
--- a/src/java/com/jogamp/common/os/NativeLibrary.java
+++ b/src/java/com/jogamp/common/os/NativeLibrary.java
@@ -41,7 +41,6 @@
package com.jogamp.common.os;
import com.jogamp.common.util.IOUtil;
-import com.jogamp.gluegen.runtime.GlueGenJNILibLoader;
import jogamp.common.Debug;
import jogamp.common.os.MacOSXDynamicLinkerImpl;
import jogamp.common.os.UnixDynamicLinkerImpl;
@@ -175,7 +174,7 @@ public class NativeLibrary implements DynamicLookupHelper {
if (DEBUG) {
System.err.println("Trying to load " + path);
}
- GlueGenJNILibLoader.loadGlueGenRT();
+ Platform.initSingleton(); // loads native gluegen-rt library
long res;
if(global) {
res = dynLink.openLibraryGlobal(path, DEBUG);
diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java
index 78daf4c..3627513 100644
--- a/src/java/com/jogamp/common/os/Platform.java
+++ b/src/java/com/jogamp/common/os/Platform.java
@@ -28,13 +28,18 @@
package com.jogamp.common.os;
+import java.io.IOException;
+import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.util.jar.JarFile;
import com.jogamp.common.nio.Buffers;
+import com.jogamp.common.util.JarUtil;
+import com.jogamp.common.util.cache.TempJarCache;
import jogamp.common.os.MachineDescriptionRuntime;
@@ -184,6 +189,8 @@ public class Platform {
os_and_arch = getOSAndArch(OS_TYPE, CPU_ARCH);
+ loadGlueGenRTImpl();
+
MachineDescription md = MachineDescriptionRuntime.getRuntime();
if(null == md) {
MachineDescription.StaticConfig smd = MachineDescriptionRuntime.getStatic();
@@ -211,26 +218,6 @@ public class Platform {
return 0x0C0D == tst_s.get(0);
}
- public static boolean isCPUArch32Bit() throws RuntimeException {
- switch( CPU_ARCH ) {
- case X86_32:
- case ARM:
- case ARMv5:
- case ARMv6:
- case ARMv7:
- case SPARC_32:
- case PPC:
- return true;
- case X86_64:
- case IA64:
- case SPARCV9_64:
- case PA_RISC2_0:
- return false;
- default:
- throw new RuntimeException("Please port CPU detection (32/64 bit) to your platform (" + Platform.OS_lower + "/" + Platform.ARCH_lower + "("+Platform.CPU_ARCH+"))");
- }
- }
-
private static OSType getOSTypeImpl() throws RuntimeException {
if ( AndroidVersion.isAvailable ) {
return OSType.ANDROID;
@@ -289,6 +276,38 @@ public class Platform {
return false;
}
+ private static void loadGlueGenRTImpl() {
+ final String nativeJarName = "gluegen-rt-natives-"+os_and_arch+".jar";
+ final String libBaseName = "gluegen-rt";
+ final ClassLoader cl = Platform.class.getClassLoader();
+
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ if(TempJarCache.initSingleton()) {
+ try {
+ URL jarUrlRoot = JarUtil.getJarURLDirname(
+ JarUtil.getJarURL(Platform.class.getName(), cl) );
+ System.err.println("gluegen-rt: url-root "+jarUrlRoot);
+ URL nativeJarURL = JarUtil.getJarURL(jarUrlRoot, nativeJarName);
+ System.err.println("gluegen-rt: nativeJarURL "+nativeJarURL);
+ JarFile nativeJar = JarUtil.getJarFile(nativeJarURL, cl);
+ System.err.println("gluegen-rt: nativeJar "+nativeJar.getName());
+ TempJarCache.bootstrapNativeLib(libBaseName, nativeJar);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+ }
+ DynamicLibraryBundle.GlueJNILibLoader.loadLibrary(libBaseName, false);
+ return null;
+ }
+ });
+ }
+
+ /**
+ * kick off static initialization incl native gluegen-rt lib loading
+ */
+ public static void initSingleton() { }
+
/**
* Returns true only if this program is running on the Java Standard Edition.
*/
diff --git a/src/java/com/jogamp/gluegen/runtime/GlueGenJNILibLoader.java b/src/java/com/jogamp/gluegen/runtime/GlueGenJNILibLoader.java
deleted file mode 100755
index 4f281df..0000000
--- a/src/java/com/jogamp/gluegen/runtime/GlueGenJNILibLoader.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2011 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.gluegen.runtime;
-
-import java.security.*;
-
-import com.jogamp.common.jvm.JNILibLoaderBase;
-
-/** Class providing control over whether GlueGen loads the native code
- associated with the NativeLibrary implementation. Alternative app
- launchers such as those running within applets may want to disable
- this default loading behavior and load the native code via another
- (manual) mechanism. */
-public class GlueGenJNILibLoader extends JNILibLoaderBase {
-
- public static void loadGlueGenRT() {
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- public Object run() {
- loadLibrary("gluegen-rt", false);
- return null;
- }
- });
- }
-}