Repository navigation
Description
Motivation
With the 7.x SPI architecture (SystemInfoFactory / SystemInfoProvider), users can choose between JNA (oshi-core) and FFM (oshi-core-ffm) implementations. However, both require --enable-native-access under JEP 472 (Java 24+), which was the original concern raised in #2698.
Now that the SPI pattern is in place, there is an opportunity to provide a third option: a pure-Java, native-free fallback provider built into oshi-common itself, targeting Linux.
Proposal
Register a SystemInfoProvider implementation within oshi-common that implements the OSHI interfaces using only:
/procfilesystem (/proc/cpuinfo,/proc/meminfo,/proc/stat,/proc/[pid]/*,/proc/net/*, etc.)/sysfilesystem (/sys/class/net/,/sys/block/,/sys/class/hwmon/,/sys/class/power_supply/,/sys/devices/system/cpu/,/sys/class/dmi/id/, etc.)- Standard Java file I/O and
FileStoreAPIs - Command-line utilities as fallback (
lsblk,ip,lspci,lsusb)
This provider would be loaded by SystemInfoFactory at the lowest priority — only used when neither oshi-core nor oshi-core-ffm is on the classpath.
What this enables
- Zero native access warnings — no
--enable-native-accessneeded - No JNA dependency —
oshi-common+ SLF4J only - Smallest possible footprint for Linux-only deployments (containers, CLI tools, monitoring agents)
- Graceful degradation — individual methods in JNA/FFM providers could delegate to this fallback when native calls fail
Coverage estimate (Linux)
Most of oshi-common already contains the procfs/sysfs parsing logic that oshi-core calls into. The fallback provider would wire these existing drivers directly to the SPI interfaces. Estimated coverage:
| Category | Coverage | Source |
|---|---|---|
| CentralProcessor | ~95% | /proc/cpuinfo, /proc/stat, /sys/devices/system/cpu/ |
| GlobalMemory / VirtualMemory | ~100% | /proc/meminfo, /proc/vmstat |
| HWDiskStore / HWPartition | ~95% | /sys/block/, /proc/diskstats, lsblk |
| FileSystem | ~100% | /proc/mounts, Java FileStore |
| NetworkIF | ~95% | /sys/class/net/, /proc/net/dev |
| InternetProtocolStats | ~90% | /proc/net/tcp, /proc/net/udp, /proc/net/snmp |
| OSProcess / OSThread | ~95% | /proc/[pid]/stat, status, cmdline, smaps_rollup |
| OperatingSystem | ~100% | /proc/version, /etc/os-release, /proc/uptime |
| Sensors | ~80% | /sys/class/hwmon/, /sys/class/thermal/ |
| PowerSource | ~90% | /sys/class/power_supply/ |
| ComputerSystem / Baseboard / Firmware | ~70% | /sys/class/dmi/id/ (some fields need root) |
| USB / Display / SoundCard | ~70% | /sys/bus/usb/, /sys/class/drm/, /proc/asound/ |
Non-goals
- Windows/macOS support (those platforms genuinely need native calls)
- Full feature parity with JNA/FFM providers (some fields will return defaults)
- Process control (kill/signal — not in OSHI's scope)
Design considerations
- The provider should be Linux-only; on other platforms
SystemInfoFactory.create()would throw if no JNA/FFM provider is available - Priority: FFM > JNA > procfs fallback
- Could be implemented incrementally — start with CPU/memory/process (highest demand) and expand
Activity
Add native-free Linux SystemInfoProvider in oshi-common (#3238)