Skip to content

Extend native-free provider to NetBSD and add native-free CI#3507

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:nativefree-netbsd
Jul 21, 2026
Merged

Extend native-free provider to NetBSD and add native-free CI#3507
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:nativefree-netbsd

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Jul 21, 2026

Copy link
Copy Markdown
Member

Summary

Extends the native-free provider (oshi-common alone — no JNA, no FFM, no --enable-native-access) to NetBSD, so NetBSD users without the JNA native library can depend on oshi-common directly, as Linux already can.

NetBSD's oshi-common base classes (NetBsdOperatingSystem, NetBsdHardwareAbstractionLayer, NetBsdCentralProcessor) are already fully native-free — they query sysctl/ps via the command line. The oshi-core JNA subclasses only swap in a JNA processor and native pid/tid. So the native-free provider uses the base NetBSD classes directly (unlike Linux, which needs dedicated *NF subclasses).

Changes

  • oshi.nativefree.SystemInfo: selects Linux (*NF classes) or NetBSD (base classes) by PlatformEnum; isAvailable() now covers LINUX and NETBSD.
  • SystemInfoFactory / SystemInfoProvider: refreshed the error message and priority-0 javadoc for the two-platform native-free fallback.
  • Tests: nativefree.SystemInfoTest and spi.SystemInfoFactoryTest now gate on a shared isNativeFreePlatform() helper that uses the same PlatformEnum detection as isAvailable(), so the tests can't drift from production logic.
  • Docs: README and index.md native-free row now reads "Linux and NetBSD only".
  • CI: new nativefree.yaml builds/tests oshi-common in isolation (no oshi-core/JNA, no oshi-core-ffm) — Linux on ubuntu, NetBSD in a VM without java-jna.

Testing

Both native-free CI jobs pass on my fork. The NetBSD job ran the full native-free SystemInfoTest end-to-end ("Using Native-Free (NF)", every hardware/OS check) with oshi-common alone. Local spotless, checkstyle, install, forbiddenapis, and javadoc all pass.

Not API-breaking (no interface changes; only a wider isAvailable() plus docs/CI).

Summary by CodeRabbit

  • New Features

    • Extended native-free support to NetBSD alongside Linux.
    • No --enable-native-access option is required when using the native-free implementation on supported platforms.
  • Documentation

    • Updated usage guidance, compatibility tables, and API/changelog notes to reflect NetBSD native-free support.
  • Tests

    • Added CI coverage validating native-free behavior on both Linux and NetBSD, including running the native-free test suite for oshi-common.

@coderabbitai

coderabbitai Bot commented Jul 21, 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: 855e4770-811f-4088-aa7f-4c4ad85ccfa7

📥 Commits

Reviewing files that changed from the base of the PR and between e5a6606 and cea6282.

📒 Files selected for processing (10)
  • .github/workflows/nativefree.yaml
  • CHANGELOG.md
  • README.md
  • oshi-common/src/main/java/oshi/nativefree/SystemInfo.java
  • oshi-common/src/main/java/oshi/nativefree/package-info.java
  • oshi-common/src/main/java/oshi/spi/SystemInfoFactory.java
  • oshi-common/src/main/java/oshi/spi/SystemInfoProvider.java
  • oshi-common/src/test/java/oshi/nativefree/SystemInfoTest.java
  • oshi-common/src/test/java/oshi/spi/SystemInfoFactoryTest.java
  • src/site/markdown/index.md
🚧 Files skipped from review as they are similar to previous changes (7)
  • oshi-common/src/main/java/oshi/nativefree/package-info.java
  • README.md
  • oshi-common/src/main/java/oshi/spi/SystemInfoProvider.java
  • src/site/markdown/index.md
  • CHANGELOG.md
  • .github/workflows/nativefree.yaml
  • oshi-common/src/main/java/oshi/nativefree/SystemInfo.java
📜 Recent review details
⏰ Context from checks skipped due to timeout. (12)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 26, macos-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 26, windows-latest
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2026-04-12T19:22:09.716Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:22:09.716Z
Learning: When reviewing OSHI hardware platform code that uses or implements `CentralProcessor`/`PhysicalProcessor.getEfficiency()`, remember the API’s counterintuitive semantics: a *higher* efficiency-class value indicates *greater performance* (lower efficiency). P-cores/“performance cores” should therefore have higher values (e.g., 1) than E-cores/“efficiency cores” (e.g., 0), as documented in the `CentralProcessor` Javadoc. Do not flag code as incorrect solely because ARM_P_CORES or Intel P-cores are assigned higher efficiency values.

Applied to files:

  • oshi-common/src/main/java/oshi/spi/SystemInfoFactory.java
📚 Learning: 2026-07-06T19:25:59.225Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:25:59.225Z
Learning: In this repo’s SLF4J 1.x-compatible logging code, do not flag cases where a logger call uses SLF4J 1.6+ implicit-cause handling—e.g., `log.error("...{}", value, t)` (or similar with a single `{}` placeholder) where `t` is passed as the final/trailing argument. SLF4J will attach `t` as the log event’s cause with the full stack trace; this is equivalent to SLF4J 2.x’s fluent `atLevel(...).setCause(t).log(...)` and is intentionally used to preserve SLF4J 1.x runtime compatibility.

Applied to files:

  • oshi-common/src/main/java/oshi/spi/SystemInfoFactory.java
🔇 Additional comments (3)
oshi-common/src/main/java/oshi/spi/SystemInfoFactory.java (1)

50-68: LGTM!

oshi-common/src/test/java/oshi/nativefree/SystemInfoTest.java (1)

35-64: LGTM!

oshi-common/src/test/java/oshi/spi/SystemInfoFactoryTest.java (1)

13-42: LGTM!


📝 Walkthrough

Walkthrough

The native-free oshi-common provider now supports Linux and NetBSD through platform-specific OS and hardware factories. Tests, documentation, changelog content, and GitHub Actions coverage were updated accordingly.

Changes

Native-free NetBSD support

Layer / File(s) Summary
Platform-aware provider dispatch
oshi-common/src/main/java/oshi/nativefree/SystemInfo.java, oshi-common/src/main/java/oshi/nativefree/package-info.java, oshi-common/src/main/java/oshi/spi/*
SystemInfo dispatches native-free OS and hardware implementations for Linux and NetBSD, and provider documentation describes priority 0 as the native-free fallback.
Platform-aware provider tests
oshi-common/src/test/java/oshi/nativefree/SystemInfoTest.java, oshi-common/src/test/java/oshi/spi/SystemInfoFactoryTest.java
Tests derive conditional execution from native-free provider availability and cover supported and unsupported provider selection.
NetBSD validation and documentation
.github/workflows/nativefree.yaml, README.md, src/site/markdown/index.md, CHANGELOG.md
Native-free tests run on Linux and NetBSD, and platform coverage is updated in project documentation and the changelog.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SystemInfoFactory
  participant NativeFreeSystemInfo
  participant PlatformEnum
  SystemInfoFactory->>NativeFreeSystemInfo: create native-free provider
  NativeFreeSystemInfo->>PlatformEnum: getCurrentPlatform()
  PlatformEnum-->>NativeFreeSystemInfo: LINUX or NETBSD
  NativeFreeSystemInfo->>NativeFreeSystemInfo: create platform-specific OS and hardware
Loading

Possibly related PRs

  • oshi/oshi#3234: Added related native-free provider selection behavior.
  • oshi/oshi#3238: Introduced the Linux native-free provider expanded here to NetBSD.
  • oshi/oshi#3365: Added related native-free provider factory behavior and tests.

Poem

A bunny hops where Linux runs,
Then NetBSD joins the sunny fun.
Native-free paths now bloom,
Tests leap lightly through the room.
“No native flags!” the rabbit sings.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the two main changes: NetBSD support for the native-free provider and new native-free CI coverage.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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.

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 35.71429% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.16%. Comparing base (2ac7fd9) to head (cea6282).

Files with missing lines Patch % Lines
...mmon/src/main/java/oshi/nativefree/SystemInfo.java 35.71% 6 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3507      +/-   ##
============================================
- Coverage     77.00%   72.16%   -4.84%     
  Complexity       76       76              
============================================
  Files           660      660              
  Lines         23347    23358      +11     
  Branches       3888     3889       +1     
============================================
- Hits          17978    16856    -1122     
- Misses         3292     4535    +1243     
+ Partials       2077     1967     -110     
Flag Coverage Δ
aix ?
freebsd 31.04% <21.42%> (+<0.01%) ⬆️
linux 35.10% <35.71%> (+<0.01%) ⬆️
macos 36.14% <21.42%> (-0.06%) ⬇️
openbsd 30.24% <21.42%> (-0.04%) ⬇️
solaris 31.59% <21.42%> (-0.01%) ⬇️
windows 43.54% <21.42%> (-0.02%) ⬇️

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.

NetBSD's oshi-common base classes (NetBsdOperatingSystem,
NetBsdHardwareAbstractionLayer) are already fully native-free, querying
sysctl/ps via the command line; the oshi-core JNA subclasses only swap in
a JNA processor and native pid/tid. So the native-free provider can use the
base NetBSD classes directly, letting NetBSD users without the JNA native
library depend on oshi-common alone, as Linux already does.

- oshi.nativefree.SystemInfo now selects Linux (*NF classes) or NetBSD (base
  classes) by PlatformEnum; isAvailable() covers LINUX and NETBSD.
- Refresh SystemInfoFactory error/javadoc and SystemInfoProvider priority-0
  javadoc for the two-platform native-free fallback.
- Gate nativefree SystemInfoTest and SystemInfoFactoryTest on a shared
  isNativeFreePlatform() helper using the same PlatformEnum detection as
  isAvailable(), so tests can't drift from production logic.
- README and index.md: native-free row now "Linux and NetBSD only".
- New nativefree.yaml CI builds/tests oshi-common in isolation (no
  oshi-core/JNA, no oshi-core-ffm): Linux on ubuntu, NetBSD in a VM without
  java-jna.
@dbwiddis
dbwiddis force-pushed the nativefree-netbsd branch from e5a6606 to cea6282 Compare July 21, 2026 16:59
@dbwiddis
dbwiddis merged commit 7248cf3 into oshi:master Jul 21, 2026
19 checks passed
@dbwiddis
dbwiddis deleted the nativefree-netbsd branch July 21, 2026 17:07
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