Package dev.hydraulic.types.machines
Types for modelling aspects of a computer relevant to the execution of native code, such as the operating system, CPU architecture and C library.
Each aspect of machine compatibility is modelled with an interface that extendsMachineCompatibilityAspect and an enum that contains well known implementations of that aspect.
For example the CPUArchitecture interface is implemented by each member of the
CPUArchitectures enum which contains values for AMD64, AARCH64 and so on.
This package is only intended to contain types, not functionality. If you're looking for ways to get information about the operating system you're running on, check out OSHI.
Comprehensiveness
The primary goal of this package is to provide a schema for representing hardware and software in active use as of January 2022 for general purpose computing, whilst still allowing extension for more exotic components that maybe aren't widely used (see below).
Extinct or hobby components won't be included unless someone can provide a compelling use case, or argue convincingly that they've changed status ("hobby" is defined as being developed for its own sake). Specialized embedded systems that aren't intended for general purpose computing also don't fall under this definition. Variants so minor that they can be binary compatible from the perspective of application developers aren't distinguished from each other.
Naming and aliases
Enumeration values have names that match the capitalization used by the vendors, not the normal enum capitalization rules for Java.
This is to make source code read more naturally. If you want to put a name into a user interface, use
MachineCompatibilityAspect.getDisplayName() which returns the brand name including characters that
aren't legal in Java identifiers.
Each interface contains a from method (and variants) that parse a variety of common aliases for each aspect. This is intended
to make handling user input and file name parsing more robust, whilst avoiding the question of what a given aspect 'should' be called.
This is especially useful for macOS which is known by a variety of names (like mac, macos, osx and
darwin), and also CPU architectures. Aliases can be found using the static
ALIAS_MAP on each enum, or by calling MachineCompatibilityAspect.getAliases() for a given
entry, and the sets returned will include the lower cased name of the enum value itself.
Forwards/backwards compatibility
The enums are intended to be as exhaustive as possible within the rules given above. Over time new components are developed and
released, and these will be added to new versions of the library. Thus if you write code that de-serializes these enums you should be
able to handle unrecognized values from the future by mapping them to null or the entry Other. ObjectInputStream
doesn't support this, so consider wrapping types if you need to serialize enums with Java serialization in ways that need to be forwards
compatible.
Other rules are:
- No entries will ever be removed, even if they become extinct.
- Operating systems may be added or removed from the family sets (
apple,linuxKernelBased,unixetc), although it's unlikely anything about them would change enough to justify this. - Aliases may be added but will never be removed.
- Vendors and display names may change at any time, e.g. to track rebrandings.
Extension
It's impossible and/or undesirable to list every possible CPU architecture and operating system in an enum. If a component you want isn't available but you need to express it to a library that uses this API, implement the interfacesCPUArchitecture or OperatingSystem yourself. They don't contain
any functionality, only naming related methods intended to enable interoperability and user interface generation.
If you need to model an aspect of compatibility that goes beyond what this API does, e.g. individual Linux distributions, consider
creating an interface that extends one of the interfaces here. You can then delegate to the base enum values for the base methods and
only implement the extra properties you need.-
ClassDescriptionEnumerates glibc and muslc, the two C libraries that matter on Linux.Models a C library for platforms that have multiple competing implementations.A type that models a coarse-grained CPU architecture.Major CPU architecture families and common names for them.Models a machine that runs Linux specifically, adding the additional detail of which C library and distribution it uses.Represents combined aspects of a computer that can affect binary compatibility.Base interface for objects that represents some component or interface of a computer that affects application compatibility.A type that represents an operating system or family of closely related operating systems.An enumeration of well known, actively used operating systems.Various groupings of well known operating systems useful for compatibility testing purposes.Thrown if a name or alias isn't recognized.