Skip to content

Move NetBSD to oshi-common; wire NetBSD into FFM SystemInfo - #3360

Merged
dbwiddis merged 2 commits into
oshi:masterfrom
dbwiddis:netbsd-to-oshi-common
Jun 9, 2026
Merged

dbwiddis merged 2 commits into
oshi:masterfrom
dbwiddis:netbsd-to-oshi-common

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Jun 9, 2026 •

Copy link
Copy Markdown
Member

Summary

NetBSD's implementation has no native dependencies — it's all command-line parsing and file reads — so its platform classes belong next to oshi-common's other "no JNA / no FFM" code (FreeBSD bases, OpenBSD bases, Solaris bases, AIX bases) rather than over in oshi-core. This move + a small wiring change lets oshi-core-ffm cover NetBSD too, closing the only remaining FFM platform gap that wasn't a JDK-25-availability problem.

Companion to #3357 / #3359 — once this lands, the only platform oshi-core-ffm doesn't claim is DragonFly BSD (tracked separately by #3346, which adds a real FFM port mirroring the FreeBSD pattern).

What changed

  • All 25 NetBSD classes move from oshi-core to oshi-common (8 software/os + 13 hardware + 2 util + 2 package-info), under the canonical oshi.{software,hardware,util}.common.{os,platform}.unix.netbsd packages. Mirrors the layout already used for the other Unix platforms. Renames preserve git history.
  • oshi-core-ffm/SystemInfo.java gains case NETBSD: entries in createOperatingSystem() and createHardware() (instantiating the shared oshi-common classes), and NETBSD is added to SUPPORTED_PLATFORMS. JDK 25 on NetBSD is currently aspirational (no community port yet), but when one lands FFM mode just works.
  • New LpstatPrinter class in oshi-common (oshi.hardware.common.platform.unix.LpstatPrinter) — a concrete CupsPrinter subclass that uses lpstat shell output only, no libcups via JNA. NetBsdHardwareAbstractionLayer now calls LpstatPrinter.getPrinters() instead of CupsPrinterJNA.getPrinters(). Printer enumeration behavior on NetBSD is functionally unchanged; it's just no longer coupled to oshi-core.
  • FstatUtilTest switches from oshi.SystemInfo to ManagementFactory.getRuntimeMXBean().getName() for the live-NetBSD PID, mirroring the FreeBSD ProcstatUtilTest pattern, so the test can live in oshi-common without depending on oshi-core.
  • Docs swept for stale "FFM doesn't support …" caveats:
    • README.md selection-matrix: NetBSD removed from the "unsupported platform" row; added to the FFM-supported rows.
    • FAQ.md FFM platform list: NetBSD and AIX added (AIX had been missing since the AIX-FFM port landed in 7.3.1-rc).
    • oshi-core-ffm/module-info.java: same list update.
    • oshi-core/SystemInfo.java javadoc: same list update.
  • CHANGELOG.md entry under 7.3.1 New Features.
  • module-info.test (oshi-common): adds --add-opens lines for the three new NetBSD packages so JUnit Jupiter can reflectively access the test class.

Issues

Test plan

  • ./mvnw clean install from repo root passes (all 788 tests).
  • Spotless / Checkstyle / Forbidden APIs / Javadoc clean on oshi-common, oshi-core, oshi-core-ffm.
  • JPMS module-info updates verified: oshi-core no longer exports the moved package, oshi-common exports the three new ones.
  • CI runs (this PR) — Linux/macOS/Windows matrix should be unchanged. FreeBSD/OpenBSD/OpenIndiana paths should be unchanged. NetBSD VM job exercises oshi-core SystemInfo against the moved classes (the actual functional regression check).

Summary by CodeRabbit

  • New Features

    • FFM now supports NetBSD (no native dependencies) and AIX; FFM coverage expanded across BSD/Unix platforms.
    • Added native-free printer discovery using lpstat for Unix platforms where available.
  • Chores

    • Reorganized NetBSD implementation packages and updated fallback behavior (DragonFly BSD still falls back to JNA).
    • Updated CHANGELOG, README and FAQ to reflect platform compatibility changes.

…temInfo

NetBSD's implementation has no native dependencies (only command-line
parsing and file reads), so the classes belong next to the other "no
JNA / no FFM" platform code in oshi-common rather than oshi-core.
Mirrors the abstract-base/POJO split convention already used by
oshi-common's freebsd, openbsd, solaris, and aix packages.

- All 25 NetBSD classes (8 software/os, 13 hardware, 2 util, 2
  package-info) move from oshi-core/.../netbsd/ to
  oshi-common/.../common/.../netbsd/. The classes themselves stay
  concrete with no JNA or FFM subclass — for the now-supported FFM
  path, oshi-core-ffm SystemInfo instantiates the same shared classes.
- FFM SystemInfo gains a NETBSD case in createOperatingSystem() and
  createHardware(), and NETBSD is added to SUPPORTED_PLATFORMS. JDK 25
  on NetBSD is currently aspirational (no community port yet), but
  when one lands FFM mode will work without code changes. Issues
  #3347 (restore JNA-with-fallback for NetBSD) and #3348 (FFM-native
  bindings for NetBSD) remain open as future performance improvements.
- Replaces the CupsPrinterJNA call in NetBsdHardwareAbstractionLayer
  with a new LpstatPrinter (oshi-common) concrete CupsPrinter subclass
  that uses lpstat shell output only. NetBSD's printer enumeration is
  unchanged in behavior, just no longer coupled to oshi-core.
- FstatUtilTest switches from SystemInfo to ManagementFactory for the
  live-NetBSD PID, mirroring the FreeBSD ProcstatUtilTest pattern, so
  the test can live in oshi-common without depending on oshi-core.
- Docs (README matrix, FAQ FFM platform list, FFM module-info,
  JNA-SystemInfo javadoc) updated to reflect NetBSD in the FFM
  supported set and AIX in the FFM list it had been missing.

Tested with \`./mvnw clean install\` from root (all 788 tests pass).
@coderabbitai

coderabbitai Bot commented Jun 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e7b21739-5d46-41ee-9743-faefb68d31e3

📥 Commits

Reviewing files that changed from the base of the PR and between 30981cf and 810e8a7.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/test/java/oshi/util/common/platform/unix/netbsd/FstatUtilTest.java
  • oshi-core/src/main/java/module-info.java
💤 Files with no reviewable changes (1)
  • oshi-core/src/main/java/module-info.java
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/test/java/oshi/util/common/platform/unix/netbsd/FstatUtilTest.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). (14)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: JMH Benchmarks, ubuntu-latest
  • GitHub Check: Test JDK 26, windows-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 26, macos-latest
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
  • GitHub Check: Analyze (java)

📝 Walkthrough

Walkthrough

This PR consolidates NetBSD platform support by migrating all NetBSD-specific implementations from oshi-core to oshi-common, enables NetBSD in the FFM module, introduces a native-free printer discovery mechanism via lpstat parsing, and updates module exports accordingly.

Changes

NetBSD FFM Support and Common Module Migration

Layer / File(s) Summary
Documentation and Platform Support Matrix
CHANGELOG.md, FAQ.md, README.md, oshi-core-ffm/src/main/java/module-info.java, oshi-core/src/main/java/oshi/SystemInfo.java
CHANGELOG and FAQ document NetBSD FFM support and expanded AIX coverage; README updates the implementation selection matrix to reflect that NetBSD no longer requires JNA fallback when both modules are present; Javadoc updated to clarify DragonFly BSD remains JNA-only.
Native-Free Printer Implementation via lpstat
oshi-common/src/main/java/oshi/hardware/common/platform/unix/LpstatPrinter.java, oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdHardwareAbstractionLayer.java
New LpstatPrinter class provides CUPS printer discovery by parsing lpstat -p command output without JNA dependencies; NetBsdHardwareAbstractionLayer now delegates to LpstatPrinter.getPrinters() instead of CupsPrinterJNA.
NetBSD Hardware Classes Migration to oshi-common
oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsd*.java, oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/package-info.java
Relocated all NetBSD hardware implementations (CentralProcessor, ComputerSystem, Firmware, GlobalMemory, GraphicsCard, HWDiskStore, NetworkIF, PowerSource, Sensors, SoundCard, UsbDevice, VirtualMemory) to oshi.hardware.common.platform.unix.netbsd namespace; updated imports to reference util packages in oshi.util.common.platform.unix.netbsd.
NetBSD Software/OS Classes Migration to oshi-common
oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsd*.java, oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/package-info.java
Relocated all NetBSD operating system implementations (FileSystem, InternetProtocolStats, NetworkParams, OSFileStore, OSProcess, OSThread, OperatingSystem) to oshi.software.common.os.unix.netbsd namespace; updated util imports accordingly.
NetBSD Util Classes Migration to oshi-common
oshi-common/src/main/java/oshi/util/common/platform/unix/netbsd/FstatUtil.java, oshi-common/src/main/java/oshi/util/common/platform/unix/netbsd/NetBsdSysctlUtil.java, oshi-common/src/main/java/oshi/util/common/platform/unix/netbsd/package-info.java
Relocated NetBSD utility classes (FstatUtil, NetBsdSysctlUtil) to oshi.util.common.platform.unix.netbsd namespace, supporting both hardware and software layers.
Module Configuration and Package Exports
oshi-common/src/main/java/module-info.java, oshi-core/src/main/java/module-info.java
Added exports for three relocated NetBSD packages in oshi-common; removed export of oshi.util.platform.unix.netbsd and requires java.management from oshi-core since utilities now live in oshi-common.
FFM Entry Point NetBSD Support
oshi-core-ffm/src/main/java/oshi/ffm/SystemInfo.java
Added NetBSD platform support by importing NetBSD OS and hardware implementations, adding PlatformEnum.NETBSD to SUPPORTED_PLATFORMS, and extending createOperatingSystem() and createHardware() switch statements to return NetBSD implementations.
Test Updates and Module Configuration
oshi-common/src/test/java/oshi/util/common/platform/unix/netbsd/FstatUtilTest.java, oshi-common/src/test/java/module-info.test
Updated FstatUtilTest to extract PID from ManagementFactory.getRuntimeMXBean().getName() instead of SystemInfo, removing test coupling to oshi-core; added JUnit --add-opens directives for relocated NetBSD packages.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

  • #3348: The FFM port for NetBSD is the primary objective of this PR, directly implementing NetBSD support in the FFM module with shared implementations in oshi-common.
  • #3344: Broad FFM platform coverage work; this PR implements the NetBSD portion of that effort.

Possibly related PRs

  • oshi/oshi#3330: Similar FFM SystemInfo extension adding another BSD platform via SUPPORTED_PLATFORMS and factory branches.
  • oshi/oshi#3112: Prior FFM SystemInfo dispatch changes that this PR builds on for adding NETBSD branches.
  • oshi/oshi#3310: Related NetBSD sysctl/JNA removal work; package moves here align with that refactor.

"🐰 A rabbit hops through code so clean,
NetBSD now fits the FFM scene!
Lpstat calls, no natives in sight,
Commonized packages make builds light.
Hooray—this patch makes the tree feel right!"

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR moves NetBSD to oshi-common with FFM support but does not restore JNA native calls with command-line fallback as required by issue #3347. Add JNA native calls (sysctl, getpid, getloadavg, getrlimit) with command-line fallback to the five specified NetBSD files to satisfy issue #3347 requirements.
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: moving NetBSD from oshi-core to oshi-common and integrating NetBSD into the FFM SystemInfo entry point.
Out of Scope Changes check ✅ Passed The PR includes changes within scope (NetBSD movement, FFM integration, documentation updates) plus one new LpstatPrinter class for native-free CUPS printer enumeration, which is a reasonable extension for NetBSD's native-free design and is properly integrated.

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

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

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 Jun 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.02%. Comparing base (69f0ad7) to head (810e8a7).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...i/hardware/common/platform/unix/LpstatPrinter.java 0.00% 3 Missing ⚠️
...hi-core-ffm/src/main/java/oshi/ffm/SystemInfo.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3360      +/-   ##
============================================
- Coverage     75.02%   75.02%   -0.01%     
  Complexity       76       76              
============================================
  Files           551      552       +1     
  Lines         22750    22755       +5     
  Branches       3759     3759              
============================================
+ Hits          17068    17071       +3     
+ Misses         3579     3578       -1     
- Partials       2103     2106       +3     
Flag Coverage Δ
freebsd 25.77% <0.00%> (-0.01%) ⬇️
linux 29.12% <0.00%> (+<0.01%) ⬆️
macos 29.78% <0.00%> (-0.01%) ⬇️
openbsd 25.19% <0.00%> (-0.02%) ⬇️
solaris 27.48% <0.00%> (+0.01%) ⬆️
windows 37.41% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

- oshi-common/module-info: add `requires java.management;` since
  NetBsdOperatingSystem.getProcessId() reads RuntimeMXBean. NetBSD VM
  test surfaced this — the class moved modules but its module-graph
  dependency didn't follow.
- oshi-core/module-info: drop the now-unused `requires java.management;`
  line. Nothing in oshi-core references java.lang.management anymore
  after the NetBSD move.
- FstatUtilTest: spotless re-ordered ManagementFactory into the java.*
  import block.
- CHANGELOG: shorten the NetBSD entry to match the AIX one-liner format
  and add the PR number (#3360).
@dbwiddis
dbwiddis merged commit 23a158d into oshi:master Jun 9, 2026
21 of 22 checks passed
@dbwiddis
dbwiddis deleted the netbsd-to-oshi-common branch June 9, 2026 01:01
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.

NetBSD: restore JNA native calls with command-line fallback

1 participant