- All Superinterfaces:
Comparable<Machine>
- All Known Subinterfaces:
LinuxMachine
Machines define a small string serialization of the form osname.cpuname, as generated by toString() and parsed by parse(String). Machines sort according to their string representation. Subtypes like LinuxMachine may extend this string
encoding to incorporate more detail.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LinuxMachineAn immutableLinuxMachinewith no distribution domain, AARCH64 and glibc.static final LinuxMachineAn immutableLinuxMachinewith no distribution domain, AARCH64 and muslc.static final LinuxMachineAn immutableLinuxMachinewith no distribution domain, AMD64 and glibc.static final LinuxMachineAn immutableLinuxMachinewith no distribution domain, AMD64 and muslc.static final MachineAn immutableMachinewith macOS on AARCH64.static final MachineAn immutableMachinewith macOS on AMD64.static final MachineAn immutableMachinewith Windows on AARCH64.static final MachineAn immutableMachinewith Windows on AMD64. -
Method Summary
Modifier and TypeMethodDescriptionstatic Machinecurrent()Returns a machine representing the currently executing JVM's environment, based on reading system properties and file paths.getCPU()The CPU architecture.getOS()The operating system, without version information.static Machineof(OperatingSystem os, CPUArchitecture cpu) Returns an object that implements Machine and possibly LinuxMachine (defaulting to glibc as the C library and no distribution domain), given the specified operating system and CPU architecture.static MachineConverts a string to a machine spec by parsing it in a lenient manner.Converts a string to a machine spec by parsing it in a lenient manner.Methods inherited from interface java.lang.Comparable
compareTo
-
Field Details
-
LINUX_AMD64
An immutableLinuxMachinewith no distribution domain, AMD64 and glibc. -
LINUX_AARCH64
An immutableLinuxMachinewith no distribution domain, AARCH64 and glibc. -
LINUX_AMD64_MUSLC
An immutableLinuxMachinewith no distribution domain, AMD64 and muslc. -
LINUX_AARCH64_MUSLC
An immutableLinuxMachinewith no distribution domain, AARCH64 and muslc. -
MACOS_AMD64
An immutableMachinewith macOS on AMD64. -
MACOS_AARCH64
An immutableMachinewith macOS on AARCH64. -
WINDOWS_AMD64
An immutableMachinewith Windows on AMD64. -
WINDOWS_AARCH64
An immutableMachinewith Windows on AARCH64.
-
-
Method Details
-
getOS
OperatingSystem getOS()The operating system, without version information. -
getCPU
CPUArchitecture getCPU()The CPU architecture. -
of
Returns an object that implements Machine and possibly LinuxMachine (defaulting to glibc as the C library and no distribution domain), given the specified operating system and CPU architecture. -
parse
Converts a string to a machine spec by parsing it in a lenient manner. The string is split into components using the `.` separator, then the first component is matched against the OS and the second against the CPU architecture. If the OS is Linux then the third (if present) may be a C library and the remaining components are reversed DNS components of the distribution website.Because a Machine must specify a CPU architecture, if the string form doesn't then a default is picked based on the dominant OS type used on that platform, or if no such type is known then [CPUArchitectures.UNKNOWN] is used:
- Linux, Windows: AMD64 - Android, any Apple OS including macOS: AARCH64 - Others: UNKNOWN
- Throws:
IllegalArgumentException- if any component isn't a recognized name or alias.
-
parseAll
Converts a string to a machine spec by parsing it in a lenient manner. The string is split into components using the `.` separator, then the first component is matched against the OS and the second against the CPU architecture. If the OS is Linux then the third (if present) may be a C library and the remaining components are reversed DNS components of the distribution website.
Unlike
parse(String), missing components will be expanded to all known CPU architectures and C libraries. An empty string will yield an empty result. The special string "*" will yield a result with all known operating systems and CPU architectures.If
supportedis set to true, combinations that don't represent machines actually in use are excluded. For exampleparseAll("mac", true)won't return results withCPUArchitectures.RISCVincluded, because (at the time of writing) there is no Mac with a RISC-V chip and probably there never will be. Windows is likewise taken to only support AMD64, x86 and AARCH64, although other combinations have been used in the past. Free UNIXes like Linux, FreeBSD etc are assumed to support every possible CPU architecture, and Linux is assumed to support every CPU architure and C library in combination. Please note that this support matrix isn't guaranteed to be 100% correct, especially as a release of the library ages.- Parameters:
spec- The input to expand.supported- Whether to only include combinations that were known to actually be in use at the time of the release of this library.- Returns:
- An unordered set of all known machines that match the input.
-
current
Returns a machine representing the currently executing JVM's environment, based on reading system properties and file paths. This is currently capable of detecting Windows, Mac and Linux but other operating systems will be detected asOperatingSystems.UNKNOWN. The C library for Linux hosts is detected by looking for/lib/libc.musl-x86_64.so.1.
-