Repository navigation
DragonFly BSD: add FFM port; refactor to mirror FreeBSD split - #3362
Conversation
Closes #3346. With this, oshi-core-ffm covers the same set of platforms as oshi-core (JNA) — no platform exceptions in either docs or code. - Move no-native DragonFly classes (OSThread, ProcstatUtil) to oshi-common. - Extract DragonFlyBsdOSProcess abstract base into oshi-common, holding the shared PsThreadColumns enum + PS_THREAD_COLUMNS constant used by both OSProcess and OSThread. Mirrors the FreeBSD pattern. - Rename the JNA implementations with JNA suffix (DragonFlyBsd{OperatingSystem,OSProcess,CentralProcessor,HardwareAbstractionLayer}JNA) for naming consistency with FreeBSD/AIX. - Add the FFM port: DragonFlyBsdLibcFunctions (lwp_gettid only — everything else is reused from FreeBsdLibcFunctions), DragonFlyBsdCentralProcessorFFM (extends FreeBsdCentralProcessorFFM, overrides per-CPU tick query for DragonFly's kern.cputime sysctl), DragonFlyBsdHardwareAbstractionLayerFFM, DragonFlyBsdOperatingSystemFFM, DragonFlyBsdOSProcessFFM. - Wire DRAGONFLYBSD into oshi.ffm.SystemInfo's SUPPORTED_PLATFORMS, createOperatingSystem, and createHardware. - Update module-info.java in oshi-common and oshi-core-ffm to export the new packages; remove the now-empty oshi.util.platform.unix. dragonflybsd export from oshi-core. Add --add-opens entries for the new oshi-common test packages. - Drop the redundant "(currently supported platforms …)" lists from README, FAQ, module-info, and SystemInfo javadocs. oshi-core-ffm now matches oshi-core platform coverage, so the docs just say "supports all OSHI-supported platforms." - DragonFly ProcstatUtilTest uses ManagementFactory for its live PID (matches the FreeBSD/NetBSD test pattern), avoiding a oshi-common-to- oshi-core dependency on SystemInfo. Tested with \`./mvnw clean install\` from root (all 788 tests pass).
📝 WalkthroughWalkthroughThis PR consolidates DragonFly BSD code into shared common packages, renames and re-wires JNA-specific DragonFly classes to use those commons, and adds a complete FFM implementation (libc downcalls, HAL, processor ticks, OS/process introspection) plus documentation and test updates. ChangesDragonFly BSD Platform Unification
Sequence Diagram(s)sequenceDiagram
participant App
participant SystemInfo
participant DragonFlyBsdOperatingSystemFFM
participant DragonFlyBsdOSProcessFFM
App->>SystemInfo: request OS/HAL for DRAGONFLYBSD
SystemInfo->>DragonFlyBsdOperatingSystemFFM: createOperatingSystem()
DragonFlyBsdOperatingSystemFFM->>DragonFlyBsdOSProcessFFM: enumerate/query processes (ps/sysctl/proc)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3362 +/- ##
============================================
- Coverage 74.99% 74.97% -0.02%
Complexity 76 76
============================================
Files 552 552
Lines 22755 22757 +2
Branches 3759 3759
============================================
- Hits 17064 17063 -1
+ Misses 3586 3584 -2
- Partials 2105 2110 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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/dragonflybsd/ProcstatUtilTest.java`:
- Around line 89-92: The test currently falls back to -1 when parsing the JVM
pid; add a precondition assertion immediately after computing pid (from
ParseUtil.parseIntOrDefault(ManagementFactory.getRuntimeMXBean().getName().split("@",2)[0],
-1)) to fail fast if parsing failed—e.g., assertThat("Could not determine test
JVM pid", pid, is(greaterThanOrEqualTo(0))); then proceed to call
ProcstatUtil.getOpenFiles(pid); this ensures the test aborts with a clear
diagnostic instead of running with an invalid PID.
In
`@oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessorFFM.java`:
- Around line 43-50: The code in DragonFlyBsdCentralProcessorFFM that reads
per-CPU tick fields (the loop accessing ticks[cpu][TickType... ] using CP_USER,
CP_NICE, CP_SYS, CP_INTR, CP_IDLE offsets) assumes a non-zero cpu count and that
the ByteBuffer contains at least the expected bytes per-CPU; guard these reads
by validating cpus > 0 and that arraySize (or buf.remaining()) is >=
expectedBytesPerCpu * cpus (compute expectedBytesPerCpu from UINT64_SIZE and the
highest CP_* index used) before computing structSize and performing the loop,
and if the check fails, skip reading (or log/return) to avoid out-of-bounds
accesses.
In
`@oshi-core-ffm/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystemFFM.java`:
- Around line 179-184: getCurrentThread() dereferences proc.getThreadDetails()
without checking if getCurrentProcess() returned null; before accessing proc,
add a null-check: call getCurrentProcess(), if it is null return a new
oshi.software.common.os.unix.dragonflybsd.DragonFlyBsdOSThread using a safe
fallback PID (e.g., 0) and the thread id from getThreadId(), otherwise proceed
to stream proc.getThreadDetails() as currently implemented (references:
getCurrentThread(), getCurrentProcess(), getThreadId(), OSProcess,
getThreadDetails(), DragonFlyBsdOSThread).
🪄 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: 59f93bd4-d099-4636-a59d-a0cd67334be3
📒 Files selected for processing (25)
CHANGELOG.mdFAQ.mdREADME.mdoshi-common/src/main/java/module-info.javaoshi-common/src/main/java/oshi/software/common/os/unix/dragonflybsd/DragonFlyBsdOSProcess.javaoshi-common/src/main/java/oshi/software/common/os/unix/dragonflybsd/DragonFlyBsdOSThread.javaoshi-common/src/main/java/oshi/software/common/os/unix/dragonflybsd/package-info.javaoshi-common/src/main/java/oshi/util/common/platform/unix/dragonflybsd/ProcstatUtil.javaoshi-common/src/main/java/oshi/util/common/platform/unix/dragonflybsd/package-info.javaoshi-common/src/test/java/module-info.testoshi-common/src/test/java/oshi/util/common/platform/unix/dragonflybsd/ProcstatUtilTest.javaoshi-core-ffm/src/main/java/module-info.javaoshi-core-ffm/src/main/java/oshi/ffm/SystemInfo.javaoshi-core-ffm/src/main/java/oshi/ffm/platform/unix/dragonflybsd/DragonFlyBsdLibcFunctions.javaoshi-core-ffm/src/main/java/oshi/ffm/platform/unix/dragonflybsd/package-info.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessorFFM.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayerFFM.javaoshi-core-ffm/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcessFFM.javaoshi-core-ffm/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystemFFM.javaoshi-core/src/main/java/module-info.javaoshi-core/src/main/java/oshi/SystemInfo.javaoshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessorJNA.javaoshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayerJNA.javaoshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcessJNA.javaoshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystemJNA.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). (14)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 26, windows-latest
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Test JDK 26, macos-latest
- GitHub Check: Analyze (java)
- GitHub Check: JMH Benchmarks, windows-latest
- GitHub Check: JMH Benchmarks, macos-latest
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: JMH Benchmarks, ubuntu-latest
- GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
- GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
- GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
🧰 Additional context used
🧠 Learnings (3)
📚 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/software/common/os/unix/dragonflybsd/DragonFlyBsdOSThread.javaoshi-common/src/main/java/module-info.javaoshi-common/src/main/java/oshi/util/common/platform/unix/dragonflybsd/package-info.javaoshi-common/src/main/java/oshi/software/common/os/unix/dragonflybsd/package-info.javaoshi-common/src/main/java/oshi/software/common/os/unix/dragonflybsd/DragonFlyBsdOSProcess.javaoshi-common/src/main/java/oshi/util/common/platform/unix/dragonflybsd/ProcstatUtil.java
📚 Learning: 2026-03-29T20:01:01.877Z
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:01.877Z
Learning: In this repo’s `module-info.java` files, keep exports aligned with which platform implementations are actually supported by the current FFM (Foreign Function & Memory) backend. Do not export FreeBSD, OpenBSD, or Solaris packages (e.g., `oshi.util.platform.unix.freebsd|openbsd|solaris`) in modules where the FFM implementation only supports Windows/macOS/Linux; this asymmetry vs older Java targets (e.g., the java11 module-info that exports all Unix packages) is intentional and should not be flagged as an omission unless the underlying support changes.
Applied to files:
oshi-core-ffm/src/main/java/module-info.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/DragonFlyBsdCentralProcessorJNA.javaoshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayerJNA.javaoshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystemJNA.javaoshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcessJNA.java
🔇 Additional comments (22)
CHANGELOG.md (1)
7-7: LGTM!FAQ.md (1)
103-103: LGTM!README.md (1)
79-81: LGTM!oshi-core-ffm/src/main/java/module-info.java (1)
4-5: LGTM!Also applies to: 26-26
oshi-core-ffm/src/main/java/oshi/ffm/SystemInfo.java (1)
19-19: LGTM!Also applies to: 29-29, 63-64, 96-97, 118-119, 143-144
oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/dragonflybsd/DragonFlyBsdLibcFunctions.java (1)
1-41: LGTM!oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/dragonflybsd/package-info.java (1)
1-8: LGTM!oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayerFFM.java (1)
1-101: LGTM!oshi-core-ffm/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcessFFM.java (1)
1-448: LGTM!oshi-common/src/main/java/module-info.java (1)
49-49: LGTM!Also applies to: 58-58
oshi-common/src/main/java/oshi/software/common/os/unix/dragonflybsd/DragonFlyBsdOSProcess.java (1)
1-30: LGTM!oshi-common/src/main/java/oshi/software/common/os/unix/dragonflybsd/DragonFlyBsdOSThread.java (1)
5-5: LGTM!Also applies to: 20-20, 116-131
oshi-common/src/main/java/oshi/software/common/os/unix/dragonflybsd/package-info.java (1)
1-9: LGTM!oshi-common/src/main/java/oshi/util/common/platform/unix/dragonflybsd/ProcstatUtil.java (1)
5-5: LGTM!oshi-common/src/main/java/oshi/util/common/platform/unix/dragonflybsd/package-info.java (1)
8-8: LGTM!oshi-common/src/test/java/module-info.test (1)
55-58: LGTM!oshi-core/src/main/java/module-info.java (1)
5-5: LGTM!oshi-core/src/main/java/oshi/SystemInfo.java (1)
17-17: LGTM!Also applies to: 27-27, 61-63, 130-130, 165-165
oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessorJNA.java (1)
24-24: LGTM!Also applies to: 26-26
oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayerJNA.java (1)
36-37: LGTM!Also applies to: 39-39, 53-53
oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcessJNA.java (1)
38-39: LGTM!Also applies to: 41-41, 45-45, 51-51, 53-53, 55-55, 86-86, 336-336
oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystemJNA.java (1)
30-30: LGTM!Also applies to: 51-51, 53-53, 58-58, 147-148
| long structSize = arraySize / cpus; | ||
| for (int cpu = 0; cpu < cpus; cpu++) { | ||
| long base = structSize * cpu; | ||
| ticks[cpu][TickType.USER.getIndex()] = buf.get(JAVA_LONG, base + CP_USER * UINT64_SIZE); | ||
| ticks[cpu][TickType.NICE.getIndex()] = buf.get(JAVA_LONG, base + CP_NICE * UINT64_SIZE); | ||
| ticks[cpu][TickType.SYSTEM.getIndex()] = buf.get(JAVA_LONG, base + CP_SYS * UINT64_SIZE); | ||
| ticks[cpu][TickType.IRQ.getIndex()] = buf.get(JAVA_LONG, base + CP_INTR * UINT64_SIZE); | ||
| ticks[cpu][TickType.IDLE.getIndex()] = buf.get(JAVA_LONG, base + CP_IDLE * UINT64_SIZE); |
There was a problem hiding this comment.
Guard kern.cputime layout before fixed-offset reads.
Line 43 and Lines 46-50 assume at least five uint64 tick fields per CPU. If cpus is 0 or the buffer is shorter than expected, this can throw at runtime while sampling ticks.
Suggested patch
public long[][] queryProcessorCpuLoadTicks() {
int cpus = getLogicalProcessorCount();
long[][] ticks = new long[cpus][CentralProcessor.TickType.values().length];
+ if (cpus <= 0) {
+ return ticks;
+ }
// DragonFly's kern.cputime returns a packed per-CPU array; the struct size per CPU is the total length
// divided by CPU count (the trailing fields can vary by DragonFly version).
MemorySegment buf = BsdSysctlUtilFFM.sysctl("kern.cputime");
if (buf == null) {
return ticks;
@@
if (arraySize <= 0) {
return ticks;
}
long structSize = arraySize / cpus;
+ long required = (CP_IDLE + 1L) * UINT64_SIZE;
+ if (structSize < required) {
+ return ticks;
+ }
for (int cpu = 0; cpu < cpus; cpu++) {
long base = structSize * cpu;
ticks[cpu][TickType.USER.getIndex()] = buf.get(JAVA_LONG, base + CP_USER * UINT64_SIZE);🤖 Prompt for 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.
In
`@oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessorFFM.java`
around lines 43 - 50, The code in DragonFlyBsdCentralProcessorFFM that reads
per-CPU tick fields (the loop accessing ticks[cpu][TickType... ] using CP_USER,
CP_NICE, CP_SYS, CP_INTR, CP_IDLE offsets) assumes a non-zero cpu count and that
the ByteBuffer contains at least the expected bytes per-CPU; guard these reads
by validating cpus > 0 and that arraySize (or buf.remaining()) is >=
expectedBytesPerCpu * cpus (compute expectedBytesPerCpu from UINT64_SIZE and the
highest CP_* index used) before computing structSize and performing the loop,
and if the check fails, skip reading (or log/return) to avoid out-of-bounds
accesses.
| public OSThread getCurrentThread() { | ||
| OSProcess proc = getCurrentProcess(); | ||
| final int tid = getThreadId(); | ||
| return proc.getThreadDetails().stream().filter(t -> t.getThreadId() == tid).findFirst() | ||
| .orElse(new oshi.software.common.os.unix.dragonflybsd.DragonFlyBsdOSThread(proc.getProcessID(), tid)); | ||
| } |
There was a problem hiding this comment.
Handle null current process before dereferencing thread list.
Line 182 assumes getCurrentProcess() succeeded. If PID lookup/process fetch fails (e.g., fallback PID 0 path), this can NPE.
Suggested patch
public OSThread getCurrentThread() {
OSProcess proc = getCurrentProcess();
final int tid = getThreadId();
+ if (proc == null) {
+ return new oshi.software.common.os.unix.dragonflybsd.DragonFlyBsdOSThread(getProcessId(), tid);
+ }
return proc.getThreadDetails().stream().filter(t -> t.getThreadId() == tid).findFirst()
.orElse(new oshi.software.common.os.unix.dragonflybsd.DragonFlyBsdOSThread(proc.getProcessID(), tid));
}🤖 Prompt for 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.
In
`@oshi-core-ffm/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystemFFM.java`
around lines 179 - 184, getCurrentThread() dereferences proc.getThreadDetails()
without checking if getCurrentProcess() returned null; before accessing proc,
add a null-check: call getCurrentProcess(), if it is null return a new
oshi.software.common.os.unix.dragonflybsd.DragonFlyBsdOSThread using a safe
fallback PID (e.g., 0) and the thread id from getThreadId(), otherwise proceed
to stream proc.getThreadDetails() as currently implemented (references:
getCurrentThread(), getCurrentProcess(), getThreadId(), OSProcess,
getThreadDetails(), DragonFlyBsdOSThread).
- ProcstatUtilTest: assert RuntimeMXBean-derived PID > 0 before using it, matching the FreeBSD ProcstatUtilTest precondition pattern. - DragonFlyBsdCentralProcessorFFM: add a single structSize guard for the kern.cputime per-CPU layout. The dynamic structSize computation (unlike FreeBSD's static CPTIME_SIZE) makes an IOBE possible if the sysctl returns a short buffer — e.g. a stub sysctl on a non-DragonFly kernel. Skips the loop instead of crashing. - CHANGELOG: match the one-liner format used for the AIX and NetBSD FFM ports and add the PR number. Did not adopt CodeRabbit's getCurrentThread() null-check suggestion — matches the no-null-check pattern used by every Unix OperatingSystem implementation (JNA and FFM); if getCurrentProcess() could return null it would be a longstanding cross-platform bug, not a DragonFly issue.
Matches the naming convention established by AIX (#3350), FreeBSD, and extended to DragonFly today (#3362). The 8 oshi-core OpenBSD classes (5 hardware, 3 software/os) get a JNA suffix to make the JNA-vs-FFM split explicit in the file names. The 6 abstract bases in oshi-common keep their unsuffixed names; the FFM classes in oshi-core-ffm already have the FFM suffix. - Rename: - OpenBsdComputerSystem.java → OpenBsdComputerSystemJNA.java - OpenBsdHardwareAbstractionLayer.java → OpenBsdHardwareAbstractionLayerJNA.java - OpenBsdCentralProcessor.java → OpenBsdCentralProcessorJNA.java - OpenBsdGlobalMemory.java → OpenBsdGlobalMemoryJNA.java - OpenBsdHWDiskStore.java → OpenBsdHWDiskStoreJNA.java - OpenBsdFileSystem.java → OpenBsdFileSystemJNA.java - OpenBsdOperatingSystem.java → OpenBsdOperatingSystemJNA.java - OpenBsdOSProcess.java → OpenBsdOSProcessJNA.java - Three classes (OpenBsdGlobalMemory, OpenBsdFileSystem, OpenBsdOSProcess) previously used `extends oshi.<...>.<unqualified-same-name>` to disambiguate from the common base of the same name. With the suffix in place the FQN-extends becomes a regular `extends OpenBsdFoo` with a normal import — cleaner and matches every other platform. - oshi-core SystemInfo updated for the two renamed entry points. - OpenBsdSysctlUtil stays unsuffixed in oshi-core (matches the BsdSysctlUtil precedent — the FFM counterpart OpenBsdSysctlUtilFFM carries the suffix on the FFM side only). Tested with `./mvnw clean install` from root (all tests pass).
Summary
Closes #3346. Adds DragonFly BSD support to
oshi-core-ffm, refactoring the existing JNA implementation along the way to match the abstract-base / JNA-subclass / FFM-subclass split used by FreeBSD/AIX.With this PR,
oshi-core-ffmcovers the same set of platforms asoshi-core(JNA). The user-facing story is now simple: OSHI has JNA and FFM implementations; both cover all supported platforms; pick whichever fits your deployment.What changed
Refactor (mirror FreeBSD pattern)
DragonFlyBsdOSThreadandProcstatUtil(with its test) are pure shell/file-parsing; they live next to the other Unixoshi-commonclasses.DragonFlyBsdOSProcessabstract base into oshi-common, holding the sharedPsThreadColumnsenum +PS_THREAD_COLUMNSconstant used by both OSProcess and OSThread (same pattern asFreeBsdOSProcess).JNAsuffix inoshi-core:DragonFlyBsd{OperatingSystem,OSProcess,CentralProcessor,HardwareAbstractionLayer}JNA. Matches FreeBSD/AIX.New FFM implementations (
oshi-core-ffm)DragonFlyBsdLibcFunctions— adds only the DragonFly-specificlwp_gettid()downcall. Shared libc surface (getpid,sysctl,getrlimit,sysctlbyname) is reused fromFreeBsdLibcFunctions.DragonFlyBsdCentralProcessorFFM extends FreeBsdCentralProcessorFFM— inheritskern.cp_timesystem-tick logic from FreeBSD; overridesqueryProcessorCpuLoadTicksto use DragonFly'skern.cputimesysctl (FreeBSD useskern.cp_times).DragonFlyBsdHardwareAbstractionLayerFFM— uses FreeBSD FFM implementations where behavior is identical (computer system, memory, sensors, power, disks, USB, sound, graphics, displays, network); overridescreateProcessorfor the DragonFly-specific CP; usesCupsPrinterFFMfor printers.DragonFlyBsdOperatingSystemFFM— full FFM implementation mirroring the JNA structure; usesFreeBsdLibcFunctions.getpid,DragonFlyBsdLibcFunctions.lwp_gettid,BsdSysctlUtilFFMforkern.boottime, and FreeBSD FFM file system / IP stats / network params.DragonFlyBsdOSProcessFFM— full FFM implementation; usesFreeBsdLibcFunctions.getrlimitfor file-descriptor limits andFreeBsdLibcFunctions.sysctl(int MIB)for bitness detection.Wiring + docs
oshi.ffm.SystemInfogainscase DRAGONFLYBSDincreateOperatingSystemandcreateHardware;DRAGONFLYBSDadded toSUPPORTED_PLATFORMS.oshi-common/module-info.javaandoshi-core-ffm/module-info.javaget the new package exports;oshi-core/module-info.javadrops the moved-outoshi.util.platform.unix.dragonflybsdexport.module-info.testadds--add-opensentries for the new DragonFly packages inoshi-common.ProcstatUtilTestswitches fromoshi.SystemInfotoManagementFactoryfor its live-DragonFly PID (matches the FreeBSD/NetBSD test pattern, avoiding a oshi-common-to-oshi-core dependency).oshi-core-ffm/module-infojavadoc, andoshi-core/SystemInfo+oshi-core-ffm/SystemInfojavadoc all drop the "currently supports these specific OSes" lists, since FFM and JNA now cover the same platforms. The selection matrix in README just says "all supported platforms" for both columns.Test plan
./mvnw clean installfrom repo root passes (all 788 tests).oshi-common,oshi-core,oshi-core-ffm.oshi-coreSystemInfo references the new JNA-suffixed class names.oshi-core-ffmSystemInfo now supports DragonFly; throws only for genuinely unsupported platforms.unix.yamlpush-to-master, so the FFM path is not exercised by PR CI today — same gap we've worked around for NetBSD.Unix CIvalidates the JNA-suffixed DragonFly classes still work on the actual DragonFly VM (the no-FFM portion).Caveats / notes
pkg install openjdk25is still failing per FFM port: DragonFly BSD (extend FreeBSD bindings) #3346's blocker — no published binary on the vmactions DF VM image). When that clears,unix.yamlcan be bumped to JDK 25 for DragonFly and FFM will be exercised. The FFM code is structured to closely mirror the FreeBSD FFM bindings, so confidence is high.oshi.SystemInfo(JNA) instantiates the renamedDragonFlyBsd*JNAclasses fromoshi-core.Summary by CodeRabbit
New Features
Documentation
Tests