Package com.kenai.jffi
Class Platform
java.lang.Object
com.kenai.jffi.Platform
- Direct Known Subclasses:
Platform.Darwin
,Platform.Default
,Platform.Windows
Convenience class to interrogate the system about various platform-specific details.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
static enum
The common names of cpu architectures.private static final class
APlatform
subclass representing the MacOS system.private static final class
static enum
The common names of operating systems.private static final class
Holds a single, lazily loaded instance ofPlatform
private static final class
APlatform
subclass representing the Windows system. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
private static final Locale
private final Platform.OS
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Platform
(Platform.OS os) Constructs a newPlatform
instance. -
Method Summary
Modifier and TypeMethodDescriptionfinal long
Gets the 32/64bit mask of a C address/pointer on the native platform.final int
Gets the size of a C address/pointer on the native platform.private static final Platform.OS
Determines the operating system jffi is running onprivate static final Platform
Determines thePlatform
that best describes theOS
final Platform.CPU
getCPU()
Gets the current processor architecture the JVM is running on.final int
Gets the version of the Java Virtual Machine (JVM) jffi is running on.Gets the regex string used to match platform-specific librariesgetName()
Gets the name of thisPlatform
.final Platform.OS
getOS()
Gets the current Operating System.static final Platform
Gets the currentPlatform
boolean
Checks if the current platform is supported by JFFI.abstract int
longSize()
Gets the size of a C 'long' on the native platform.mapLibraryName
(String libName) Maps from a generic library name (e.g.private static Platform
private static Platform
private static Platform
private static boolean
startsWithIgnoreCase
(String s1, String s2)
-
Field Details
-
LOCALE
-
os
-
javaVersionMajor
private final int javaVersionMajor
-
-
Constructor Details
-
Platform
Constructs a newPlatform
instance.- Parameters:
os
- The current operating system.
-
-
Method Details
-
determineOS
Determines the operating system jffi is running on- Returns:
- An member of the
OS
enum.
-
determinePlatform
Determines thePlatform
that best describes theOS
- Parameters:
os
- The operating system.- Returns:
- An instance of
Platform
-
newDarwinPlatform
-
newWindowsPlatform
-
newDefaultPlatform
-
getPlatform
Gets the currentPlatform
- Returns:
- The current platform.
-
getOS
Gets the current Operating System.- Returns:
- A
OS
value representing the current Operating System.
-
getCPU
Gets the current processor architecture the JVM is running on.- Returns:
- A
CPU
value representing the current processor architecture.
-
getJavaMajorVersion
public final int getJavaMajorVersion()Gets the version of the Java Virtual Machine (JVM) jffi is running on.- Returns:
- A number representing the java version. e.g. 5 for java 1.5, 6 for java 1.6
-
longSize
public abstract int longSize()Gets the size of a C 'long' on the native platform.- Returns:
- the size of a long in bits
-
addressSize
public final int addressSize()Gets the size of a C address/pointer on the native platform.- Returns:
- the size of a pointer in bits
-
addressMask
public final long addressMask()Gets the 32/64bit mask of a C address/pointer on the native platform.- Returns:
- the size of a pointer in bits
-
getName
Gets the name of thisPlatform
.- Returns:
- The name of this platform.
-
mapLibraryName
Maps from a generic library name (e.g. "c") to the platform specific library name.- Parameters:
libName
- The library name to map- Returns:
- The mapped library name.
-
getLibraryNamePattern
Gets the regex string used to match platform-specific libraries- Returns:
-
isSupported
public boolean isSupported()Checks if the current platform is supported by JFFI.- Returns:
true
if the platform is supported, else false.
-
startsWithIgnoreCase
-