true
if AWT is available and not in headless mode, otherwise false
. */
public static final boolean AWT_AVAILABLE;
public static final boolean JAVA_SE;
public static final boolean LITTLE_ENDIAN;
public static final String OS;
public static final String OS_lower;
public static final String OS_VERSION;
public static final VersionNumber OS_VERSION_NUMBER;
public static final String ARCH;
public static final String ARCH_lower;
public static final String JAVA_VENDOR;
public static final String JAVA_VENDOR_URL;
public static final String JAVA_VM_NAME;
public static final String JAVA_RUNTIME_NAME;
public static final String JAVA_VERSION;
public static final VersionNumber JAVA_VERSION_NUMBER;
public static final String NEWLINE;
public enum OSType {
LINUX(0), FREEBSD(1), ANDROID(2), MACOS(3), SUNOS(4), HPUX(5), WINDOWS(6), OPENKODE(7);
public final int id;
OSType(int id){
this.id = id;
}
}
public static final OSType OS_TYPE;
public enum CPUFamily {
/** AMD/Intel */
X86( 0x00000000),
/** ARM */
ARM( 0x00010000),
/** Power PC */
PPC( 0x00020000),
/** SPARC */
SPARC( 0x00030000),
/** PA RISC */
PA_RISC(0xFFFF0000),
/** Itanium */
IA64( 0xFFFF1000);
public final int id;
CPUFamily(int id){
this.id = id;
}
}
public enum CPUType {
/** X86 32bit */
X86_32( CPUFamily.X86, 0x0001),
/** X86 64bit */
X86_64( CPUFamily.X86, 0x0002),
/** ARM default */
ARM( CPUFamily.ARM, 0x0000),
/** ARM7EJ, ARM9E, ARM10E, XScale */
ARMv5( CPUFamily.ARM, 0x0001),
/** ARM11 */
ARMv6( CPUFamily.ARM, 0x0002),
/** ARM Cortex */
ARMv7( CPUFamily.ARM, 0x0004),
/** PPC default */
PPC( CPUFamily.PPC, 0x0000),
/** SPARC 32bit */
SPARC_32( CPUFamily.SPARC, 0x0001),
/** SPARC 64bit */
SPARCV9_64(CPUFamily.SPARC, 0x0002),
/** Itanium default */
IA64( CPUFamily.IA64, 0x0000),
/** PA_RISC2_0 */
PA_RISC2_0(CPUFamily.PA_RISC, 0x0001);
public final int id;
public final CPUFamily family;
CPUType(CPUFamily type, int id){
this.family = type;
this.id = id;
}
public CPUFamily getFamily() { return family; }
}
public static final CPUType CPU_ARCH;
public enum ABIType {
GENERIC_ABI ( 0x0000 ),
/** ARM GNU-EABI ARMEL -mfloat-abi=softfp */
EABI_GNU_ARMEL ( 0x0001 ),
/** ARM GNU-EABI ARMHF -mfloat-abi=hard */
EABI_GNU_ARMHF ( 0x0002 );
public final int id;
ABIType(int id){
this.id = id;
}
}
public static final ABIType ABI_TYPE;
private static final boolean is32Bit;
private static final MachineDescription machineDescription;
private static final String os_and_arch;
static {
// 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");
OS_lower = OS.toLowerCase();
OS_VERSION = System.getProperty("os.version");
OS_VERSION_NUMBER = new VersionNumber(OS_VERSION, ".");
ARCH = System.getProperty("os.arch");
ARCH_lower = ARCH.toLowerCase();
JAVA_VENDOR = System.getProperty("java.vendor");
JAVA_VENDOR_URL = System.getProperty("java.vendor.url");
JAVA_VERSION = System.getProperty("java.version");
JAVA_VERSION_NUMBER = new VersionNumber(JAVA_VERSION, ".");
NEWLINE = System.getProperty("line.separator");
JAVA_VM_NAME = System.getProperty("java.vm.name");
JAVA_RUNTIME_NAME = getJavaRuntimeNameImpl();
JAVA_SE = initIsJavaSE();
LITTLE_ENDIAN = queryIsLittleEndianImpl();
CPU_ARCH = getCPUTypeImpl(ARCH_lower);
ABI_TYPE = guessABITypeImpl(CPU_ARCH);
OS_TYPE = getOSTypeImpl();
os_and_arch = getOSAndArch(OS_TYPE, CPU_ARCH, ABI_TYPE);
USE_TEMP_JAR_CACHE = (OS_TYPE != OSType.ANDROID) && isRunningFromJarURL() &&
Debug.getBooleanProperty(useTempJarCachePropName, true, true);
loadGlueGenRTImpl();
JVMUtil.initSingleton(); // requires gluegen-rt, one-time init.
MachineDescription md = MachineDescriptionRuntime.getRuntime();
if(null == md) {
MachineDescription.StaticConfig smd = MachineDescriptionRuntime.getStatic();
md = smd.md;
System.err.println("Warning: Using static MachineDescription: "+smd);
} else {
MachineDescription.StaticConfig smd = MachineDescriptionRuntime.getStatic();
if(!md.compatible(smd.md)) {
throw new RuntimeException("Incompatible MachineDescriptions:"+Platform.NEWLINE+
" Static "+smd+Platform.NEWLINE+
" Runtime "+md);
}
}
machineDescription = md;
is32Bit = machineDescription.is32Bit();
{
final ClassLoader cl = Platform.class.getClassLoader();
AWT_AVAILABLE = AccessController.doPrivileged(new PrivilegedAction* Impact: Less overhead and more robustness. *
* * @return true if we're running from a Jar URL, otherwise false */ private static boolean isRunningFromJarURL() { return JarUtil.hasJarURL(Platform.class.getName(), Platform.class.getClassLoader()); } private static boolean queryIsLittleEndianImpl() { ByteBuffer tst_b = Buffers.newDirectByteBuffer(Buffers.SIZEOF_INT); // 32bit in native order IntBuffer tst_i = tst_b.asIntBuffer(); ShortBuffer tst_s = tst_b.asShortBuffer(); tst_i.put(0, 0x0A0B0C0D); return 0x0C0D == tst_s.get(0); } private static CPUType getCPUTypeImpl(String archLower) { if( archLower.equals("x86") || archLower.equals("i386") || archLower.equals("i486") || archLower.equals("i586") || archLower.equals("i686") ) { return CPUType.X86_32; } else if( archLower.equals("x86_64") || archLower.equals("amd64") ) { return CPUType.X86_64; } else if( archLower.equals("ia64") ) { return CPUType.IA64; } else if( archLower.equals("arm") ) { return CPUType.ARM; } else if( archLower.equals("armv5l") ) { return CPUType.ARMv5; } else if( archLower.equals("armv6l") ) { return CPUType.ARMv6; } else if( archLower.equals("armv7l") ) { return CPUType.ARMv7; } else if( archLower.equals("sparc") ) { return CPUType.SPARC_32; } else if( archLower.equals("sparcv9") ) { return CPUType.SPARCV9_64; } else if( archLower.equals("pa_risc2.0") ) { return CPUType.PA_RISC2_0; } else if( archLower.equals("ppc") ) { return CPUType.PPC; } else { throw new RuntimeException("Please port CPU detection to your platform (" + OS_lower + "/" + archLower + ")"); } } private static boolean contains(String data, String[] search) { if(null != data && null != search) { for(int i=0; i