Repository navigation
Extract Solaris common abstract bases for JNA/FFM parity - #3367
Conversation
Add pure-Java mirrors of the Solaris psinfo_t / lwpsinfo_t / prusage_t /
timestruc_t structs (SolarisPsInfo, SolarisLwpsInfo, SolarisPrUsage,
SolarisTimestruc) and a common PsInfo driver that parses
/proc/<pid>/{psinfo,usage} and /proc/<pid>/lwp/<tid>/{lwpsinfo,usage}
from a ByteBuffer. These contain no native code, so both the JNA and FFM
Solaris implementations can share them, mirroring the existing
oshi.driver.common.unix.aix carriers.
Rebase Solaris OSProcess, OSThread, FileSystem, NetworkParams, and OperatingSystem onto abstract bases in oshi-common, with concrete <Os>FooJNA (oshi-core) and <Os>FooFFM (oshi-core-ffm) subclasses, matching the AIX and FreeBSD convention. OSFileStore has no native code, so it becomes a single concrete common class like AixOSFileStore. The shared attribute parsing now reads the common /proc carriers, removing the duplicated updateAttributes logic between the JNA and FFM sides. The JNA-only Kstat2 paths stay JNA-side: HAS_KSTAT2, the dual-path file descriptor counts, system uptime/boot time, and the getSessions override remain in SolarisOperatingSystemJNA / SolarisFileSystemJNA. FFM uses the legacy kstat chain only, since kstat2 exists only on the JDK 17-capped latest Solaris and illumos forked before it. The driver split mirrors AIX: the buffer parsing lives in the common PsInfo driver, the JNA PsInfo is renamed to PsInfoJNA and keeps only the pread-based arg/env read, and PsInfoFFM keeps only the pargs-based read. The now-unused psinfo/lwpsinfo/prusage JNA structs are removed from SolarisLibc. Also fixes an FFM gap: its prusage POJO had dropped pr_ioch, so FFM never populated OSProcess.getBytesRead(); the common carrier restores it so both implementations report it.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (6)
📜 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)
🧰 Additional context used🧠 Learnings (1)📚 Learning: 2026-04-12T19:22:09.716ZApplied to files:
🔇 Additional comments (1)
📝 WalkthroughWalkthroughThis PR unifies Solaris support across JNA and FFM backends by extracting shared struct mirrors and abstract base classes into a common package, while moving platform-specific implementations into separate JNA and FFM modules. It introduces kstat2 capability detection in the JNA layer and refactors all Solaris components to use abstract extension points. ChangesShared Solaris Struct Mirrors and Pure-Java Drivers
Abstract Base Classes for Solaris OS Components
JNA-Specific Solaris Implementation Layer
FFM-Specific Solaris Implementation Layer
Global Reference Updates to HAS_KSTAT2 and Imports
🎯 4 (Complex) | ⏱️ ~75 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 #3367 +/- ##
============================================
- Coverage 75.04% 68.82% -6.22%
Complexity 76 76
============================================
Files 552 561 +9
Lines 22757 22416 -341
Branches 3759 3701 -58
============================================
- Hits 17078 15428 -1650
- Misses 3578 5115 +1537
+ Partials 2101 1873 -228
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: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
oshi-core/src/main/java/oshi/driver/unix/solaris/PsInfoJNA.java (1)
193-195:⚠️ Potential issue | 🟠 MajorFix unsigned decoding of 32-bit pointers in
getOffsetFromBuffer()For 32-bit Solaris processes (
pr_dmodel⇒increment == 4),getOffsetFromBuffer()returnsbuffer.getInt(...)cast tolongwithout treating it as unsigned. Values ≥0x8000_0000become negative and are then used as addresses forpreadpage selection andbuffer.getString(...), breaking arg/env extraction for otherwise valid processes.Suggested fix
private static long getOffsetFromBuffer(Memory buffer, long offset, long increment) { - return increment == 8 ? buffer.getLong(offset) : buffer.getInt(offset); + return increment == 8 ? buffer.getLong(offset) : buffer.getInt(offset) & 0xffff_ffffL; }🤖 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/src/main/java/oshi/driver/unix/solaris/PsInfoJNA.java` around lines 193 - 195, The getOffsetFromBuffer method is incorrectly treating 32-bit pointer values as signed; modify the branch for increment == 4 in getOffsetFromBuffer to convert the returned int to an unsigned long (e.g., use Integer.toUnsignedLong(buffer.getInt(offset)) or bitwise mask & 0xFFFFFFFFL) so values >= 0x80000000 are preserved as correct positive addresses; leave the increment == 8 path using buffer.getLong(offset) unchanged.oshi-core/src/test/java/oshi/driver/unix/solaris/PsInfoTest.java (1)
30-31:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winGuard nullable
/procreads before dereferencing in the test.Line 30 and Line 37 call nullable APIs; direct field access at Line 31/Line 38 can intermittently NPE when an LWP exits between enumerate/read.
Suggested fix
SolarisPsInfo psinfo = PsInfo.queryPsInfo(pid); + assertNotNull(psinfo, "psinfo should be readable for current PID"); assertThat("Process ID in structure should match PID", psinfo.pr_pid, is(pid)); @@ int tid = ParseUtil.parseIntOrDefault(lwpidFile.getName(), 0); SolarisLwpsInfo lwpsinfo = PsInfo.queryLwpsInfo(pid, tid); + if (lwpsinfo == null) { + continue; // LWP may exit between listing and read + } assertThat("Thread ID in structure should match TID", lwpsinfo.pr_lwpid, is(tid));Also applies to: 37-38
🤖 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/src/test/java/oshi/driver/unix/solaris/PsInfoTest.java` around lines 30 - 31, Guard nullable returns before accessing fields: after calling PsInfo.queryPsInfo(pid) (and similarly any LwpInfo or other query* methods used later), assert or assume the returned object is non-null before dereferencing its fields; e.g., add an assertNotNull("PsInfo should not be null", psinfo) (or an assumeTrue/assumeNotNull to skip the test if transient), then perform assertThat(psinfo.pr_pid, is(pid)). Apply the same null-check pattern for the later call(s) (e.g., LwpInfo or other query methods) before accessing their fields to prevent intermittent NPEs.
🤖 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/main/java/oshi/software/common/os/unix/solaris/SolarisFileSystem.java`:
- Around line 52-53: The method SolarisFileSystem.getFileStoreMatching(...) is
unnecessarily public; change its declaration from "public static
List<OSFileStore> getFileStoreMatching(...)" to package-private static (remove
the public modifier) so it's accessible to SolarisOSFileStore in the same
package but not exported from the API; update any Javadoc/comment if needed to
reflect the reduced visibility.
In
`@oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOSProcess.java`:
- Around line 419-431: In getProcessOpenFileLimit, guard access to split[index]
to avoid ArrayIndexOutOfBoundsException: after computing String[] split =
nofilesLine.get().split("\\D+"), check that split.length > index (and that
split[index] is non-empty if desired) and return -1 when the token isn't
present, instead of directly calling ParseUtil.parseLongOrDefault(split[index],
-1); this ensures getProcessOpenFileLimit handles cases like "nofiles 256
unlimited" safely.
In
`@oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOSThread.java`:
- Around line 122-126: The code in SolarisOSThread updates userTime, kernelTime,
and contextSwitches only when prusage (usage) is non-null, leaving prior
contextSwitches stale if a later refresh returns null; modify the update block
for usage (in SolarisOSThread, where usage/prusage is read) to explicitly reset
contextSwitches to 0 when usage == null (and optionally reset userTime and
kernelTime to 0 as well) so stale values are not retained.
In
`@oshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOperatingSystemJNA.java`:
- Around line 167-174: In queryBootAndUptime(), change the Kstat2 path used in
KstatUtil.queryKstat2 to include the "kstat:/" prefix (use
"kstat:/misc/unix/system_misc") so boot_time/snaptime aren't null, and normalize
the boot_time fallback to seconds (if results[0] is null set boot =
System.currentTimeMillis() / 1000L) to match getSystemBootTime() expectations;
keep the snaptime conversion to seconds by dividing results[1] by 1_000_000_000L
and return the Pair<>(boot, snap) from the same method name.
In
`@oshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOSProcessJNA.java`:
- Around line 47-48: The code currently calls
SolarisLibc.INSTANCE.getrlimit(SolarisLibc.RLIMIT_NOFILE, rlimit) and then uses
rlimit.rlim_cur / rlim_max without checking the call's return status; change
both usages (the calls around rlimit.rlim_cur and rlimit.rlim_max) to capture
the return value (e.g., int rc = SolarisLibc.INSTANCE.getrlimit(...)), verify rc
== 0 before reading rlimit fields, and on failure handle it consistently (log or
propagate an error and return a sentinel like -1 or throw) so you never consume
rlimit.rlim_* after a failed getrlimit. Ensure you update both places referenced
in the diff and use SolarisLibc.INSTANCE.getrlimit, SolarisLibc.RLIMIT_NOFILE,
and rlimit names to locate the changes.
---
Outside diff comments:
In `@oshi-core/src/main/java/oshi/driver/unix/solaris/PsInfoJNA.java`:
- Around line 193-195: The getOffsetFromBuffer method is incorrectly treating
32-bit pointer values as signed; modify the branch for increment == 4 in
getOffsetFromBuffer to convert the returned int to an unsigned long (e.g., use
Integer.toUnsignedLong(buffer.getInt(offset)) or bitwise mask & 0xFFFFFFFFL) so
values >= 0x80000000 are preserved as correct positive addresses; leave the
increment == 8 path using buffer.getLong(offset) unchanged.
In `@oshi-core/src/test/java/oshi/driver/unix/solaris/PsInfoTest.java`:
- Around line 30-31: Guard nullable returns before accessing fields: after
calling PsInfo.queryPsInfo(pid) (and similarly any LwpInfo or other query*
methods used later), assert or assume the returned object is non-null before
dereferencing its fields; e.g., add an assertNotNull("PsInfo should not be
null", psinfo) (or an assumeTrue/assumeNotNull to skip the test if transient),
then perform assertThat(psinfo.pr_pid, is(pid)). Apply the same null-check
pattern for the later call(s) (e.g., LwpInfo or other query methods) before
accessing their fields to prevent intermittent NPEs.
🪄 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: 4f1cd15d-7ca1-4cd4-a7a5-67e5d5dcb6ce
📒 Files selected for processing (37)
config/checkstyle-suppressions.xmloshi-common/src/main/java/module-info.javaoshi-common/src/main/java/oshi/driver/common/unix/solaris/PsInfo.javaoshi-common/src/main/java/oshi/driver/common/unix/solaris/SolarisLwpsInfo.javaoshi-common/src/main/java/oshi/driver/common/unix/solaris/SolarisPrUsage.javaoshi-common/src/main/java/oshi/driver/common/unix/solaris/SolarisPsInfo.javaoshi-common/src/main/java/oshi/driver/common/unix/solaris/SolarisTimestruc.javaoshi-common/src/main/java/oshi/driver/common/unix/solaris/package-info.javaoshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisNetworkParams.javaoshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOSFileStore.javaoshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOSProcess.javaoshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOSThread.javaoshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOperatingSystem.javaoshi-core-ffm/src/main/java/oshi/driver/unix/solaris/PsInfoFFM.javaoshi-core-ffm/src/main/java/oshi/driver/unix/solaris/kstat/SystemPagesFFM.javaoshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/Kstat2Functions.javaoshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisFileSystemFFM.javaoshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisNetworkParamsFFM.javaoshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisOSFileStoreFFM.javaoshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisOSProcessFFM.javaoshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisOSThreadFFM.javaoshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisOperatingSystemFFM.javaoshi-core/src/main/java/oshi/SystemInfo.javaoshi-core/src/main/java/oshi/driver/unix/solaris/PsInfoJNA.javaoshi-core/src/main/java/oshi/driver/unix/solaris/kstat/SystemPages.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessor.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisHWDiskStore.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisNetworkIF.javaoshi-core/src/main/java/oshi/jna/platform/unix/SolarisLibc.javaoshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisFileSystemJNA.javaoshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisNetworkParamsJNA.javaoshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOSProcessJNA.javaoshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOSThreadJNA.javaoshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOperatingSystemJNA.javaoshi-core/src/main/java/oshi/util/platform/unix/solaris/KstatUtil.javaoshi-core/src/test/java/oshi/driver/unix/solaris/PsInfoTest.java
💤 Files with no reviewable changes (2)
- oshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisOSFileStoreFFM.java
- oshi-core/src/main/java/oshi/jna/platform/unix/SolarisLibc.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 26, macos-latest
- GitHub Check: Analyze (java)
- GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
- GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
- GitHub Check: Test JDK 26, windows-latest
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: JMH Benchmarks, ubuntu-latest
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
- GitHub Check: JMH Benchmarks, macos-latest
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: JMH Benchmarks, windows-latest
🧰 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/driver/common/unix/solaris/SolarisLwpsInfo.javaoshi-common/src/main/java/oshi/driver/common/unix/solaris/SolarisTimestruc.javaoshi-common/src/main/java/oshi/driver/common/unix/solaris/package-info.javaoshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisNetworkParams.javaoshi-common/src/main/java/oshi/driver/common/unix/solaris/SolarisPrUsage.javaoshi-common/src/main/java/module-info.javaoshi-common/src/main/java/oshi/driver/common/unix/solaris/SolarisPsInfo.javaoshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOSThread.javaoshi-common/src/main/java/oshi/driver/common/unix/solaris/PsInfo.javaoshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOSFileStore.javaoshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOSProcess.javaoshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOperatingSystem.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/solaris/SolarisNetworkIF.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisHWDiskStore.javaoshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOSThreadJNA.javaoshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisFileSystemJNA.javaoshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOSProcessJNA.javaoshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOperatingSystemJNA.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessor.javaoshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisNetworkParamsJNA.java
🔇 Additional comments (19)
oshi-core/src/main/java/oshi/SystemInfo.java (1)
30-30: LGTM!Also applies to: 122-122
oshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisNetworkParamsJNA.java (1)
13-13: LGTM!Also applies to: 19-31
oshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOSThreadJNA.java (1)
14-18: LGTM!oshi-core/src/main/java/oshi/driver/unix/solaris/kstat/SystemPages.java (1)
7-7: LGTM!oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisNetworkIF.java (1)
7-7: LGTM!oshi-common/src/main/java/module-info.java (1)
28-28: LGTM!oshi-common/src/main/java/oshi/driver/common/unix/solaris/package-info.java (1)
1-8: LGTM!oshi-common/src/main/java/oshi/driver/common/unix/solaris/SolarisTimestruc.java (1)
14-31: LGTM!oshi-common/src/main/java/oshi/driver/common/unix/solaris/SolarisLwpsInfo.java (1)
16-67: LGTM!oshi-common/src/main/java/oshi/driver/common/unix/solaris/SolarisPrUsage.java (1)
17-76: LGTM!oshi-common/src/main/java/oshi/driver/common/unix/solaris/SolarisPsInfo.java (1)
16-95: LGTM!config/checkstyle-suppressions.xml (1)
33-37: LGTM!oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOSProcess.java (1)
5-5: LGTM!Also applies to: 36-39, 48-60, 87-87, 99-106, 139-140, 331-333, 354-357, 362-364, 369-376, 386-386, 412-418, 434-447
oshi-common/src/main/java/oshi/driver/common/unix/solaris/PsInfo.java (1)
40-56: LGTM!Also applies to: 65-77, 85-96, 105-116, 124-130
oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisNetworkParams.java (1)
16-26: LGTM!oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOSFileStore.java (1)
5-5: LGTM!Also applies to: 12-13
oshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisNetworkParamsFFM.java (1)
15-15: LGTM!Also applies to: 17-21
oshi-core-ffm/src/main/java/oshi/driver/unix/solaris/kstat/SystemPagesFFM.java (1)
30-32: LGTM!oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/Kstat2Functions.java (1)
31-31: LGTM!
Several issues surfaced in review of code carried into oshi-common; all
pre-existed the parity refactor and are fixed here:
- PsInfoJNA.getOffsetFromBuffer: read 32-bit pointers as unsigned so high
user addresses (>= 0x80000000) aren't sign-extended.
- SolarisOperatingSystemJNA.queryBootAndUptime: use the kstat:/ URI prefix
("kstat:/misc/unix/system_misc") so boot_time/snaptime resolve on Solaris
11.4+, and keep the boot_time fallback in seconds.
- SolarisOSProcessJNA: check the getrlimit return status before reading
rlim_cur/rlim_max, matching the AIX and FFM implementations.
- SolarisOSProcess.getProcessOpenFileLimit: guard the split index so a
non-numeric plimit token (e.g. "nofiles ... unlimited") can't throw.
- SolarisOSThread: reset contextSwitches to 0 before the usage block so a
later refresh that can't read usage doesn't retain a stale value.
Also tighten visibility and tests:
- SolarisFileSystem.getFileStoreMatching is package-private (only the
same-package SolarisOSFileStore and getFileStores call it), matching AIX.
- PsInfoTest asserts the query results are non-null before dereferencing.
The FreeBSD, OpenBSD, and DragonFly OperatingSystem classes each duplicated their entire body between the JNA and FFM backends (the method signatures were identical; only the native calls and backend factory types differed). Following the Solaris #3367 template, extract an abstract per-platform base in oshi-common holding the ps-based process enumeration, process/thread counts, services, and system uptime/boot time. The JNA and FFM subclasses are reduced to the genuinely backend-specific bits: the OSProcess factory (a new createProcess hook), the FileSystem/NetworkParams/InternetProtocolStats factories, getpid/ thread-id, the sysctl version query, and who sessions. Per-platform notes: - FreeBSD/DragonFly read boot time from a native sysctl struct, so the base declares an abstract queryBootTime() hook (memoized); OpenBSD text-parses it, so its base implements queryBootTime() concretely. - OpenBSD's InternetProtocolStats and NetworkParams are common (non-native) classes, so they move into the base; FreeBSD/DragonFly keep their JNA/FFM factory overrides. DragonFly reuses FreeBSD's filesystem/IP/network impls and keeps its kernel-thread (pid <= 0) filter. NetBSD already has a single common OperatingSystem class and is unchanged. The JNA/FFM subclasses shrink from ~225-238 lines each to ~55-90.
Part 1 of 2 of the Solaris JNA/FFM parity cleanup. This PR covers the
software.osclasses; a follow-up will give the Solarishardwareclasses (CentralProcessor,GlobalMemory,HWDiskStore,NetworkIF,PowerSource, HAL) the same treatment.Brings Solaris in line with the AIX/FreeBSD JNA/FFM structure. Solaris was the last platform whose JNA and FFM implementations both extended the generic
Abstract*bases directly, duplicating Solaris-specific logic acrossoshi-coreandoshi-core-ffm.What changed
/proccarriers in oshi-common — pure-Java mirrors ofpsinfo_t/lwpsinfo_t/prusage_t/timestruc_tplus a commonPsInfodriver that parses/proc/<pid>/{psinfo,usage}and/proc/<pid>/lwp/<tid>/{lwpsinfo,usage}from aByteBuffer. No native code, so both implementations share them, mirroringoshi.driver.common.unix.aix.oshi-common, with concrete<Os>FooJNA(oshi-core) and<Os>FooFFM(oshi-core-ffm) subclasses. This removes the duplicatedupdateAttributeslogic and drops the FQN-extends awkwardness.AixOSFileStore.PsInfo; the JNAPsInfois renamedPsInfoJNA(keeps only thepread-based arg/env read) andPsInfoFFMkeeps only thepargs-based read. The now-unused psinfo/lwpsinfo/prusage JNA structs are removed fromSolarisLibc.Kstat2 stays JNA-only (intentional)
HAS_KSTAT2, the dual-path file-descriptor counts, system uptime/boot time, and thegetSessions()override remain inSolarisOperatingSystemJNA/SolarisFileSystemJNA. FFM uses the legacy kstat chain only — kstat2 exists only on the JDK 17-capped latest Solaris, and illumos forked before it, so FFM (JDK 25) never needs it.Incidental FFM fix
The FFM
prusagePOJO had droppedpr_ioch, so FFM never populatedOSProcess.getBytesRead()while the JNA side did. The common carrier restores it, so both implementations report it again.Net ~830 fewer lines. Full clean reactor build plus spotless/checkstyle/forbiddenapis/javadoc all pass locally.
Summary by CodeRabbit
Release Notes
New Features
Improvements