summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/jogamp/common')
-rwxr-xr-xsrc/java/com/jogamp/common/os/DynamicLibraryBundle.java12
-rw-r--r--src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java11
-rw-r--r--src/java/com/jogamp/common/os/Platform.java17
-rw-r--r--src/java/com/jogamp/common/util/ReflectionUtil.java9
-rw-r--r--src/java/com/jogamp/common/util/RunnableExecutor.java4
-rw-r--r--src/java/com/jogamp/common/util/VersionUtil.java4
6 files changed, 52 insertions, 5 deletions
diff --git a/src/java/com/jogamp/common/os/DynamicLibraryBundle.java b/src/java/com/jogamp/common/os/DynamicLibraryBundle.java
index efb6d89..b86a701 100755
--- a/src/java/com/jogamp/common/os/DynamicLibraryBundle.java
+++ b/src/java/com/jogamp/common/os/DynamicLibraryBundle.java
@@ -33,7 +33,10 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
+import jogamp.common.awt.AWTEDTExecutor;
+
import com.jogamp.common.jvm.JNILibLoaderBase;
+import com.jogamp.common.util.RunnableExecutor;
/**
* Provides bundling of:<br>
@@ -69,6 +72,15 @@ public class DynamicLibraryBundle implements DynamicLookupHelper {
private HashSet<String> toolGetProcAddressFuncNameSet;
private List<String> toolGetProcAddressFuncNameList;
+ /** Returns an AWT-EDT {@link RunnableExecutor} implementation if AWT is available, otherwise {@link RunnableExecutor#currentThreadExecutor}. */
+ public static RunnableExecutor getDefaultRunnableExecutor() {
+ if(Platform.AWT_AVAILABLE) {
+ return AWTEDTExecutor.singleton;
+ } else {
+ return RunnableExecutor.currentThreadExecutor;
+ }
+ }
+
/** Instantiates and loads all {@link NativeLibrary}s incl. JNI libraries. */
public DynamicLibraryBundle(DynamicLibraryBundleInfo info) {
if(null==info) {
diff --git a/src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java b/src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java
index 6178048..8532548 100644
--- a/src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java
+++ b/src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java
@@ -86,6 +86,17 @@ public interface DynamicLibraryBundleInfo {
/** @return true if the dynamic symbol lookup shall happen system wide, over all loaded libraries. Otherwise only the loaded native libraries are used for lookup, which shall be the default. */
public boolean shallLookupGlobal();
+ /**
+ * Returns a suitable {@link RunnableExecutor} implementation, which is being used
+ * to load the <code>tool</code> native libraries.
+ * <p>
+ * This allows the generic {@link DynamicLibraryBundle} implementation to
+ * load the <code>tool</code> native libraries on a designated thread.
+ * </p>
+ * <p>
+ * An implementation may return {@link DynamicLibraryBundle#getDefaultRunnableExecutor()}.
+ * </p>
+ */
public RunnableExecutor getLibLoaderExecutor();
}
diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java
index dc1ce91..6553b07 100644
--- a/src/java/com/jogamp/common/os/Platform.java
+++ b/src/java/com/jogamp/common/os/Platform.java
@@ -38,6 +38,7 @@ import java.util.concurrent.TimeUnit;
import com.jogamp.common.nio.Buffers;
import com.jogamp.common.util.JarUtil;
+import com.jogamp.common.util.ReflectionUtil;
import com.jogamp.common.util.VersionNumber;
import com.jogamp.common.util.cache.TempJarCache;
@@ -61,6 +62,9 @@ public class Platform {
public static final boolean USE_TEMP_JAR_CACHE;
private static final String useTempJarCachePropName = "jogamp.gluegen.UseTempJarCache";
+ /** <code>true</code> if AWT is available and not in headless mode, otherwise <code>false</code>. */
+ public static final boolean AWT_AVAILABLE;
+
public static final boolean JAVA_SE;
public static final boolean LITTLE_ENDIAN;
public static final String OS;
@@ -225,6 +229,19 @@ public class Platform {
}
machineDescription = md;
is32Bit = machineDescription.is32Bit();
+
+ {
+ final ClassLoader cl = Platform.class.getClassLoader();
+ boolean _AWT_AVAILABLE = false;
+ if( !Debug.getBooleanProperty("java.awt.headless", true) &&
+ ReflectionUtil.isClassAvailable(ReflectionUtil.AWTNames.ComponentClass, cl) &&
+ ReflectionUtil.isClassAvailable(ReflectionUtil.AWTNames.GraphicsEnvironmentClass, cl) ) {
+ try {
+ _AWT_AVAILABLE = false == ((Boolean)ReflectionUtil.callStaticMethod(ReflectionUtil.AWTNames.GraphicsEnvironmentClass, ReflectionUtil.AWTNames.isHeadlessMethod, null, null, cl)).booleanValue();
+ } catch (Throwable t) { }
+ }
+ AWT_AVAILABLE = _AWT_AVAILABLE;
+ }
}
private Platform() {}
diff --git a/src/java/com/jogamp/common/util/ReflectionUtil.java b/src/java/com/jogamp/common/util/ReflectionUtil.java
index db98d6e..f6b9efb 100644
--- a/src/java/com/jogamp/common/util/ReflectionUtil.java
+++ b/src/java/com/jogamp/common/util/ReflectionUtil.java
@@ -46,6 +46,11 @@ public final class ReflectionUtil {
public static final boolean DEBUG = Debug.debug("ReflectionUtil");
+ public static class AWTNames {
+ public static final String ComponentClass = "java.awt.Component" ;
+ public static final String GraphicsEnvironmentClass = "java.awt.GraphicsEnvironment";
+ public static final String isHeadlessMethod = "isHeadless";
+ }
private static final Class<?>[] zeroTypes = new Class[0];
/**
@@ -261,11 +266,11 @@ public final class ReflectionUtil {
}
public static boolean isAWTComponent(Object target) {
- return instanceOf(target, "java.awt.Component");
+ return instanceOf(target, AWTNames.ComponentClass);
}
public static boolean isAWTComponent(Class<?> clazz) {
- return instanceOf(clazz, "java.awt.Component");
+ return instanceOf(clazz, AWTNames.ComponentClass);
}
/**
diff --git a/src/java/com/jogamp/common/util/RunnableExecutor.java b/src/java/com/jogamp/common/util/RunnableExecutor.java
index 7e6289b..7bf9685 100644
--- a/src/java/com/jogamp/common/util/RunnableExecutor.java
+++ b/src/java/com/jogamp/common/util/RunnableExecutor.java
@@ -28,8 +28,8 @@
package com.jogamp.common.util;
public interface RunnableExecutor {
- /** {@link RunnableExecutor} implementation simply invoking {@link Runnable#run()},
- * i.e. on the current thread at the time of calling {@link #invoke(boolean, Runnable)}.
+ /** This {@link RunnableExecutor} implementation simply invokes {@link Runnable#run()}
+ * on the current thread.
*/
public static final RunnableExecutor currentThreadExecutor = new CurrentThreadExecutor();
diff --git a/src/java/com/jogamp/common/util/VersionUtil.java b/src/java/com/jogamp/common/util/VersionUtil.java
index 30b23f2..4d2d0f2 100644
--- a/src/java/com/jogamp/common/util/VersionUtil.java
+++ b/src/java/com/jogamp/common/util/VersionUtil.java
@@ -69,7 +69,9 @@ public class VersionUtil {
// JVM/JRE
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()).append(", is JavaSE: ").append(Platform.isJavaSE());
+ sb.append("Platform: Java Vendor: ").append(Platform.getJavaVendor()).append(", ").append(Platform.getJavaVendorURL());
+ sb.append(", is JavaSE: ").append(Platform.isJavaSE());
+ sb.append(", AWT enabled: ").append(Platform.AWT_AVAILABLE);
sb.append(Platform.getNewline()).append(SEPERATOR);
return sb;