summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/os
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/jogamp/common/os
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/jogamp/common/os')
-rwxr-xr-xsrc/java/com/jogamp/common/os/NativeLibrary.java3
-rw-r--r--src/java/com/jogamp/common/os/Platform.java59
2 files changed, 40 insertions, 22 deletions
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.
*/