Class Platform

java.lang.Object
com.kenai.jffi.Platform
Direct Known Subclasses:
Platform.Darwin, Platform.Default, Platform.Windows

public abstract class Platform extends Object
Convenience class to interrogate the system about various platform-specific details.
  • Field Details

    • LOCALE

      private static final Locale LOCALE
    • os

      private final Platform.OS os
    • javaVersionMajor

      private final int javaVersionMajor
  • Constructor Details

    • Platform

      private Platform(Platform.OS os)
      Constructs a new Platform instance.
      Parameters:
      os - The current operating system.
  • Method Details

    • determineOS

      private static final Platform.OS determineOS()
      Determines the operating system jffi is running on
      Returns:
      An member of the OS enum.
    • determinePlatform

      private static final Platform determinePlatform(Platform.OS os)
      Determines the Platform that best describes the OS
      Parameters:
      os - The operating system.
      Returns:
      An instance of Platform
    • newDarwinPlatform

      private static Platform newDarwinPlatform()
    • newWindowsPlatform

      private static Platform newWindowsPlatform()
    • newDefaultPlatform

      private static Platform newDefaultPlatform(Platform.OS os)
    • getPlatform

      public static final Platform getPlatform()
      Gets the current Platform
      Returns:
      The current platform.
    • 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.
    • 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

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

      public String mapLibraryName(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.
    • getLibraryNamePattern

      public String 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

      private static boolean startsWithIgnoreCase(String s1, String s2)