Package jnr.ffi

Class Platform


  • public abstract class Platform
    extends java.lang.Object
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Platform.CPU
      The supported CPU architectures.
      static class  Platform.OS
      The common names of supported operating systems.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.regex.Pattern libPattern  
    • Constructor Summary

      Constructors 
      Constructor Description
      Platform​(Platform.OS os, Platform.CPU cpu, int addressSize, int longSize, java.lang.String libPattern)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      int addressSize()
      Deprecated.
      Platform.CPU getCPU()
      Gets the current processor architecture the JVM is running on.
      java.lang.String getName()
      Gets the name of this Platform.
      static Platform getNativePlatform()
      Gets the native Platform
      Platform.OS getOS()
      Gets the current Operating System.
      static Platform getPlatform()
      Deprecated.
      java.lang.String getStandardCLibraryName()
      Returns the platform specific standard C library name
      boolean isBigEndian()
      Returns true if the current platform is big endian
      boolean isBSD()  
      boolean isLittleEndian()
      Returns true if the current platform is little endian
      boolean isUnix()  
      java.util.List<java.lang.String> libraryLocations​(java.lang.String libName, java.util.List<java.lang.String> additionalPaths)
      Returns a list of absolute paths to the found locations of a library with the base name libName, if the returned list is empty then the library could not be found and will fail to be loaded as a result.
      java.lang.String locateLibrary​(java.lang.String libName, java.util.List<java.lang.String> libraryPath)
      Searches through a list of directories for a native library.
      java.lang.String locateLibrary​(java.lang.String libName, java.util.List<java.lang.String> libraryPaths, java.util.Map<LibraryOption,​java.lang.Object> options)
      Searches through a list of directories for a native library.
      int longSize()
      Deprecated.
      Use Runtime.longSize() instead.
      java.lang.String mapLibraryName​(java.lang.String libName)
      Maps from a generic library name (e.g.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • libPattern

        protected final java.util.regex.Pattern libPattern
    • Constructor Detail

      • Platform

        public Platform​(Platform.OS os,
                        Platform.CPU cpu,
                        int addressSize,
                        int longSize,
                        java.lang.String libPattern)
    • Method Detail

      • getNativePlatform

        public static Platform getNativePlatform()
        Gets the native Platform
        Returns:
        The current platform.
      • getPlatform

        @Deprecated
        public static Platform getPlatform()
        Deprecated.
      • getOS

        public final Platform.OS getOS()
        Gets the current Operating System.
        Returns:
        A OS value representing the current Operating System.
      • getCPU

        public final Platform.CPU getCPU()
        Gets the current processor architecture the JVM is running on.
        Returns:
        A CPU value representing the current processor architecture.
      • isBSD

        public final boolean isBSD()
      • isUnix

        public final boolean isUnix()
      • longSize

        public final int longSize()
        Deprecated.
        Use Runtime.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.
        Gets the size of a C address/pointer on the native platform.
        Returns:
        the size of a pointer in bits
      • 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
      • getName

        public java.lang.String getName()
        Gets the name of this Platform.
        Returns:
        The name of this platform.
      • getStandardCLibraryName

        public java.lang.String getStandardCLibraryName()
        Returns the platform specific standard C library name
        Returns:
        The standard C library name
      • mapLibraryName

        public java.lang.String mapLibraryName​(java.lang.String libName)
        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.
      • locateLibrary

        public java.lang.String locateLibrary​(java.lang.String libName,
                                              java.util.List<java.lang.String> libraryPath)
        Searches through a list of directories for a native library.
        Parameters:
        libName - the base name (e.g. "c") of the library to locate
        libraryPath - the list of directories to search
        Returns:
        the path of the library
      • locateLibrary

        public java.lang.String locateLibrary​(java.lang.String libName,
                                              java.util.List<java.lang.String> libraryPaths,
                                              java.util.Map<LibraryOption,​java.lang.Object> options)
        Searches through a list of directories for a native library.
        Parameters:
        libName - the base name (e.g. "c") of the library to locate
        libraryPaths - the list of directories to search
        options - map of LibraryOptions to customize search behavior such as LibraryOption.PreferCustomPaths
        Returns:
        the path of the library
      • libraryLocations

        public java.util.List<java.lang.String> libraryLocations​(java.lang.String libName,
                                                                 java.util.List<java.lang.String> additionalPaths)
        Returns a list of absolute paths to the found locations of a library with the base name libName, 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 locate
        additionalPaths - additional paths to search, these take precedence over default paths, (as is the behavior in LibraryLoader) pass null to only search in the default paths
        Returns:
        the list of absolute paths where the library was found