29package com.jogamp.common.os;
31import java.security.PrivilegedAction;
32import java.util.concurrent.TimeUnit;
34import com.jogamp.common.jvm.JNILibLoaderBase;
35import com.jogamp.common.net.Uri;
36import com.jogamp.common.util.JarUtil;
37import com.jogamp.common.util.PropertyAccess;
38import com.jogamp.common.util.ReflectionUtil;
39import com.jogamp.common.util.SecurityUtil;
40import com.jogamp.common.util.VersionNumber;
41import com.jogamp.common.util.cache.TempJarCache;
43import jogamp.common.jvm.JVMUtil;
44import jogamp.common.os.MachineDataInfoRuntime;
45import jogamp.common.os.PlatformPropsImpl;
58public class Platform extends PlatformPropsImpl {
61 LINUX, FREEBSD,
ANDROID, MACOS, SUNOS, HPUX, WINDOWS, OPENKODE, IOS;
137 if(
null == other ) {
139 }
else if( other ==
this ) {
142 return this.family == other.family &&
148 if(
null == cpuABILower ) {
149 throw new IllegalArgumentException(
"Null cpuABILower arg");
151 if( cpuABILower.equals(
"x86") ||
152 cpuABILower.equals(
"i386") ||
153 cpuABILower.equals(
"i486") ||
154 cpuABILower.equals(
"i586") ||
155 cpuABILower.equals(
"i686") ) {
157 }
else if( cpuABILower.equals(
"x86_64") ||
158 cpuABILower.equals(
"amd64") ) {
160 }
else if( cpuABILower.equals(
"ia64") ) {
162 }
else if( cpuABILower.equals(
"aarch64") ) {
164 }
else if( cpuABILower.startsWith(
"arm") ) {
165 if( cpuABILower.equals(
"armv8-a") ||
166 cpuABILower.equals(
"arm-v8-a") ||
167 cpuABILower.equals(
"arm-8-a") ||
168 cpuABILower.equals(
"arm64-v8a") ) {
170 }
else if( cpuABILower.startsWith(
"arm64") ) {
172 }
else if( cpuABILower.startsWith(
"armv7") ||
173 cpuABILower.startsWith(
"arm-v7") ||
174 cpuABILower.startsWith(
"arm-7") ||
175 cpuABILower.startsWith(
"armeabi-v7") ) {
177 }
else if( cpuABILower.startsWith(
"armv5") ||
178 cpuABILower.startsWith(
"arm-v5") ||
179 cpuABILower.startsWith(
"arm-5") ) {
181 }
else if( cpuABILower.startsWith(
"armv6") ||
182 cpuABILower.startsWith(
"arm-v6") ||
183 cpuABILower.startsWith(
"arm-6") ) {
188 }
else if( cpuABILower.equals(
"sparcv9") ) {
190 }
else if( cpuABILower.equals(
"sparc") ) {
192 }
else if( cpuABILower.equals(
"pa_risc2.0") ) {
194 }
else if( cpuABILower.startsWith(
"ppc64") ) {
196 }
else if( cpuABILower.startsWith(
"ppc") ) {
198 }
else if( cpuABILower.startsWith(
"mips64") ) {
200 }
else if( cpuABILower.startsWith(
"mips") ) {
202 }
else if( cpuABILower.startsWith(
"superh") ) {
205 throw new RuntimeException(
"Please port CPUType detection to your platform (CPU_ABI string '" + cpuABILower +
"')");
230 if(
null == other ) {
233 return other ==
this;
238 if(
null == cpuType ) {
239 throw new IllegalArgumentException(
"Null cpuType");
240 }
else if(
null == cpuABILower ) {
241 throw new IllegalArgumentException(
"Null cpuABILower");
245 }
else if( cpuABILower.equals(
"armeabi-v7a-hard") ) {
246 return EABI_GNU_ARMHF;
248 return EABI_GNU_ARMEL;
256 private static final String useTempJarCachePropName =
"jogamp.gluegen.UseTempJarCache";
262 private static final String libBaseName =
"gluegen_rt";
283 private static final boolean isRunningFromJarURL;
286 final boolean[] _isRunningFromJarURL =
new boolean[] {
false };
287 final boolean[] _USE_TEMP_JAR_CACHE =
new boolean[] {
false };
288 final boolean[] _AWT_AVAILABLE =
new boolean[] {
false };
292 public Object run() {
294 PlatformPropsImpl.initSingleton();
296 final ClassLoader cl =
Platform.class.getClassLoader();
298 final Uri platformClassJarURI;
300 Uri _platformClassJarURI =
null;
303 }
catch (
final Exception e) { }
304 platformClassJarURI = _platformClassJarURI;
306 _isRunningFromJarURL[0] =
null != platformClassJarURI;
308 _USE_TEMP_JAR_CACHE[0] = ( OS_TYPE != OSType.ANDROID ) && ( OS_TYPE !=
OSType.
IOS ) &&
309 (
null != platformClassJarURI ) &&
316 }
catch (
final Exception e0) {
318 System.err.println(
"Caught "+e0.getClass().getSimpleName()+
": "+e0.getMessage()+
", while JNILibLoaderBase.addNativeJarLibs(..)");
324 JVMUtil.initSingleton();
332 }
catch (
final Throwable t) { }
336 isRunningFromJarURL = _isRunningFromJarURL[0];
343 MachineDataInfoRuntime.initialize();
344 machineDescription = MachineDataInfoRuntime.getRuntime();
353 return isRunningFromJarURL;
365 return LITTLE_ENDIAN;
387 return OS_VERSION_NUMBER;
409 return CPU_ARCH.family;
424 return CPU_ARCH.is32Bit;
432 return !CPU_ARCH.is32Bit;
476 return JAVA_RUNTIME_NAME;
483 return JAVA_VENDOR_URL;
497 return JAVA_VERSION_NUMBER;
511 return machineDescription;
554 getCurrentSleepJitterImpl(TimeUnit.MILLISECONDS.toNanos(10), 10);
555 return getCurrentSleepJitterImpl(TimeUnit.MILLISECONDS.toNanos(10), 10);
557 private static long getCurrentSleepJitterImpl(
final long nsDuration,
final int splitInLoops) {
558 final long nsPeriod = nsDuration / splitInLoops;
560 for(
int i=splitInLoops; i>0; i--) {
561 try { TimeUnit.NANOSECONDS.sleep(nsPeriod); }
catch (
final InterruptedException e) { }
563 return ( ( Clock.currentNanos() - t0_ns ) - nsDuration ) / splitInLoops;
static synchronized void loadLibrary(final String libname, final String[] preload, final boolean preloadIgnoreError, final ClassLoader cl)
Loads the library specified by libname, using the LoaderAction set by setLoadingAction(LoaderAction).
static boolean addNativeJarLibs(final Class<?>[] classesFromJavaJars, final String singleJarMarker)
Loads and adds a JAR file's native library to the TempJarCache.
This class implements an immutable Uri as defined by RFC 2396.
static native long currentNanos()
Returns current monotonic nanoseconds since start of this application.
static native long currentTimeMillis()
Returns the unix based current monotonic time in milliseconds.
static native long currentMillis()
Returns current monotonic milliseconds since start of this application.
Machine data description for alignment and size onle, see com.jogamp.gluegen.
static Uri getJarUri(final String clazzBinName, final ClassLoader cl)
The Class's "com.jogamp.common.GlueGenVersion" Uri jar:sub_protocol:/some/path/gluegen-rt....
Helper routines for accessing properties.
static final boolean getBooleanProperty(final String property, final boolean jnlpAlias)
static final String ComponentClass
static final String isHeadlessMethod
static final String GraphicsEnvironmentClass
static final Object callStaticMethod(final String clazzName, final String methodName, final Class<?>[] argTypes, final Object[] args, final ClassLoader cl)
static final boolean isClassAvailable(final String clazzName, final ClassLoader cl)
Returns true only if the class could be loaded.
static< T > T doPrivileged(final PrivilegedAction< T > o)
Call wrapper for java.security.AccessController#doPrivileged(PrivilegedAction).
Simple version number class containing a version number either being defined explicit or derived from...
Static Jar file cache handler using an underlying instance of TempFileCache, see getTempFileCache().
static boolean isInitialized(final boolean forExecutables)
static boolean initSingleton()
Documented way to kick off static initialization.