Class SystemTools

java.lang.Object
rife.bld.extension.tools.SystemTools

@NullMarked public final class SystemTools extends Object
Utility methods for detecting the current operating system, architecture, and related execution environments.

Provides normalized OS-name checks for common platforms (AIX, FreeBSD, Linux, macOS, OpenVMS, Solaris, Windows) along with heuristics for identifying Cygwin, MinGW/MSYS2, and WSL environments. Also provides architecture detection for x86 and ARM families.

Designed for null-safety, testability, and minimal overhead. All system properties are cached at class load time.

Since:
1.0
Author:
Erik C. Thauvin
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Returns the normalized system architecture string.
    static boolean
    Determines if the current operating system is AIX.
    static boolean
    Determines if the current system architecture is any ARM variant.
    static boolean
    Determines if the current system architecture is ARM 32-bit.
    static boolean
    Determines if the current system architecture is ARM 64-bit.
    static boolean
    Determines if the current environment is running in a Cygwin environment.
    static boolean
    Determines if the current operating system is FreeBSD.
    static boolean
    Determines if the current operating system is Linux.
    static boolean
    Determines if the current operating system is macOS.
    static boolean
    Determines if the current environment is running in a MinGW/MSYS2 environment.
    static boolean
    Determines if the current operating system is OpenVMS.
    static boolean
    Determines if the current operating system is other than AIX, FreeBSD, Linux, macOS, OpenVMS, Solaris, or Windows.
    static boolean
    Determines if the current operating system is Solaris.
    static boolean
    Determines if the current operating system is Windows.
    static boolean
    Determines if the current environment is Windows Subsystem for Linux.
    static boolean
    Determines if the current system architecture is x86 64-bit.
    static boolean
    Determines if the current system architecture is x86 32-bit.
    static boolean
    Determines if the current system architecture is any x86 variant.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • arch

      public static String arch()
      Returns the normalized system architecture string.

      Equivalent to System.getProperty("os.arch").toLowerCase(Locale.ROOT). Use the is* methods for reliable checks instead of comparing this value directly, as os.arch values vary across JVM implementations.

      Returns:
      the architecture string in lowercase, or empty string if unavailable
      Since:
      1.3
    • isAix

      public static boolean isAix()
      Determines if the current operating system is AIX.
      Returns:
      true if the operating system is AIX, false otherwise
      Since:
      1.0
    • isArm

      public static boolean isArm()
      Determines if the current system architecture is any ARM variant.

      Equivalent to isArm32() || isArm64().

      Returns:
      true if the architecture is ARM 32-bit or 64-bit, false otherwise
      Since:
      1.3
    • isArm32

      public static boolean isArm32()
      Determines if the current system architecture is ARM 32-bit.

      Checks os.arch for "arm", "arm32", or "armv*" without "64". Covers older Raspberry Pi, Android devices, etc.

      Returns:
      true if the architecture is ARM 32-bit, false otherwise
      Since:
      1.3
    • isArm64

      public static boolean isArm64()
      Determines if the current system architecture is ARM 64-bit.

      Checks os.arch for "aarch64" or "arm64". Covers Apple Silicon, AWS Graviton, Raspberry Pi 64-bit, etc.

      Returns:
      true if the architecture is ARM64, false otherwise
      Since:
      1.3
    • isCygwin

      public static boolean isCygwin()
      Determines if the current environment is running in a Cygwin environment.

      This method delegates to isCygwin(String, Function) using the current OS name and System.getenv(java.lang.String) as the environment provider. For testing, use isCygwin(String, Function) directly with a custom environment provider.

      Heuristic-based detection; may have false positives on Windows with Unix-like tools.

      Returns:
      true if the environment is detected as Cygwin, false otherwise
      Since:
      1.0
    • isFreeBsd

      public static boolean isFreeBsd()
      Determines if the current operating system is FreeBSD.
      Returns:
      true if the operating system is FreeBSD, false otherwise
      Since:
      1.0
    • isLinux

      public static boolean isLinux()
      Determines if the current operating system is Linux.
      Returns:
      true if the operating system is Linux, false otherwise
      Since:
      1.0
    • isMacOS

      public static boolean isMacOS()
      Determines if the current operating system is macOS.
      Returns:
      true if the OS is macOS, false otherwise
      Since:
      1.0
    • isMinGw

      public static boolean isMinGw()
      Determines if the current environment is running in a MinGW/MSYS2 environment.

      This method delegates to isMinGw(String, Function) using the current OS name and System.getenv(java.lang.String) as the environment provider. For testing, use isMinGw(String, Function) directly with a custom environment provider.

      Heuristic-based detection; may have false positives on Windows with Unix-like tools.

      Returns:
      true if the environment is detected as MinGW/MSYS2, false otherwise
      Since:
      1.0
    • isOpenVms

      public static boolean isOpenVms()
      Determines if the current operating system is OpenVMS.
      Returns:
      true if the operating system is OpenVMS, false otherwise
      Since:
      1.0
    • isOtherOs

      public static boolean isOtherOs()
      Determines if the current operating system is other than AIX, FreeBSD, Linux, macOS, OpenVMS, Solaris, or Windows.
      Returns:
      true if the operating system is none of the above, false otherwise
      Since:
      1.0
    • isSolaris

      public static boolean isSolaris()
      Determines if the current operating system is Solaris.
      Returns:
      true if the operating system is Solaris, false otherwise
      Since:
      1.0
    • isWindows

      public static boolean isWindows()
      Determines if the current operating system is Windows.
      Returns:
      true if the operating system is Windows, false otherwise
      Since:
      1.0
    • isWsl

      public static boolean isWsl()
      Determines if the current environment is Windows Subsystem for Linux.

      Checks /proc/version for "Microsoft" or "WSL" signatures. Result is cached at class load time.

      Returns:
      true if running under WSL, false otherwise
      Since:
      1.3
    • isX64

      public static boolean isX64()
      Determines if the current system architecture is x86 64-bit.

      Checks os.arch for "amd64" or "x86_64". Covers Intel/AMD 64-bit, including Apple Intel Macs.

      Returns:
      true if the architecture is x86 64-bit, false otherwise
      Since:
      1.3
    • isX86

      public static boolean isX86()
      Determines if the current system architecture is x86 32-bit.

      Checks os.arch for "x86", "i386", "i486", "i586", or "i686".

      Returns:
      true if the architecture is x86 32-bit, false otherwise
      Since:
      1.3
    • isX86Family

      public static boolean isX86Family()
      Determines if the current system architecture is any x86 variant.

      Equivalent to isX86() || isX64().

      Returns:
      true if the architecture is x86 32-bit or 64-bit, false otherwise
      Since:
      1.3