summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-01-19 03:57:52 +0100
committerSven Gothel <[email protected]>2013-01-19 03:57:52 +0100
commit039ff52d12f5dd750494fb2dea580946291bdb7e (patch)
tree120fedf7cc88637a087c51ae801d857c3ee82223
parent9bcec728aebc74c81cdd7c92aba5ac2706a7da19 (diff)
Modified Java 1.5 Buffers patch 2b7d1b1d25cb2cd73311ec9159b465f0391bf5e0 - May break GCJ/ECJ .. needs to be revised.
- Adding JAVA_6 in PlatformPropsImpl - Buffers.isDirect() chooses fast-path iff JAVA_6, otherwise using reflection (GCJ/ECJ) - Adding JAVA_6 info in VersionUtil - API doc: Refine JAVA_SE and JAVA_6 spec. TODO: In case GCJ etc is unable to compile the JAVA_6 code even though it uses a static condition (probably not), We have to wrap isStatic in an own class, one for JAVA_6 and one for <= 1.5. This will be a good exercise for further issues we may have w/ Java <= 1.5.
-rwxr-xr-xmake/scripts/runtest.sh2
-rwxr-xr-xsrc/java/com/jogamp/common/nio/Buffers.java46
-rw-r--r--src/java/com/jogamp/common/os/Platform.java15
-rw-r--r--src/java/com/jogamp/common/util/VersionUtil.java3
-rw-r--r--src/java/jogamp/common/os/PlatformPropsImpl.java20
5 files changed, 57 insertions, 29 deletions
diff --git a/make/scripts/runtest.sh b/make/scripts/runtest.sh
index 2f3942f..d01867f 100755
--- a/make/scripts/runtest.sh
+++ b/make/scripts/runtest.sh
@@ -67,7 +67,7 @@ function onetest() {
echo
}
-#onetest com.jogamp.common.GlueGenVersion 2>&1 | tee -a $LOG
+onetest com.jogamp.common.GlueGenVersion 2>&1 | tee -a $LOG
#onetest com.jogamp.common.util.TestSystemPropsAndEnvs 2>&1 | tee -a $LOG
#onetest com.jogamp.common.util.TestVersionInfo 2>&1 | tee -a $LOG
#onetest com.jogamp.common.util.TestVersionNumber 2>&1 | tee -a $LOG
diff --git a/src/java/com/jogamp/common/nio/Buffers.java b/src/java/com/jogamp/common/nio/Buffers.java
index 4a5255e..283cf07 100755
--- a/src/java/com/jogamp/common/nio/Buffers.java
+++ b/src/java/com/jogamp/common/nio/Buffers.java
@@ -41,6 +41,8 @@ package com.jogamp.common.nio;
import java.nio.*;
+import jogamp.common.os.PlatformPropsImpl;
+
import com.jogamp.common.util.ValueConv;
/**
@@ -359,25 +361,31 @@ public class Buffers {
if (buf == null) {
return true;
}
- if (buf instanceof ByteBuffer) {
- return ((ByteBuffer) buf).isDirect();
- } else if (buf instanceof IntBuffer) {
- return ((IntBuffer) buf).isDirect();
- } else if (buf instanceof ShortBuffer) {
- return ((ShortBuffer) buf).isDirect();
- } else if (buf instanceof FloatBuffer) {
- return ((FloatBuffer) buf).isDirect();
- } else if (buf instanceof DoubleBuffer) {
- return ((DoubleBuffer) buf).isDirect();
- } else if (buf instanceof LongBuffer) {
- return ((LongBuffer) buf).isDirect();
- } else if (buf instanceof CharBuffer) {
- return ((CharBuffer) buf).isDirect();
- } else if (buf instanceof PointerBuffer) {
- return ((PointerBuffer) buf).isDirect();
- } else if (buf instanceof Buffer) {
- throw new IllegalArgumentException("Unexpected buffer type Buffer.isDirect() operation is undefined");
- }
+ if ( PlatformPropsImpl.JAVA_6 ) {
+ if (buf instanceof Buffer) {
+ return ((Buffer) buf).isDirect();
+ } else if (buf instanceof PointerBuffer) {
+ return ((PointerBuffer) buf).isDirect();
+ }
+ } else {
+ if (buf instanceof ByteBuffer) {
+ return ((ByteBuffer) buf).isDirect();
+ } else if (buf instanceof IntBuffer) {
+ return ((IntBuffer) buf).isDirect();
+ } else if (buf instanceof ShortBuffer) {
+ return ((ShortBuffer) buf).isDirect();
+ } else if (buf instanceof FloatBuffer) {
+ return ((FloatBuffer) buf).isDirect();
+ } else if (buf instanceof DoubleBuffer) {
+ return ((DoubleBuffer) buf).isDirect();
+ } else if (buf instanceof LongBuffer) {
+ return ((LongBuffer) buf).isDirect();
+ } else if (buf instanceof CharBuffer) {
+ return ((CharBuffer) buf).isDirect();
+ } else if (buf instanceof PointerBuffer) {
+ return ((PointerBuffer) buf).isDirect();
+ }
+ }
throw new IllegalArgumentException("Unexpected buffer type " + buf.getClass().getName());
}
diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java
index 72a0b3d..e58e72c 100644
--- a/src/java/com/jogamp/common/os/Platform.java
+++ b/src/java/com/jogamp/common/os/Platform.java
@@ -257,13 +257,26 @@ public class Platform extends PlatformPropsImpl {
public static void initSingleton() { }
/**
- * Returns true only if this program is running on the Java Standard Edition.
+ * Returns true only if having {@link java.nio.LongBuffer} and {@link java.nio.DoubleBuffer} available.
*/
public static boolean isJavaSE() {
return JAVA_SE;
}
/**
+ * Returns true only if being compatible w/ language level 6, e.g. JRE 1.6.
+ * <p>
+ * Implies {@link #isJavaSE()}.
+ * </p>
+ * <p>
+ * <i>Note</i>: We claim Android is compatible.
+ * </p>
+ */
+ public static boolean isJava6() {
+ return JAVA_6;
+ }
+
+ /**
* Returns true if this machine is little endian, otherwise false.
*/
public static boolean isLittleEndian() {
diff --git a/src/java/com/jogamp/common/util/VersionUtil.java b/src/java/com/jogamp/common/util/VersionUtil.java
index e5491c7..22672b4 100644
--- a/src/java/com/jogamp/common/util/VersionUtil.java
+++ b/src/java/com/jogamp/common/util/VersionUtil.java
@@ -71,7 +71,8 @@ public class VersionUtil {
sb.append("Platform: Java Version: ").append(Platform.getJavaVersion()).append(", VM: ").append(Platform.getJavaVMName());
sb.append(", Runtime: ").append(Platform.getJavaRuntimeName()).append(Platform.getNewline());
sb.append("Platform: Java Vendor: ").append(Platform.getJavaVendor()).append(", ").append(Platform.getJavaVendorURL());
- sb.append(", is JavaSE: ").append(Platform.isJavaSE());
+ sb.append(", JavaSE: ").append(Platform.isJavaSE());
+ sb.append(", Java6: ").append(Platform.isJava6());
sb.append(", AWT enabled: ").append(Platform.AWT_AVAILABLE);
sb.append(Platform.getNewline()).append(SEPERATOR);
diff --git a/src/java/jogamp/common/os/PlatformPropsImpl.java b/src/java/jogamp/common/os/PlatformPropsImpl.java
index 3010a31..8a4f2b2 100644
--- a/src/java/jogamp/common/os/PlatformPropsImpl.java
+++ b/src/java/jogamp/common/os/PlatformPropsImpl.java
@@ -30,6 +30,9 @@ public abstract class PlatformPropsImpl {
// static initialization order:
//
+ /** Version 1.6. As a JVM version, it enables certain JVM 1. features. */
+ public static final VersionNumber Version16;
+
public static final String OS;
public static final String OS_lower;
public static final String OS_VERSION;
@@ -39,10 +42,13 @@ public abstract class PlatformPropsImpl {
public static final String JAVA_VENDOR;
public static final String JAVA_VENDOR_URL;
public static final String JAVA_VERSION;
- public static final VersionNumber JAVA_VERSION_NUMBER;
+ public static final VersionNumber JAVA_VERSION_NUMBER;
public static final String JAVA_VM_NAME;
public static final String JAVA_RUNTIME_NAME;
+ /** True if having {@link java.nio.LongBuffer} and {@link java.nio.DoubleBuffer} available. */
public static final boolean JAVA_SE;
+ /** True if being compatible w/ language level 6, e.g. JRE 1.6. Implies {@link #JAVA_SE}. <i>Note</i>: We claim Android is compatible. */
+ public static final boolean JAVA_6;
public static final String NEWLINE;
public static final boolean LITTLE_ENDIAN;
@@ -51,8 +57,9 @@ public abstract class PlatformPropsImpl {
public static final ABIType ABI_TYPE;
public static final OSType OS_TYPE;
public static final String os_and_arch;
-
+
static {
+ Version16 = new VersionNumber(1, 6, 0);
// We don't seem to need an AccessController.doPrivileged() block
// here as these system properties are visible even to unsigned Applets.
OS = System.getProperty("os.name");
@@ -68,6 +75,7 @@ public abstract class PlatformPropsImpl {
JAVA_VM_NAME = System.getProperty("java.vm.name");
JAVA_RUNTIME_NAME = getJavaRuntimeNameImpl();
JAVA_SE = initIsJavaSE();
+ JAVA_6 = JAVA_SE && ( AndroidVersion.isAvailable || JAVA_VERSION_NUMBER.compareTo(Version16) >= 0 ) ;
NEWLINE = System.getProperty("line.separator");
LITTLE_ENDIAN = queryIsLittleEndianImpl();
@@ -75,7 +83,7 @@ public abstract class PlatformPropsImpl {
CPU_ARCH = getCPUTypeImpl(ARCH_lower);
ABI_TYPE = guessABITypeImpl(CPU_ARCH);
OS_TYPE = getOSTypeImpl();
- os_and_arch = getOSAndArch(OS_TYPE, CPU_ARCH, ABI_TYPE);
+ os_and_arch = getOSAndArch(OS_TYPE, CPU_ARCH, ABI_TYPE);
}
protected PlatformPropsImpl() {}
@@ -90,10 +98,8 @@ public abstract class PlatformPropsImpl {
}
private static final boolean initIsJavaSE() {
- if(JAVA_RUNTIME_NAME!=null) {
- if(JAVA_RUNTIME_NAME.indexOf("Java SE") != -1) {
- return true;
- }
+ if( null != JAVA_RUNTIME_NAME && JAVA_RUNTIME_NAME.indexOf("Java SE") != -1) {
+ return true;
}
// probe for classes we need on a SE environment