Skip to content

Move Linux HAL and hardware classes to oshi-common - #3138

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:linux-hal
Apr 11, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:linux-hal

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Apr 11, 2026 •

Copy link
Copy Markdown
Member

Moves the Linux hardware abstraction layer and all native-free Linux hardware base classes from oshi-core (oshi.hardware.platform.linux) to oshi-common (oshi.hardware.common.platform.linux), so both JNA and FFM subclasses extend from a shared module.

HAL and dependencies

  • LinuxHardwareAbstractionLayer (abstract) — getPrinters() removed (interface default returns empty list), getGraphicsCards() made abstract
  • LinuxComputerSystem, LinuxFirmware, LinuxBaseboard, LinuxSensors, LinuxSoundCard
  • UnixDisplay → oshi.hardware.common.platform.unix
  • Xrandr driver → oshi.util.driver.unix

Hardware base classes

Class Pattern
LinuxCentralProcessor Base + JNA + FFM (made public)
LinuxHWDiskStore Base + JNA + FFM
LinuxLogicalVolumeGroup Base + JNA + FFM (made public)
LinuxNetworkIF Base + JNA + FFM
LinuxPowerSource Base + JNA + FFM
LinuxUsbDevice Base + JNA + FFM
LinuxGlobalMemory Single class, no native deps
LinuxVirtualMemory Single class, no native deps

Not moved

LinuxGraphicsCard and LinuxGpuStats remain in oshi-core — createStatsSession() instantiates LinuxGpuStats which depends on NvmlUtil (JNA). These need a JNA/FFM split before they can move.

Import updates

All JNA subclasses in oshi-core and FFM subclasses in oshi-core-java25 updated with explicit imports for the relocated base classes. LinuxPowerSourceTest moved to oshi-common test tree. module-info.java already exported the target package from the prior HAL work.

Summary by CodeRabbit

  • New Features

    • Module exports expanded to expose common Linux and Unix hardware packages
    • Graphics card and printer enumeration added for Linux platforms
  • Refactor

    • Shared/common Linux/Unix hardware implementations reorganized for reuse
    • Driver utilities and platform-specific types consolidated under a unified package structure

@coderabbitai

coderabbitai Bot commented Apr 11, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 57642e79-30e2-4ad8-9a77-3b802b78da58

📥 Commits

Reviewing files that changed from the base of the PR and between 951ef15 and 00fa19f.

📒 Files selected for processing (41)
  • CHANGELOG.md
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxBaseboard.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxGlobalMemory.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHardwareAbstractionLayer.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxLogicalVolumeGroup.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxPowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxSensors.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxSoundCard.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxUsbDevice.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxVirtualMemory.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/package-info.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/UnixDisplay.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Xrandr.java
  • oshi-common/src/test/java/module-info.test
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxPowerSourceTest.java
  • oshi-common/src/test/java/oshi/util/driver/unix/XrandrTest.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxHardwareAbstractionLayerFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxLogicalVolumeGroupFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxNetworkIFFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxUsbDeviceFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHardwareAbstractionLayerJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxLogicalVolumeGroupJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxNetworkIFJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxUsbDeviceJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/aix/AixHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/openbsd/OpenBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisHardwareAbstractionLayer.java
✅ Files skipped from review due to trivial changes (22)
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/package-info.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisHardwareAbstractionLayer.java
  • oshi-common/src/test/java/module-info.test
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/package-info.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxUsbDeviceFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxUsbDeviceJNA.java
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxBaseboard.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxGlobalMemory.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java
  • oshi-common/src/test/java/oshi/util/driver/unix/XrandrTest.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxNetworkIF.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxLogicalVolumeGroupFFM.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxSensors.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/openbsd/OpenBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHardwareAbstractionLayer.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxVirtualMemory.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (16)
  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxPowerSource.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Xrandr.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxPowerSourceTest.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/aix/AixHardwareAbstractionLayer.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxCentralProcessor.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxNetworkIFFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxNetworkIFJNA.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/UnixDisplay.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxUsbDevice.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxSoundCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceJNA.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxLogicalVolumeGroup.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHardwareAbstractionLayerJNA.java
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Analyze (java)
  • GitHub Check: Test JDK 11, windows-latest
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 11, macos-latest
  • GitHub Check: Test JDK 25, windows-latest
  • GitHub Check: Test JDK 25, macos-latest
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
🧰 Additional context used
🧠 Learnings (11)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:51.516Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java11/src/main/java/module-info.java:10-17
Timestamp: 2026-03-29T20:01:06.452Z
Learning: In the oshi project, `oshi-core-java25/src/main/java/module-info.java` intentionally does NOT export `oshi.util.platform.unix.freebsd`, `oshi.util.platform.unix.openbsd`, or `oshi.util.platform.unix.solaris`, because the FFM (Foreign Function & Memory) implementation only supports Windows, macOS, and Linux. This differs from `oshi-core-java11/src/main/java/module-info.java` which exports all Unix platform packages. The asymmetry is by design.
📚 Learning: 2026-04-05T16:15:06.124Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxLogicalVolumeGroupJNA.java:95-97
Timestamp: 2026-04-05T16:15:06.124Z
Learning: In `LinuxLogicalVolumeGroupJNA.getLogicalVolumeGroups()` (oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxLogicalVolumeGroupJNA.java), `physicalVolumesMap.get(e.getKey())` in the final stream mapping cannot return null: both `logicalVolumesMap` and `physicalVolumesMap` are populated via `computeIfAbsent` inside the same conditional block (`!Util.isBlank(vgName) && !Util.isBlank(lvName)`), so every VG key in `logicalVolumesMap` is guaranteed to have a corresponding entry in `physicalVolumesMap`. Do not flag this `.get()` call as a potential null-return issue. The FFM version uses `getOrDefault` as extra defensiveness, not because null is possible here.

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxLogicalVolumeGroupJNA.java
📚 Learning: 2026-04-06T04:45:47.644Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:47.644Z
Learning: In the oshi/oshi project, only interfaces and classes in the root packages `oshi`, `oshi.hardware`, and `oshi.software.os` are considered the public API. Code in subpackages that represent specific implementations/platforms (e.g., `oshi.software.os.linux`, `oshi.hardware.platform.linux`, and similar subpackages) is implementation detail. When reviewing, do not treat changes to classes in these platform-specific subpackages as public API breaks (for example: making `LinuxOperatingSystem` abstract, narrowing constructor visibility, or adding/removing abstract methods should not be flagged as breaking public API).

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxLogicalVolumeGroupJNA.java
📚 Learning: 2026-04-05T05:40:45.797Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceFFM.java:62-65
Timestamp: 2026-04-05T05:40:45.797Z
Learning: In OSHI's Linux FFM and JNA udev code, a null guard on `udev_enumerate_new()` is intentionally absent and should not be flagged. This is consistent across all four FFM classes (LinuxPowerSourceFFM, LinuxHWDiskStoreFFM, LinuxLogicalVolumeGroupFFM, LinuxUsbDeviceFFM) and the JNA implementation (which also does not guard `enumerateNew()` for null). Per libudev semantics, `udev_enumerate_new()` only returns NULL when udev itself is broken (e.g. OOM), so a successful `udev_new()` (which is guarded) implies `udev_enumerate_new()` will succeed. Adding a null guard would be both redundant and inconsistent with the established pattern.

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxLogicalVolumeGroupJNA.java
📚 Learning: 2026-04-05T05:39:21.126Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceFFM.java:62-65
Timestamp: 2026-04-05T05:39:21.126Z
Learning: In OSHI's Linux FFM/JNA udev code, a null guard on `udev_enumerate_new()` is unnecessary if `udev_new()` has already been guarded: per libudev semantics, `udev_enumerate_new()` only returns NULL when udev itself is broken (e.g. OOM), so a successful `udev_new()` implies `udev_enumerate_new()` will succeed as well. Do not flag missing null checks on `udev_enumerate_new()` as an issue.

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxLogicalVolumeGroupJNA.java
📚 Learning: 2026-04-06T04:45:51.516Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:51.516Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.

Applied to files:

  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxHardwareAbstractionLayerFFM.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHardwareAbstractionLayer.java
📚 Learning: 2026-04-05T05:40:43.357Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceFFM.java:62-65
Timestamp: 2026-04-05T05:40:43.357Z
Learning: In OSHI’s Linux FFM implementations (e.g., LinuxPowerSourceFFM, LinuxHWDiskStoreFFM, LinuxLogicalVolumeGroupFFM, LinuxUsbDeviceFFM) and the corresponding JNA udev code, do not require/flag a missing null check around `udev_enumerate_new()`/`enumerateNew()`. Per libudev semantics, `udev_enumerate_new()` returns NULL only if udev itself is broken (e.g., OOM). Since `udev_new()` is already guarded and is the successful prerequisite for enumeration, treating `udev_enumerate_new()` as non-null is consistent with the established pattern; adding a redundant null guard would be inconsistent.

Applied to files:

  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxHardwareAbstractionLayerFFM.java
📚 Learning: 2026-04-05T15:37:17.867Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxUsbDeviceFFM.java:59-65
Timestamp: 2026-04-05T15:37:17.867Z
Learning: In OSHI's Linux USB device implementations (LinuxUsbDeviceFFM, and the JNA equivalent), when `getUsbDevices(boolean tree)` is called with `tree=false`, the returned flat list intentionally **includes** controller nodes — it does not exclude them. The existing Javadoc that says "returns a flat list excluding controllers" is incorrect. Do not flag the implementation for including controllers in flat mode; instead, flag only the Javadoc if it claims controllers are excluded.

Applied to files:

  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxHardwareAbstractionLayerFFM.java
📚 Learning: 2026-04-03T02:07:47.621Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3110
File: oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHWDiskStoreFFM.java:119-121
Timestamp: 2026-04-03T02:07:47.621Z
Learning: In OSHI’s Java FFM/API implementation classes (e.g., *FFM.java) that implement/override `updateAttributes()`, preserve the intentional failure-handling pattern: catch `Throwable` and return `false` without logging. `updateAttributes()` is a public API whose contract is to signal failure via the boolean return value, and callers rely on that return value (so emitting logs from this path is not desired and should not be introduced during review unless the method contract changes).

Applied to files:

  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxHardwareAbstractionLayerFFM.java
📚 Learning: 2026-04-05T05:39:18.791Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceFFM.java:62-65
Timestamp: 2026-04-05T05:39:18.791Z
Learning: When reviewing OSHI Linux FFM/JNA code that uses libudev, do not flag a missing null check on `udev_enumerate_new()` if `udev_new()` has already been guarded. Per libudev semantics, `udev_enumerate_new()` returns NULL only when the udev context itself is broken (e.g., OOM), so a successful `udev_new()` implies `udev_enumerate_new()` should succeed as well. Therefore, lack of a redundant null guard on `udev_enumerate_new()` is acceptable in this pattern.

Applied to files:

  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxHardwareAbstractionLayerFFM.java
📚 Learning: 2026-03-29T20:01:06.452Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java11/src/main/java/module-info.java:10-17
Timestamp: 2026-03-29T20:01:06.452Z
Learning: In the oshi project, `oshi-core-java25/src/main/java/module-info.java` intentionally does NOT export `oshi.util.platform.unix.freebsd`, `oshi.util.platform.unix.openbsd`, or `oshi.util.platform.unix.solaris`, because the FFM (Foreign Function & Memory) implementation only supports Windows, macOS, and Linux. This differs from `oshi-core-java11/src/main/java/module-info.java` which exports all Unix platform packages. The asymmetry is by design.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHardwareAbstractionLayer.java
🔇 Additional comments (5)
oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxLogicalVolumeGroupJNA.java (1)

24-24: Import relocation is correct and consistent.

Line 24 correctly switches to oshi.hardware.common.platform.linux.LinuxLogicalVolumeGroup, which matches the class move and keeps the subclass inheritance path intact.

oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxHardwareAbstractionLayerFFM.java (2)

10-21: Import relocation is consistent.

These imports line up cleanly with the move into oshi-common and keep the FFM HAL extending the shared Linux base without leaving stale references behind.


56-64: Override split looks correct.

Adding the graphics-card and printer overrides here matches the new common-base contract and keeps the FFM HAL behavior explicit.

oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHardwareAbstractionLayer.java (2)

5-18: Package move reads cleanly.

The class and UnixDisplay import now sit in the expected common packages for this refactor.


52-53: Abstracting graphics enumeration here makes sense.

This keeps oshi-common free of the remaining platform-specific graphics implementation while still enforcing the contract on Linux subclasses.


📝 Walkthrough

Walkthrough

Move many Linux/Unix platform classes into oshi.hardware.common.platform.linux and oshi.hardware.common.platform.unix, export those packages from the com.github.oshi.common module, update imports (including Xrandr → oshi.util.driver.unix), make LinuxHardwareAbstractionLayer.getGraphicsCards() abstract and remove its getPrinters() implementation, and add concrete overrides in JNA/FFM HALs.

Changes

Cohort / File(s) Summary
Module Configuration
oshi-common/src/main/java/module-info.java
Exported oshi.hardware.common.platform.linux and oshi.hardware.common.platform.unix.
Linux common package files
oshi-common/src/main/java/oshi/hardware/common/platform/linux/* (e.g., LinuxBaseboard.java, LinuxComputerSystem.java, LinuxFirmware.java, LinuxSensors.java, LinuxSoundCard.java, LinuxCentralProcessor.java, LinuxGlobalMemory.java, LinuxHWDiskStore.java, LinuxLogicalVolumeGroup.java, LinuxNetworkIF.java, LinuxPowerSource.java, LinuxUsbDevice.java, LinuxVirtualMemory.java, package-info.java)
Changed package declarations to oshi.hardware.common.platform.linux; some classes made public (e.g., LinuxCentralProcessor, LinuxLogicalVolumeGroup); added package Javadoc.
Linux HAL refactor (common)
oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHardwareAbstractionLayer.java
Package moved; removed getPrinters() implementation; getGraphicsCards() changed from concrete to abstract; imports updated.
Unix common package files
oshi-common/src/main/java/oshi/hardware/common/platform/unix/UnixDisplay.java, oshi-common/src/main/java/oshi/hardware/common/platform/unix/package-info.java
Moved UnixDisplay to oshi.hardware.common.platform.unix; updated Xrandr import to oshi.util.driver.unix.Xrandr; added package Javadoc and header years.
Driver/test relocation
oshi-common/src/main/java/oshi/util/driver/unix/Xrandr.java, oshi-common/src/test/java/oshi/util/driver/unix/XrandrTest.java
Package changed to oshi.util.driver.unix; updated copyright years and test package.
JNA / FFM HAL implementations
oshi-core/src/main/java/.../LinuxHardwareAbstractionLayerJNA.java, oshi-core-java25/src/main/java/.../LinuxHardwareAbstractionLayerFFM.java
Added concrete overrides: getGraphicsCards() → LinuxGraphicsCard.getGraphicsCards(); getPrinters() → UnixPrinter.getPrinters() (JNA) or CupsPrinter.getPrinters() (FFM).
Core imports updated to common packages
oshi-core/src/main/java/.../platform/linux/*FFM.java, .../platform/linux/*JNA.java, oshi-core/src/main/java/oshi/hardware/platform/unix/.../*HardwareAbstractionLayer.java
Added/imported oshi.hardware.common.platform.linux types and updated Unix HALs to use oshi.hardware.common.platform.unix.UnixDisplay; adjusted extends/imports to resolve moved classes.
Changelog
CHANGELOG.md
Release notes updated to reference an additional PR entry alongside the existing one.
Test JVM args
oshi-common/src/test/java/module-info.test
Added --add-opens for com.github.oshi.common/oshi.hardware.common.platform.linux to org.junit.platform.commons.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Client as "Client"
participant HAL as "LinuxHardwareAbstractionLayer (abstract)"
participant Impl as "LinuxHardwareAbstractionLayerJNA / FFM"
participant Provider as "LinuxGraphicsCard / UnixPrinter / CupsPrinter"

Client->>HAL: request getGraphicsCards()/getPrinters()
HAL->>Impl: call concrete override
Impl->>Provider: delegate to provider (LinuxGraphicsCard / UnixPrinter / CupsPrinter)
Provider-->>Impl: return device list
Impl-->>HAL: return list
HAL-->>Client: return devices

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐇 I hopped through packages, tidy and spry,
Moved Linux and Unix under one sky,
Made the HAL abstract, delegates sing,
JNA and FFM fetch devices in spring,
A carrot for commits — hoppity-hi!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: moving Linux HAL and hardware classes to the oshi-common module, which is the primary objective of this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Apr 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.30%. Comparing base (3ee332f) to head (00fa19f).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3138      +/-   ##
============================================
+ Coverage     61.14%   62.30%   +1.15%     
  Complexity       12       12              
============================================
  Files            39       39              
  Lines          2329     2329              
  Branches        407      407              
============================================
+ Hits           1424     1451      +27     
+ Misses          786      768      -18     
+ Partials        119      110       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dbwiddis dbwiddis changed the title Move Linux HAL and dependencies to oshi-common Move Linux HAL and hardware classes to oshi-common Apr 11, 2026
Move LinuxHardwareAbstractionLayer and its non-native dependencies
(LinuxComputerSystem, LinuxFirmware, LinuxBaseboard, LinuxSensors,
LinuxSoundCard) to oshi-common. Move UnixDisplay and Xrandr driver
to oshi-common. Make getPrinters() use interface default (empty list)
on common HAL, pushed down to JNA (UnixPrinter) and FFM (CupsPrinter)
subclasses. Make getGraphicsCards() abstract on common HAL due to
LinuxGraphicsCard -> LinuxGpuStats -> NvmlUtil JNA dependency chain.

Move 8 native-free Linux hardware base classes to oshi-common:
LinuxCentralProcessor, LinuxGlobalMemory, LinuxHWDiskStore,
LinuxLogicalVolumeGroup, LinuxNetworkIF, LinuxPowerSource,
LinuxUsbDevice, and LinuxVirtualMemory. LinuxCentralProcessor and
LinuxLogicalVolumeGroup made public for cross-package subclass access.
Updated imports in all JNA and FFM subclasses. Moved
LinuxPowerSourceTest to oshi-common.

LinuxGraphicsCard and LinuxGpuStats remain in oshi-core due to
NvmlUtil (JNA) dependency in createStatsSession().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant