Skip to content

FreeBSD Port: FFM concretes for the remaining HAL/OS surface - #3328

Merged
dbwiddis merged 9 commits into
oshi:masterfrom
dbwiddis:freebsd-ffm
Jun 4, 2026
Merged

dbwiddis merged 9 commits into
oshi:masterfrom
dbwiddis:freebsd-ffm

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Jun 4, 2026 •

Copy link
Copy Markdown
Member

Summary

Phase 5 of the FreeBSD FFM port (tracking #3315). Lands the six
remaining FreeBsd*FFM concretes (FileSystem, InternetProtocolStats,
PowerSource, HWDiskStore, OperatingSystem, OSProcess) plus the
aggregate FreeBsdHardwareAbstractionLayerFFM bookend, finishing the
HAL/OS implementation. FFM SystemInfo still reports FreeBSD as
unsupported — wiring waits for Phase 6.

Per-commit walk

  1. Phase 5 commit 1 — FreeBsdFileSystemFFM (trivial mirror,
    kern.openfiles + kern.maxfiles via BsdSysctlUtilFFM). Folds
    in three Sonar findings from PR FreeBSD Port: FFM concretes for Memory/Sensors/Network/CPU #3322's review cycle:
    HOST_NAME_MAX + 1 widened to long in FreeBsdNetworkParamsFFM
    (S2184), and two .longValue() unboxes removed in DisklabelTest
    (S2153). A fourth Sonar finding (CPUMASK regex S5998 in
    FreeBsdCentralProcessorFFM) was triaged as a false positive — the
    comma anchor between alternatives prevents catastrophic
    backtracking, and input is bounded kernel-controlled sysctl output.
  2. Phase 5 commit 2 — FreeBsdInternetProtocolStatsFFM. Memoizes
    the net.inet.tcp.stats / net.inet.udp.stats raw buffers from
    BsdSysctlUtilFFM.sysctl(name) directly instead of materializing
    an intermediate BsdTcpstat / BsdUdpstat holder the way the JNA
    sibling does — FFM lets us pull each field out at offset on demand.
  3. Phase 5 commit 3 — FreeBsdPowerSourceFFM. Three
    hw.acpi.battery.* sysctl reads + acpiconf -i 0 parsing.
  4. Phase 5 commit 4 — FreeBsdHWDiskStoreFFM. One sysctl read
    (kern.disks) + iostat -Ix parsing + the pure-Java
    GeomDiskList / GeomPartList drivers in oshi-common from Phase 2.
  5. Phase 5 commit 5 — FreeBsdOperatingSystemFFM +
    FreeBsdOSProcessFFM (they're circularly dependent, so they land
    together). Extends FreeBsdLibcFunctions with four new bindings:
    getpid, thr_self, sysctl (int-MIB form with errno capture
    for kern.proc.* queries), and getrlimit + RLIMIT_LAYOUT (two
    longs) + RLIMIT_NOFILE = 8 (the FreeBSD value, not Linux's 7).
    Hoists ProcstatUtil (oshi-core/oshi.util.platform.unix.freebsd)
    to oshi-common (oshi.util.common.platform.unix.freebsd) per the
    Phase 2 pattern; both modules now import it from the common path.
    The live test now derives the PID from ManagementFactory rather
    than oshi.SystemInfo so it can live in oshi-common.
  6. Phase 5 commit 6 — FreeBsdHardwareAbstractionLayerFFM
    bookend. Wires the FFM concretes from Phases 4–5; pure-Java
    BSD-shared classes (UnixDisplay, BsdNetworkIF, FreeBsd* for
    graphics/sound/USB) come from oshi-common. Hoists BsdNetworkIF
    (oshi-core/oshi.hardware.platform.unix) to
    oshi-common/oshi.hardware.common.platform.unix, mirroring Phase
    2's treatment of the other pure-Java BSD hardware classes; the
    three JNA HALs that consumed it (FreeBSD, OpenBSD, DragonFlyBSD)
    pick up the new import path with no behavior change.

Intentionally deferred

  • FFM SystemInfo factory wiring — Phase 6. Keeps the
    half-built state hidden until everything is in place.
    NativeComparisonTest stays gated to {LINUX, MAC, WINDOWS}.
  • Tests for the new FFM concretes — none committed. Per the
    testing pattern established in FreeBSD Port: FFM libc bindings + sysctl util + WhoFFM driver #3319 commit 3, Phase 6's
    NativeComparisonTest HAL/OS traversal will cover all of these
    transitively through the public API once SystemInfo wires
    FreeBSD in.

Test plan

  • ./mvnw clean compile across oshi-common, oshi-core,
    oshi-core-ffm on each commit
  • ./mvnw test — 749 (common) + 121 (core) + 68 (core-ffm) tests
    pass on Mac; FreeBSD-only tests skip as expected
  • ./mvnw spotless:check checkstyle:check clean on each module
  • Temporary FreeBSD CI green on the final tip commit (one earlier
    commit hit a flaky testFileSystem "total space should not
    change" race in oshi-core's JNA test suite — unrelated to FFM)
  • PR CI: existing testfreebsd job in pr.yaml will exercise
    the codebase under flags: freebsd

Tracks #3315.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a comprehensive FreeBSD FFM backend: hardware monitoring (disks, sensors, power), process/thread management, network protocol stats, filesystem and libc-backed OS queries.
  • Refactor

    • Reorganized FreeBSD/common platform packages and updated module exports to expose FreeBSD utility package.
  • Bug Fixes

    • Treat 0% battery as a valid flat battery reading.
  • Tests

    • Updated FreeBSD tests and PID derivation in procstat tests.

dbwiddis and others added 6 commits June 3, 2026 20:11
FreeBsdFileSystemFFM mirrors FreeBsdFileSystemJNA — two trivial
overrides for kern.openfiles / kern.maxfiles via BsdSysctlUtilFFM.

Folds in three Sonar findings from PR #3322:
* FreeBsdNetworkParamsFFM (S2184): widen HOST_NAME_MAX + 1 to long for
  the arena allocate call to match the gethostname argument on the
  next line, keeping both arithmetic paths in 64-bit math.
* DisklabelTest x2 (S2153): drop the unnecessary .longValue() unboxing
  from assertThat(diskdata.getC()…) in the OpenBSD and NetBSD live
  smoke tests — Hamcrest's greaterThanOrEqualTo(0L) works on the Long
  directly, the unbox-then-rebox roundtrip is wasted work.

The CPUMASK regex S5998 finding in FreeBsdCentralProcessorFFM (and its
JNA sibling) was reviewed and marked false positive: the comma anchor
between alternatives prevents catastrophic backtracking, and input is
bounded kernel-controlled sysctl output.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Mirror of FreeBsdInternetProtocolStatsJNA. Reads net.inet.tcp.stats
and net.inet.udp.stats via BsdSysctlUtilFFM.sysctl(name), returning
the auto-arena MemorySegment, then memoizes the segment itself
(instead of an intermediate BsdTcpstat / BsdUdpstat struct as the JNA
sibling does — FFM lets us pull fields out at offset on demand, so
the extra holder type isn't needed).

Established-connection counts continue to come from the shared
NetStat command-line driver. Field offsets and the
ParseUtil.unsignedIntToLong widening match the JNA layout exactly.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Mirror of FreeBsdPowerSourceJNA — three hw.acpi.battery.* sysctl reads
(state/time/life) via BsdSysctlUtilFFM, then acpiconf -i 0 parsing for
the richer device fields. Constructor signature and the heavy-but-
straightforward command-output parsing are byte-identical to the JNA
sibling.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Mirror of FreeBsdHWDiskStoreJNA. One native read (kern.disks via
BsdSysctlUtilFFM); everything else is pure-Java parsing of iostat -Ix
plus the GeomDiskList / GeomPartList drivers in oshi-common (hoisted
in Phase 2).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The two classes are circularly dependent (OS constructs OSProcess,
OSProcess holds the OS reference for the rlimit-of-self path), so they
land together with all the libc bindings they share.

* FreeBsdLibcFunctions gains: getpid, thr_self, sysctl (int-MIB form
  with errno capture), getrlimit + RLIMIT_LAYOUT (two longs, matching
  FreeBSD's struct rlimit) + RLIMIT_NOFILE = 8 (FreeBSD's value,
  not Linux's 7). rlimitCur/rlimitMax accessor helpers.

* FreeBsdOSProcessFFM mirrors FreeBsdOSProcessJNA. Static ARGMAX read
  via BsdSysctlUtilFFM at class init; queryArguments / queryEnvironmentVariables
  / queryBitness via sysctl int-MIB (CTL_KERN=1, KERN_PROC=14, with
  KERN_PROC_ARGS=7 / KERN_PROC_ENV=35 / KERN_PROC_SV_NAME=9 leaves);
  getSoftOpenFileLimit / getHardOpenFileLimit via getrlimit(RLIMIT_NOFILE)
  for the calling process, falling back to /proc/<pid>/limits parsing
  for others (same as JNA).

* FreeBsdOperatingSystemFFM mirrors FreeBsdOperatingSystemJNA. Wires
  the FFM siblings (FreeBsdFileSystemFFM, FreeBsdInternetProtocolStatsFFM,
  FreeBsdNetworkParamsFFM, FreeBsdOSProcessFFM); sessions go through
  WhoFFM.queryUtxent() (Phase 3); getProcessId / getThreadId use the
  new getpid / thr_self bindings; querySystemBootTime reads kern.boottime
  as a 16-byte struct via BsdSysctlUtilFFM.sysctl(name, segment),
  parsing the tv_sec long out of the result.

* Hoists ProcstatUtil (oshi-core/oshi.util.platform.unix.freebsd) to
  oshi-common (oshi.util.common.platform.unix.freebsd) per the Phase 2
  pattern, since both JNA OSProcess and the new FFM OSProcess need it
  and the original package is split (it also contains BsdSysctlUtil
  which is JNA-tied). FreeBsdOSProcessJNA import updated; the pure-
  parsing tests come along, and the live test now derives the current
  PID from ManagementFactory rather than oshi.SystemInfo (which lives
  in the JNA module and isn't visible from oshi-common). Module-info
  exports + add-opens updated to match.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Aggregate FFM HAL. Wires the FreeBsd*FFM concretes from Phases 4–5
(ComputerSystem, GlobalMemory, CentralProcessor, Sensors, PowerSource,
HWDiskStore, Cups printer) and reuses the pure-Java BSD-shared classes
(UnixDisplay, BsdNetworkIF, FreeBsdGraphicsCard / SoundCard / UsbDevice)
that already live in oshi-common.

Hoists BsdNetworkIF (oshi-core/oshi.hardware.platform.unix) to
oshi-common (oshi.hardware.common.platform.unix), mirroring the Phase 2
treatment of FreeBsdGraphicsCard / SoundCard / UsbDevice etc. The class
is pure-Java already (just ExecutingCommand + netstat parsing); it was
just stranded in the JNA module because Phase 2 didn't touch the BSD
network path. Both DragonFlyBsdHardwareAbstractionLayer and
FreeBsdHardwareAbstractionLayerJNA pick up the new import path; no
behavior change.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 4, 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: cf70f17b-fc12-4a42-a5a6-0d599781dc12

📥 Commits

Reviewing files that changed from the base of the PR and between 7460bae and 1793b45.

📒 Files selected for processing (1)
  • .github/workflows/unix.yaml
💤 Files with no reviewable changes (1)
  • .github/workflows/unix.yaml
📜 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). (13)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Analyze (java)
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 26, windows-latest
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 26, macos-latest
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: JMH Benchmarks, ubuntu-latest
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)

📝 Walkthrough

Walkthrough

Hoists FreeBSD utilities into oshi-common and exports the new FreeBSD package; adds FFM libc bindings; implements FFM-backed FreeBSD HAL, disk, power, filesystem, network/protocol stats, process/OS classes; and updates imports/tests.

Changes

FreeBSD FFM Implementation

Layer / File(s) Summary
Package reorganization and module exports
oshi-common/src/main/java/module-info.java, oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdNetworkIF.java, oshi-common/src/main/java/oshi/util/common/platform/unix/freebsd/ProcstatUtil.java, oshi-common/src/main/java/oshi/util/common/platform/unix/freebsd/package-info.java, oshi-common/src/test/java/module-info.test, oshi-common/src/test/java/oshi/util/common/platform/unix/freebsd/ProcstatUtilTest.java
Relocates BsdNetworkIF and ProcstatUtil into oshi.common packages, adds exports for oshi.util.common.platform.unix.freebsd, adds package-info, updates test module access (--add-opens/--add-reads java.management), and changes ProcstatUtilTest PID derivation to use ManagementFactory + ParseUtil.
FFM libc bindings for FreeBSD
oshi-core-ffm/src/main/java/oshi/ffm/unix/freebsd/FreeBsdLibcFunctions.java
Adds RLIMIT_NOFILE and RLIMIT struct layout/VarHandles, and FFM downcalls/wrappers for getpid, thr_self, int-MIB sysctl with errno capture, and getrlimit, plus rlimitCur/rlimitMax accessors.
FFM HAL, disk store, and power source
oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHardwareAbstractionLayerFFM.java, oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHWDiskStoreFFM.java, oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdPowerSourceFFM.java
Adds FreeBsdHardwareAbstractionLayerFFM wiring to FFM implementations; FreeBsdHWDiskStoreFFM parses iostat -Ix for per-disk I/O metrics and enumerates disks via sysctl kern.disks/geom; FreeBsdPowerSourceFFM reads hw.acpi.battery.* and acpiconf to populate battery fields.
FFM OS, processes, network & filesystem
oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdFileSystemFFM.java, oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStatsFFM.java, oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdNetworkParamsFFM.java, oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcessFFM.java, oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOperatingSystemFFM.java
Adds FFM-backed OS components: filesystem open/max files via sysctl; TCP/UDP stats from net.inet.*.stats sysctl buffers; hostname buffer allocation fix; FreeBsdOSProcessFFM implementing proc attributes, lazy sysctl arg/env, affinity, limits, bitness; FreeBsdOperatingSystemFFM orchestrates ps-based process enumeration, boot time from kern.boottime, and service discovery.
Import reorganization and test fixes
oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java, oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHardwareAbstractionLayerJNA.java, oshi-core/src/main/java/oshi/hardware/platform/unix/openbsd/OpenBsdHardwareAbstractionLayer.java, oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcessJNA.java, oshi-core/src/test/java/oshi/driver/unix/bsd/disk/DisklabelTest.java, oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdPowerSourceJNA.java, .github/workflows/unix.yaml
Reorders and groups imports for consistency across BSD/JNA classes, adjusts DisklabelTest assertions to compare primitive long values directly, changes battery life handling to treat life >= 0 as valid, and trims an EOF whitespace artifact in CI workflow.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

  • FFM port for FreeBSD #3315: Implementation work for the FreeBSD FFM port (package hoisting and FFM-backed classes) matches the objectives described in this issue.

Possibly related PRs

  • oshi/oshi#3319: Modifies FreeBsdLibcFunctions FFM bindings—directly related to libc/sysctl additions in this PR.
  • oshi/oshi#3312: Refactors ProcstatUtil parsing helpers—related to the relocated ProcstatUtil in this PR.
  • oshi/oshi#3130: Prior work creating oshi-common module and moving APIs that this PR builds upon.

Suggested reviewers

  • rohan-coder02

Poem

"🐰 I hopped through sysctl and ps lines,
moved helpers to a common den,
wired FFM calls and parsed the signs,
counted bytes and threads again,
a tiny rabbit cheers the FreeBSD men!"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% 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 'FreeBSD Port: FFM concretes for the remaining HAL/OS surface' directly and specifically describes the main change: implementing FreeBSD FFM concrete classes for the Hardware Abstraction Layer and OS surface.
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.

✏️ 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 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 435 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.11%. Comparing base (cde1e07) to head (1793b45).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
.../software/os/unix/freebsd/FreeBsdOSProcessFFM.java 0.00% 177 Missing ⚠️
...are/os/unix/freebsd/FreeBsdOperatingSystemFFM.java 0.00% 86 Missing ⚠️
...e/platform/unix/freebsd/FreeBsdPowerSourceFFM.java 0.00% 70 Missing ⚠️
...e/platform/unix/freebsd/FreeBsdHWDiskStoreFFM.java 0.00% 45 Missing ⚠️
.../unix/freebsd/FreeBsdInternetProtocolStatsFFM.java 0.00% 39 Missing ⚠️
...ix/freebsd/FreeBsdHardwareAbstractionLayerFFM.java 0.00% 13 Missing ⚠️
...software/os/unix/freebsd/FreeBsdFileSystemFFM.java 0.00% 3 Missing ⚠️
...tware/os/unix/freebsd/FreeBsdNetworkParamsFFM.java 0.00% 1 Missing ⚠️
...e/platform/unix/freebsd/FreeBsdPowerSourceJNA.java 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3328      +/-   ##
============================================
- Coverage     75.00%   73.11%   -1.90%     
  Complexity       76       76              
============================================
  Files           455      462       +7     
  Lines         17492    17925     +433     
  Branches       2872     2928      +56     
============================================
- Hits          13120    13105      -15     
- Misses         2780     3220     +440     
- Partials       1592     1600       +8     
Flag Coverage Δ
freebsd 29.99% <0.00%> (-0.74%) ⬇️
linux 36.83% <0.00%> (-0.87%) ⬇️
macos 37.08% <0.00%> (-0.92%) ⬇️
windows 44.10% <0.00%> (-1.22%) ⬇️

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@oshi-common/src/test/java/oshi/util/common/platform/unix/freebsd/ProcstatUtilTest.java`:
- Around line 92-95: The test currently parses
ManagementFactory.getRuntimeMXBean().getName() into a PID via
ParseUtil.parseIntOrDefault and falls back to 0; change this to fail fast if
parsing doesn't produce a valid PID by using an impossible sentinel (e.g., -1)
and asserting the PID is positive before calling ProcstatUtil.getOpenFiles(pid).
Update ProcstatUtilTest to parse the PID with ParseUtil.parseIntOrDefault(...,
-1), add an assertion that the parsed pid > 0 (or fail the test with a clear
message referencing RuntimeMXBean#getName()), and only then call
ProcstatUtil.getOpenFiles(pid).

In
`@oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdPowerSourceFFM.java`:
- Around line 88-91: In FreeBsdPowerSourceFFM, the code reading
hw.acpi.battery.life uses "if (life > 0)" which leaves
psRemainingCapacityPercent at its default 1.0 when life == 0; change the
condition in the block that handles the sysctl result (the variable life from
BsdSysctlUtilFFM.sysctl and the assignment to psRemainingCapacityPercent) to use
">= 0" so a reported 0 value correctly sets psRemainingCapacityPercent = life /
100d (yielding 0.0) instead of leaving it at 1.0.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 30f2c84b-e54a-450b-9b36-468d80b50150

📥 Commits

Reviewing files that changed from the base of the PR and between cde1e07 and d0ee06b.

📒 Files selected for processing (20)
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdNetworkIF.java
  • oshi-common/src/main/java/oshi/util/common/platform/unix/freebsd/ProcstatUtil.java
  • oshi-common/src/main/java/oshi/util/common/platform/unix/freebsd/package-info.java
  • oshi-common/src/test/java/module-info.test
  • oshi-common/src/test/java/oshi/util/common/platform/unix/freebsd/ProcstatUtilTest.java
  • oshi-core-ffm/src/main/java/oshi/ffm/unix/freebsd/FreeBsdLibcFunctions.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHWDiskStoreFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHardwareAbstractionLayerFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdPowerSourceFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStatsFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdNetworkParamsFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOperatingSystemFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHardwareAbstractionLayerJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/openbsd/OpenBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcessJNA.java
  • oshi-core/src/test/java/oshi/driver/unix/bsd/disk/DisklabelTest.java
📜 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). (11)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Analyze (java)
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: JMH Benchmarks, ubuntu-latest
  • GitHub Check: Test JDK 26, macos-latest
  • GitHub Check: Test JDK 26, windows-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
🧰 Additional context used
🧠 Learnings (16)
📓 Common learnings
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.
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3310
File: oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdOperatingSystem.java:164-166
Timestamp: 2026-05-31T04:49:16.646Z
Learning: In the oshi/oshi project, the NetBSD platform intentionally removes all JNA/native library dependencies (PR `#3310`). `NetBsdOperatingSystem.getThreadId()` uses `(int) Thread.currentThread().getId()` rather than `NetBsdLibc._lwp_self()` because the JNA native library is not bundled with the Maven dependency for the NetBSD platform. The mismatch between Java thread ids and kernel LWP ids is an accepted trade-off. Do not suggest reintroducing JNA-based calls (such as `NetBsdLibc._lwp_self()`) in NetBSD platform code.
📚 Learning: 2026-04-03T18:44:48.200Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3112
File: oshi-core/src/main/java/oshi/PlatformEnum.java:63-66
Timestamp: 2026-04-03T18:44:48.200Z
Learning: In oshi/oshi PlatformEnum.java, the DRAGONFLYBSD enum constant is intentionally added for platform detection only (no implementation classes exist yet). It allows UnsupportedOperationException messages to say "DragonFly BSD" rather than "Unknown". Full DragonFly BSD support is tracked in issue `#2583`. Do not flag the missing switch-case implementations as a bug.

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHardwareAbstractionLayerJNA.java
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/test/java/oshi/util/common/platform/unix/freebsd/ProcstatUtilTest.java
  • oshi-common/src/main/java/oshi/util/common/platform/unix/freebsd/package-info.java
  • oshi-common/src/main/java/oshi/util/common/platform/unix/freebsd/ProcstatUtil.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHardwareAbstractionLayerFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdPowerSourceFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOperatingSystemFFM.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-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/openbsd/OpenBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHardwareAbstractionLayerJNA.java
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/test/java/oshi/util/common/platform/unix/freebsd/ProcstatUtilTest.java
  • oshi-common/src/main/java/oshi/util/common/platform/unix/freebsd/package-info.java
  • oshi-common/src/main/java/oshi/util/common/platform/unix/freebsd/ProcstatUtil.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdNetworkIF.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcessJNA.java
  • oshi-common/src/test/java/module-info.test
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHardwareAbstractionLayerFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdPowerSourceFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOperatingSystemFFM.java
📚 Learning: 2026-04-03T18:43:51.290Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3112
File: oshi-core/src/main/java/oshi/PlatformEnum.java:99-100
Timestamp: 2026-04-03T18:43:51.290Z
Learning: In oshi/oshi PlatformEnum.java, the DragonFly BSD detection uses `osName.equalsIgnoreCase("dragonflybsd")` intentionally, mirroring the exact same check in JNA's `Platform.java` source. Java's `os.name` property on DragonFly BSD is "dragonflybsd" (no space), so `startsWith("DragonFly")` is NOT the correct pattern here. Do not suggest changing it to `startsWith`.

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java
  • oshi-common/src/test/java/oshi/util/common/platform/unix/freebsd/ProcstatUtilTest.java
  • oshi-common/src/main/java/oshi/util/common/platform/unix/freebsd/package-info.java
  • oshi-common/src/main/java/oshi/util/common/platform/unix/freebsd/ProcstatUtil.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/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/openbsd/OpenBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHardwareAbstractionLayerJNA.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcessJNA.java
📚 Learning: 2026-05-31T04:49:16.646Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3310
File: oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdOperatingSystem.java:164-166
Timestamp: 2026-05-31T04:49:16.646Z
Learning: In the oshi/oshi project, the NetBSD platform intentionally removes all JNA/native library dependencies (PR `#3310`). `NetBsdOperatingSystem.getThreadId()` uses `(int) Thread.currentThread().getId()` rather than `NetBsdLibc._lwp_self()` because the JNA native library is not bundled with the Maven dependency for the NetBSD platform. The mismatch between Java thread ids and kernel LWP ids is an accepted trade-off. Do not suggest reintroducing JNA-based calls (such as `NetBsdLibc._lwp_self()`) in NetBSD platform code.

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/openbsd/OpenBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHardwareAbstractionLayerJNA.java
  • oshi-common/src/test/java/oshi/util/common/platform/unix/freebsd/ProcstatUtilTest.java
  • oshi-common/src/main/java/oshi/util/common/platform/unix/freebsd/package-info.java
  • oshi-common/src/main/java/oshi/util/common/platform/unix/freebsd/ProcstatUtil.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcessJNA.java
  • oshi-core-ffm/src/main/java/oshi/ffm/unix/freebsd/FreeBsdLibcFunctions.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOperatingSystemFFM.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-common/src/main/java/module-info.java
  • oshi-common/src/main/java/oshi/util/common/platform/unix/freebsd/package-info.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdNetworkIF.java
  • oshi-common/src/test/java/module-info.test
📚 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/module-info.java
  • oshi-common/src/main/java/oshi/util/common/platform/unix/freebsd/package-info.java
  • oshi-common/src/main/java/oshi/util/common/platform/unix/freebsd/ProcstatUtil.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdNetworkIF.java
📚 Learning: 2026-04-18T03:18:06.205Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:06.205Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).

Applied to files:

  • oshi-common/src/test/java/oshi/util/common/platform/unix/freebsd/ProcstatUtilTest.java
📚 Learning: 2026-04-19T01:28:47.155Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3174
File: oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java:237-257
Timestamp: 2026-04-19T01:28:47.155Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`, the WMI comparison tests (e.g., `testProcessor`) intentionally validate only index 0 and a few representative fields per WMI data type (String, uint16, uint32, uint64). Exhaustive row-by-row comparison is deliberately avoided for numerically heavy multi-row tables. The design rationale is: matching row counts + a few selected fields covering each data type is sufficient to verify JNA vs FFM driver parity. Do not suggest looping over all rows for these tests.

Applied to files:

  • oshi-common/src/test/java/oshi/util/common/platform/unix/freebsd/ProcstatUtilTest.java
📚 Learning: 2026-04-10T22:44:36.786Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3136
File: oshi-core-java25/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java:46-53
Timestamp: 2026-04-10T22:44:36.786Z
Learning: In OSHI's `AuxvFFM.queryAuxv()` (oshi-core-java25/src/main/java/oshi/driver/linux/proc/AuxvFFM.java), the do-while loop is safe even when `/proc/self/auxv` cannot be read: `FileUtil.readAllBytesAsBuffer` returns an empty ByteBuffer on failure, and `FileUtil.readLongFromBuffer`/`readIntFromBuffer` return 0L when reading past the buffer limit. This 0L equals AT_NULL, causing the loop to exit immediately with an empty map, which triggers the `getconf`/hardcoded-default fallback in callers like `LinuxOperatingSystemFFM`. Do not flag this do-while loop or the static initializer that calls `AuxvFFM.queryAuxv()` as unsafe.

Applied to files:

  • oshi-common/src/test/java/oshi/util/common/platform/unix/freebsd/ProcstatUtilTest.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcessFFM.java
📚 Learning: 2026-04-03T02:07:49.467Z
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:49.467Z
Learning: In `oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHWDiskStoreFFM.java` (and similar FFM/API implementations in OSHI), the `updateAttributes()` method intentionally uses `catch (Throwable e) { return false; }` without logging. This is by design: `updateAttributes()` is a public API method whose contract is to return `false` on failure; callers consume the boolean and would never see log output, so adding a log statement is not desired.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHWDiskStoreFFM.java
📚 Learning: 2026-04-17T23:43:35.860Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java:0-0
Timestamp: 2026-04-17T23:43:35.860Z
Learning: In `oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java`, the `PDH_RAW_COUNTER_LAYOUT` Java FFM struct layout must place `FirstValue` at byte offset 16 (not 12). The native MSVC compiler inserts 4 bytes of implicit alignment padding before the `LONGLONG FirstValue` field (after CStatus=4 bytes + FILETIME TimeStamp=8 bytes = 12 bytes), because LONGLONG requires 8-byte alignment. The total struct size is 40 bytes (with trailing padding). Do not use JAVA_LONG_UNALIGNED without explicit padding here, as that incorrectly places FirstValue at offset 12 and causes reads of garbage counter values.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStatsFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/unix/freebsd/FreeBsdLibcFunctions.java
📚 Learning: 2026-04-08T00:58:10.736Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3125
File: oshi-core-java25/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java:131-133
Timestamp: 2026-04-08T00:58:10.736Z
Learning: In `oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceJNA.java` and `oshi-core-java25/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java`, the `getPowerSources()` method intentionally returns a singleton list wrapping a single `getPowerSource("System Battery")` call, and the enumeration loop short-circuits after the first eligible battery pack. This matches the longstanding JNA behavior and is not a bug. A broader refactor to support zero-or-more batteries across both implementations is planned for a later date. Do not flag this as an issue.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdPowerSourceFFM.java
📚 Learning: 2026-03-29T20:03:00.830Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java:87-89
Timestamp: 2026-03-29T20:03:00.830Z
Learning: In the OSHI FFM codebase (oshi-core-java25), all PDH/Kernel32/COM wrapper methods in classes like PdhFFM, Kernel32FFM, etc. declare `throws Throwable` solely as a compiler artifact of `MethodHandle.invokeExact`. They are native calls and do not throw Java checked exceptions in practice. The enclosing `getOpenFileDescriptors()` method in PdhUtilFFM already has an outer `catch (Throwable t)` that covers the entire method body including any `finally` blocks, so no exception-masking concern exists for cleanup calls like `PdhCloseQuery` in `finally`.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/ffm/unix/freebsd/FreeBsdLibcFunctions.java
📚 Learning: 2026-05-04T04:58:36.843Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3227
File: oshi-metrics/src/main/java/oshi/metrics/OshiMetrics.java:35-48
Timestamp: 2026-05-04T04:58:36.843Z
Learning: In `oshi-metrics/src/main/java/oshi/metrics/OshiMetrics.java`, the `private final OperatingSystem os` field is intentionally stored in the constructor even though it is not yet used. It is a placeholder for future OS-level metrics (e.g., process metrics) that will be added incrementally. Do not flag it as dead code.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOperatingSystemFFM.java
🔇 Additional comments (17)
oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java (1)

23-23: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHardwareAbstractionLayerJNA.java (1)

23-23: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/unix/openbsd/OpenBsdHardwareAbstractionLayer.java (1)

23-23: LGTM!

oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcessJNA.java (1)

46-46: LGTM!

oshi-core/src/test/java/oshi/driver/unix/bsd/disk/DisklabelTest.java (1)

175-175: LGTM!

Also applies to: 194-194

oshi-core-ffm/src/main/java/oshi/ffm/unix/freebsd/FreeBsdLibcFunctions.java (2)

41-52: LGTM!


337-424: LGTM!

oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHardwareAbstractionLayerFFM.java (1)

34-96: LGTM!

oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHWDiskStoreFFM.java (1)

32-108: LGTM!

oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdPowerSourceFFM.java (1)

30-55: LGTM!

Also applies to: 56-148

oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdFileSystemFFM.java (1)

15-27: LGTM!

oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStatsFFM.java (1)

27-93: LGTM!

oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcessFFM.java (2)

57-105: LGTM!

Also applies to: 107-298, 300-354, 356-443, 445-463


428-430: ⚡ Quick win

Reconsider the startTime time-unit mismatch claim: startTime = now - this.upTime is consistent because getUpTime() is treated as milliseconds across the codebase (e.g., ProcessMetrics converts it to seconds by dividing by MS_PER_SECOND), so subtracting from System.currentTimeMillis() is correct.

			> Likely an incorrect or invalid review comment.
oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOperatingSystemFFM.java (2)

51-66: LGTM!

Also applies to: 68-105, 107-162, 175-214, 216-246


164-173: ⚡ Quick win

Fix not needed: thr_self error check is correct
FreeBSD thr_self(2) returns 0 on success and -1 on failure, so the existing thr_self(id) < 0 check will correctly detect errors; removing/updating it as proposed isn’t required.

			> Likely an incorrect or invalid review comment.
oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdNetworkParamsFFM.java (1)

64-65: LGTM!

dbwiddis and others added 3 commits June 3, 2026 23:09
Both findings verified against current code; both still valid.

1. ProcstatUtilTest live-test PID parse defaulted to 0 on failure,
   which would silently pass 0 to ProcstatUtil.getOpenFiles and let
   the rest of the live assertions run against a meaningless PID.
   Switched the default to -1 and added an upfront
   assertThat(pid, is(greaterThan(0))) so a platform that doesn't
   follow RuntimeMXBean#getName()'s "pid@host" convention fails fast
   with a clear message instead of producing confusing downstream
   failures.

2. FreeBsdPowerSourceFFM/JNA: hw.acpi.battery.life uses -1 as the
   sysctl-failure sentinel and the kernel returns 0–100 for a real
   reading. The "life > 0" check left psRemainingCapacityPercent at
   its default 1.0 when life was a legitimate 0 (battery flat),
   reporting a discharged battery as fully charged. Both FFM and JNA
   copies switch to ">= 0" so genuine 0 readings drive the percent to
   0.0; -1 still falls through and keeps the 1.0 default. Lockstep
   fix on the JNA sibling because Phase 6's NativeComparisonTest will
   compare the two implementations and any divergence would fail
   parity.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Upstream 8f3f018 removed the NetBSD GCC farm CI job but left two
trailing blank lines at the end of unix.yaml that Spotless flags. The
new upstream master is otherwise unchanged for the FreeBSD port, so
this is just a one-line cleanup after the merge into freebsd-ffm.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@dbwiddis
dbwiddis merged commit 58629b5 into oshi:master Jun 4, 2026
19 of 20 checks passed
@dbwiddis
dbwiddis deleted the freebsd-ffm branch June 4, 2026 06:25
dbwiddis added a commit that referenced this pull request Jun 4, 2026
* Phase 6 commit 1: wire FreeBSD into oshi.ffm.SystemInfo

Adds PlatformEnum.FREEBSD to SUPPORTED_PLATFORMS, dispatches to
FreeBsdOperatingSystemFFM / FreeBsdHardwareAbstractionLayerFFM (shipped
in PRs #3322 and #3328), and updates the class-level Javadoc that
previously listed only Windows/macOS/Linux. FreeBSD is dropped from
the "use oshi.SystemInfo (JNA) instead" call-out since the FFM path
now covers it; OpenBSD, Solaris, AIX still need the JNA entry point.

This is the last load-bearing change of the FreeBSD FFM port — after
this, oshi.ffm.SystemInfo.isAvailable() returns true on FreeBSD and
the public API works end-to-end.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* Phase 6 commit 2: enable FreeBSD across FFM tests

Now that oshi.ffm.SystemInfo dispatches to FreeBSD (Phase 6 commit 1),
all six FFM tests previously gated to {LINUX, MAC, WINDOWS} need
FreeBSD added so they exercise the new wiring on the FreeBSD CI:

* oshi-core-ffm: SystemInfoTest, GlobalMemoryFFMTest, VirtualMemoryFFMTest,
  OperatingSystemFFMTest, ForeignFunctionsTest
* oshi-benchmark: NativeComparisonTest (the big JNA-vs-FFM HAL/OS
  parity test that retires the per-piece comparison tests we explicitly
  skipped during Phases 3–5)

No assertion changes — the test bodies already cover the FreeBSD-relevant
surface generically through the public OSHI API. Mac CI continues to
see the same 39 successful / 53 skipped split.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* Phase 6 commit 3: handle FreeBSD-specific NativeComparisonTest parity gaps

Three failures surfaced when Phase 6 commit 2 enabled NativeComparisonTest
on FreeBSD. None are real parity bugs; all are structural differences
between FreeBSD's process/sensor model and the other platforms.

* ComparisonAssertions.assertWithinRatio now treats both-NaN as equal.
  CPU temperature comes back NaN on the FreeBSD CI VM (no coretemp kld
  module loaded) from both JNA and FFM, which is correct parity, but
  NaN/NaN arithmetic made the ratio check fail.

* assertStartTimeMatches helper added to NativeComparisonTest. On
  Linux/Mac/Windows OSProcess#getStartTime() exposes the kernel's
  exact start time and strict equality holds. On FreeBSD startTime is
  derived as (now - elapsedTime) where elapsedTime is the
  seconds-resolution `ps -o etimes` value; JNA and FFM each capture
  `now` at slightly different timestamps so the derived values drift
  by tens of milliseconds. Switched the two startTime assertions
  (currentProcess() and processListStructure()) to a 2000ms tolerance
  on FreeBSD; other platforms keep strict equality.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* Phase 6 commit 4: more FreeBSD parity gaps surfaced by NativeComparisonTest

Two more failures appeared once Phase 6 commit 3's startTime and NaN
fixes cleared the way; both are real and fixed in this commit.

1. process.softOpenFileLimit — JNA returned 10328, FFM returned 175554
   (real open-files limit). Pre-existing JNA-on-FreeBSD bug:
   Resource.RLIMIT_NOFILE in the JNA platform module is the Linux
   value 7, but on FreeBSD RLIMIT_NOFILE = 8 (7 is RLIMIT_NPROC). So
   FreeBsdOSProcessJNA was calling getrlimit on the wrong resource —
   returning the max-processes limit instead of open-files. Added an
   explicit `int RLIMIT_NOFILE = 8;` to FreeBsdLibc that shadows the
   inherited Linux constant so the existing call site picks up the
   correct value with no code change at the caller. FFM was already
   using 8 (added in Phase 5 commit 5).

2. fileStoreUpdateAttributes totalSpace — JNA and FFM call
   updateAttributes() back-to-back, but on a live filesystem total
   space can drift by a few blocks while the test is itself writing
   (the observed delta was exactly 3×4KB = 12 KB out of 208 GB).
   Relaxed the strict equality to assertWithinRatio with a 0.1%
   tolerance, the same pattern this file already uses for other
   drift-prone counters.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* Phase 6 commit 5: remove temporary FreeBSD FFM CI workflow

freebsd-ffm.yaml was the push-triggered FreeBSD VM job introduced in
Phase 1 (PR #3316) so in-progress FFM work got FreeBSD coverage
between PR submissions. With the port complete and the permanent
testfreebsd job in pr.yaml + unix.yaml exercising every change, the
temp workflow is no longer needed.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
dbwiddis added a commit that referenced this pull request Jun 4, 2026
Follow-up to the five FreeBSD FFM port PRs (#3316, #3319, #3322,
#3328, #3330) covering loose ends that don't fit any individual port
commit.

JaCoCo agent excludes:
* Remove `**/unix/BsdNetworkIF*` and `**/unix/UnixBaseboard*`. Both
  classes were hoisted to oshi-common during the port (#3316 and
  #3328 respectively) and are now exercised on the permanent
  FreeBSD CI job through `NativeComparisonTest.networkInterfaces()`
  and `ComputerSystem.getBaseboard()`; the excludes were silently
  dropping that coverage from the `freebsd` codecov flag.
* Add `**/FreeBsdPowerSource*` alongside the existing
  `**/{Mac,Windows,Linux}PowerSource*` entries. No battery on the
  FreeBSD CI VM, same hardware-conditional pattern.

Documentation:
* Update the supported-platforms statement in README.md, FAQ.md,
  PERFORMANCE.md, src/site/markdown/index.md, oshi-core-ffm
  module-info Javadoc, oshi-core SystemInfo Javadoc, and oshi-core
  package-info Javadoc from "Windows, macOS, and Linux" to
  "Windows, macOS, Linux, and FreeBSD".

CHANGELOG.md gains a New Features bullet linking all five FreeBSD
FFM port PRs.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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