From 1b88a636af0c7d85ed14a2395d65f813cb14f98c Mon Sep 17 00:00:00 2001 From: Wade Walker Date: Thu, 29 Dec 2011 15:14:41 -0600 Subject: [PATCH] Fix JAR cache to allow running from class files If the Platform class is coming from a .class file (instead of from a JAR), disables use of the temp JAR cache. This allows apps to run against JOGL class files as well as JAR files, which is useful when running from within an IDE like Eclipse. --- src/java/com/jogamp/common/os/Platform.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java index af795d13..55210ce8 100644 --- a/src/java/com/jogamp/common/os/Platform.java +++ b/src/java/com/jogamp/common/os/Platform.java @@ -204,7 +204,7 @@ public enum CPUType { os_and_arch = getOSAndArch(OS_TYPE, CPU_ARCH); - USE_TEMP_JAR_CACHE = OS_TYPE != OSType.ANDROID && + USE_TEMP_JAR_CACHE = (OS_TYPE != OSType.ANDROID) && !isRunningFromClassFile() && AccessController.doPrivileged(new PrivilegedAction() { public Boolean run() { return Boolean.valueOf(Debug.getBooleanProperty(true, useTempJarCachePropName, true, AccessController.getContext())); @@ -233,6 +233,22 @@ public Boolean run() { private Platform() {} + /* Used to disable JAR caching if we're not running from a JAR. + * + * If you build JOGL in an IDE like Eclipse, it's possible for other projects in your + * workspace to depend directly on the JOGL class files rather than on the built JAR files. + * This allows you to turn off JAR file creation in your JOGL Ant build to speed up the + * build, and allows Eclipse to resolve dependencies to auto-built class files before + * the Ant build even runs (which is not until after file save). + * + * @return true if we're running from a class file, false if we're running some other + * way (like from a JAR file). + */ + private static boolean isRunningFromClassFile() { + URL url = Platform.class.getResource( "Platform.class" ); + return( url.getProtocol().equalsIgnoreCase( "file" ) ); + } + private static boolean queryIsLittleEndianImpl() { ByteBuffer tst_b = Buffers.newDirectByteBuffer(Buffers.SIZEOF_INT); // 32bit in native order IntBuffer tst_i = tst_b.asIntBuffer();