Class Platform
java.lang.Object
jnr.ffi.Platform
- Direct Known Subclasses:
Platform.Supported, Platform.Unsupported
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe supported CPU architectures.private static final classAPlatformsubclass representing the MacOS system.private static final class(package private) static final class(package private) static final classAPlatformsubclass representing the Linux operating system.static enumThe common names of supported operating systems.private static final classprivate static classprivate static classprivate static classAPlatformsubclass representing the Windows system. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intprivate final Platform.CPUprotected final Patternprivate static final Localeprivate final intprivate final Platform.OS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePlatform(Platform.OS os) Platform(Platform.OS os, Platform.CPU cpu, int addressSize, int longSize, String libPattern) -
Method Summary
Modifier and TypeMethodDescriptionfinal intDeprecated.private static intprivate static Platform.CPUprivate static Platform.OSDetermines the operating system jffi is running onprivate static Platformprivate static PlatformDetermines thePlatformthat best describes theOSprivate static booleanequalsIgnoreCase(String s1, String s2) final Platform.CPUgetCPU()Gets the current processor architecture the JVM is running on.getName()Gets the name of thisPlatform.static PlatformGets the nativePlatformfinal Platform.OSgetOS()Gets the current Operating System.final Stringstatic PlatformDeprecated.Returns the platform specific standard C library nameGets the version of this platform as specified by the system property "os.version"intGets the number representing the major version of this platform This uses the first number fromgetVersion()intGets the number representing the minor version of this platform This uses the second number fromgetVersion()final booleanis32Bit()final booleanis64Bit()final booleanReturns true if the current platform is big endianfinal booleanisBSD()final booleanReturns true if the current platform is little endianfinal booleanisUnix()libraryLocations(String libName, List<String> additionalPaths) Returns a list of absolute paths to the found locations of a library with the base namelibName, if the returned list is empty then the library could not be found and will fail to be loaded as a result.locateLibrary(String libName, List<String> libraryPath) Searches through a list of directories for a native library.locateLibrary(String libName, List<String> libraryPaths, Map<LibraryOption, Object> options) Searches through a list of directories for a native library.final intlongSize()Deprecated.UseRuntime.longSize()instead.mapLibraryName(String libName) Maps from a generic library name (e.g.private static booleanstartsWithIgnoreCase(String s1, String s2)
-
Field Details
-
LOCALE
-
os
-
cpu
-
addressSize
private final int addressSize -
longSize
private final int longSize -
libPattern
-
-
Constructor Details
-
Platform
-
Platform
-
-
Method Details
-
determineOS
Determines the operating system jffi is running on- Returns:
- An member of the
OSenum.
-
determinePlatform
Determines thePlatformthat best describes theOS- Parameters:
os- The operating system.- Returns:
- An instance of
Platform
-
determinePlatform
-
determineCPU
-
calculateAddressSize
-
getNativePlatform
-
getPlatform
Deprecated. -
getOS
Gets the current Operating System.- Returns:
- A
OSvalue representing the current Operating System.
-
getCPU
Gets the current processor architecture the JVM is running on.- Returns:
- A
CPUvalue representing the current processor architecture.
-
isBSD
public final boolean isBSD() -
isUnix
public final boolean isUnix() -
longSize
public final int longSize()Deprecated.UseRuntime.longSize()instead.Gets the size of a C 'long' on the native platform.- Returns:
- the size of a long in bits
-
addressSize
public final int addressSize()Deprecated.UseRuntime.addressSize()instead.Gets the size of a C address/pointer on the native platform.- Returns:
- the size of a pointer in bits
-
is32Bit
public final boolean is32Bit()- Returns:
- true if this platform is 32 bit, else false
Note: do not use this to determine long size, instead use
Runtime.longSize()
-
is64Bit
public final boolean is64Bit()- Returns:
- true if this platform is 64 bit, else false
Note: do not use this to determine long size, instead use
Runtime.longSize()
-
isLittleEndian
public final boolean isLittleEndian()Returns true if the current platform is little endian- Returns:
- true if little endian, false otherwise or if cannot determine
-
isBigEndian
public final boolean isBigEndian()Returns true if the current platform is big endian- Returns:
- true if big endian, false otherwise or if cannot determine
-
getOSName
- Returns:
- the String representing the OS name from the System property
os.nameor null if none was found This is not the same asgetOS()which returns thePlatform.OS. For example: Mac OS X is thePlatform.OS.DARWINPlatform.OSbut returns "Mac OS X" from this method
-
getName
-
getVersion
Gets the version of this platform as specified by the system property "os.version"- Returns:
- the String representing the version of this platform, or null if none could be found
-
getVersionNumbers
- Returns:
- the list of version numbers found from
getVersion()or an empty list if none were found
-
getVersionMajor
public int getVersionMajor()Gets the number representing the major version of this platform This uses the first number fromgetVersion()- Returns:
- the number representing the major version of this platform or -1 if none was found
-
getVersionMinor
public int getVersionMinor()Gets the number representing the minor version of this platform This uses the second number fromgetVersion()- Returns:
- the number representing the minor version of this platform or -1 if none was found
-
getStandardCLibraryName
Returns the platform specific standard C library name- Returns:
- The standard C library name
-
mapLibraryName
-
locateLibrary
-
locateLibrary
public String locateLibrary(String libName, List<String> libraryPaths, Map<LibraryOption, Object> options) Searches through a list of directories for a native library.- Parameters:
libName- the base name (e.g. "c") of the library to locatelibraryPaths- the list of directories to searchoptions- map ofLibraryOptions to customize search behavior such asLibraryOption.PreferCustomPaths- Returns:
- the path of the library
-
libraryLocations
Returns a list of absolute paths to the found locations of a library with the base namelibName, if the returned list is empty then the library could not be found and will fail to be loaded as a result. Even if a library is found, this does not guarantee that it will successfully be loaded, it only guarantees that the reason for the failure was not that it was not found.- Parameters:
libName- the base name (e.g. "c") of the library to locateadditionalPaths- additional paths to search, these take precedence over default paths, (as is the behavior inLibraryLoader) pass null to only search in the default paths- Returns:
- the list of absolute paths where the library was found
-
startsWithIgnoreCase
-
equalsIgnoreCase
-
Runtime.addressSize()instead.