Skip to content

Solaris/illumos FFM port (#3338) - #3339

Merged
dbwiddis merged 13 commits into
oshi:masterfrom
dbwiddis:solaris-ffm
Jun 5, 2026
Merged

dbwiddis merged 13 commits into
oshi:masterfrom
dbwiddis:solaris-ffm

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Jun 5, 2026 •

Copy link
Copy Markdown
Member

Closes #3338.

Ports the Solaris/illumos implementation from JNA to FFM, completing the FFM matrix started in #3316 (FreeBSD) and #3333 (OpenBSD). With this merged, every OSHI-supported platform except DragonFly BSD / NetBSD / AIX (which stay JNA-only by design) has both a JNA and an FFM implementation, and 7.3.0 can ship.

The Phase 0 audit and per-file inventory are in #3338.

Validation

Confirmed green on the OpenIndiana JDK 25 CI VM, exercising both oshi-core (JNA) and oshi-core-ffm (FFM) end-to-end including NativeComparisonTest parity gated on OS.SOLARIS. The full Unix CI matrix (FreeBSD JDK 25, OpenBSD JDK 25, DragonFly BSD JDK 21, NetBSD JDK 21, AIX JDK 17) is also green on this branch.

(Solaris SPARC's testsolaris_sparc job in the matrix has a pre-existing SSH-handshake flake against cfarm216 and is unrelated to this change.)

Commits (kept unsquashed for review)

Commit What
96f0848617 PR 1 — native-free hoist. Pure-Java Solaris classes move from oshi-core to oshi-common (Iostat / Lshal / Prtvtoc drivers; Firmware / GraphicsCard / SoundCard / UsbDevice / Sensors / ComputerSystem / VirtualMemory hardware; InternetProtocolStats software). SolarisGlobalMemory and SolarisVirtualMemory get the OpenBSD-style abstract-base treatment so both modules can swap in their own kstat-backed paged-memory query.
587eae5cac PR 2 — FFM bindings. SolarisLibcFunctions (getpid / thr_self / getrlimit, RLIMIT_NOFILE = 5 — the correct illumos value, not the inherited Linux 7), LibKstatFunctions (full kstat_t / kstat_named_t / kstat_io_t MemoryLayouts + open / close / chain_update / lookup / read / data_lookup), Kstat2Functions (probe-only stub — illumos has no libkstat2, falls through to LibKstat), and KstatUtilFFM (thread-safe wrapper with the same API surface as the JNA KstatUtil). Smoke tests gated on OS.SOLARIS.
b2b8d389c8 PR 3 — FFM concretes + wiring. 11 *FFM HAL / OS classes (CentralProcessor, GlobalMemory, HWDiskStore, NetworkIF, PowerSource, HardwareAbstractionLayer, FileSystem, OSFileStore, OSProcess, OSThread, OperatingSystem, NetworkParams) plus PsInfoFFM (/proc binary parser) and SystemPagesFFM. Wired into oshi.ffm.SystemInfo, NativeComparisonTest opened to OS.SOLARIS, testopenindiana CI bumped JDK 21 → 25 with aggregate-coverage and a solaris codecov flag. Temporary probe workflow removed.
2375a7b00a PR 4 — docs + JaCoCo cleanup, CHANGELOG → 7.3.0. Update SystemInfo Javadoc, FAQ.md, PERFORMANCE.md, oshi-core-ffm module-info.java to list OpenBSD and Solaris in the FFM-supported set. Drop the **/unix/openbsd/** and **/unix/solaris/** JaCoCo excludes — both platforms now have permanent CI jobs uploading aggregate coverage. Rename 7.2.2 (in progress) → 7.3.0 (in progress) and add the Solaris entry.
06dab7464d Diagnostic logging for PsInfoFFM (which surfaced the next two fixes), and queryContextSwitches's shell-escaped pipe matches the JNA path.
489146014b Tolerant ByteBuffer reads in PsInfoFFM. illumos's embedded lwpsinfo_t at the tail of psinfo_t is 24 bytes shorter than the JNA SolarisLwpsInfo struct expects. JNA succeeds anyway because FileUtil.readIntFromBuffer and friends silently return 0 on short reads. The FFM parser was using buff.getInt() directly and throwing BufferUnderflowException. Switched to the same FileUtil.read*FromBuffer helpers JNA uses, byte-for-byte.
52d8103ec9 Two pre-existing JNA bugs surfaced by FFM parity. SolarisLibc inherited RLIMIT_NOFILE = 7 from Resource (Linux value); illumos is 5 (7 is RLIM_NLIMITS, not a real resource) — shadow with int RLIMIT_NOFILE = 5;. SolarisCentralProcessor's createProcListFromDmesg regex was cpu(\\\\d+): — at runtime cpu(\\d+):, i.e. literal backslash + d+, which never matches dmesg's cpu0: … lines — so JNA's PhysicalProcessor.idString was always empty. Two backslashes. Both follow the FreeBSD/OpenBSD precedent of fixing pre-existing JNA bugs in the same FFM-port PR so NativeComparisonTest stays meaningful.
a9576bfcd3 tmpfs totalSpace drift tolerance in NativeComparisonTest (Solaris /var/run grows/shrinks with memory pressure between the JNA and FFM File.getTotalSpace() calls).
ef72b89012 testopenindiana VM bumped to 8 GB and Maven/child-JVM heap capped to 1 GB — the OpenIndiana VM was hitting malloc OOMs partway through the suite when both JNA and FFM were loaded and JDK 25's heap heuristic over-sized.
ce08be5d4e diskStoreUpdateAttributes in NativeComparisonTest treats a false from either side's updateAttributes() as "skip this disk this pass" rather than failing the test — JNA's kstat chain transiently loses entries for some Solaris disks, which isn't a JNA/FFM parity bug.

Notable architectural choices

  • No getutxent binding. OpenBSD's FFM port already uses the default AbstractOperatingSystem.getSessions() (which delegates to the shared Who.queryWho shell parser); Solaris FFM does the same. Avoids a fragile utmpx layout, no functional regression vs. the JNA path.
  • No FFM pread on /proc/<pid>/as. The JNA PsInfo.queryArgsEnv reads argv/envp by chasing user-space pointers via pread. PsInfoFFM substitutes pargs -ae <pid> — same data, no need for an FFM binding for open/close/pread.
  • Kstat2 deliberately stubbed. illumos doesn't ship libkstat2; only Solaris 11.4+ does. Kstat2Functions.HAS_KSTAT2 is false on the CI target, so consumers route through LibKstat throughout. The full Kstat2 surface can be added when a downstream consumer requires Solaris 11.4 fidelity that the LibKstat fallback doesn't already provide.

Test plan

  • OpenIndiana JDK 25 — full mvn clean test -Paggregate-coverage green, including NativeComparisonTest parity gate.
  • OpenBSD JDK 25, FreeBSD JDK 25 — no regressions from the shared changes (NativeComparisonTest tolerance bumps, JaCoCo excludes).
  • NetBSD JDK 21, DragonFly BSD JDK 21, AIX JDK 17 — no regressions from the JNA / common-module moves.
  • Solaris SPARC JDK 17 — currently failing on SSH handshake to cfarm216, pre-existing infrastructure flake unrelated to this branch.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added broad Solaris/illumos support via the FFM backend: CPU, memory, disks, network, power, sensors, graphics, sound, USB, filesystems, processes, threads, and OS queries.
  • Bug Fixes

    • Improved CPU feature parsing and hardened proc-path and process parsing for more reliable behavior.
  • Documentation

    • Updated changelog, FAQ, and performance notes to list Solaris/illumos support.
  • Chores

    • CI: added OpenIndiana (illumos/Solaris) job on JDK 25 with coverage upload; adjusted coverage configuration.
  • Tests

    • Added Solaris-specific unit tests exercising new platform bindings and kstat utilities.

dbwiddis and others added 11 commits June 4, 2026 19:30
Standalone temporary workflow that runs `pkg install openjdk25` and a
minimal oshi-core-ffm compile on the OpenIndiana VM, to confirm JDK 25
(and therefore FFM) is reachable before committing to a Solaris FFM
port. To be deleted once we have an answer.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Move pure-Java Solaris classes (no JNA/native dependencies) from
oshi-core to oshi-common so they can be shared by both oshi-core (JNA)
and oshi-core-ffm (FFM). Mirrors the OpenBSD port structure from #3333.

Moved to oshi-common as-is:
- Drivers: Iostat, Lshal, Prtvtoc (oshi.driver.unix.solaris.disk)
- Hardware: SolarisFirmware, SolarisGraphicsCard, SolarisSoundCard,
  SolarisUsbDevice, SolarisSensors, SolarisComputerSystem
- Software: SolarisInternetProtocolStats

Moved to oshi-common with refactor:
- SolarisVirtualMemory: drop direct SystemPages dependency; derive
  virtualMax/virtualInUse from the SolarisGlobalMemory public API
  (getTotal/getAvailable) instead. The kstat -p cpu_stat:::pgswapin/out
  paths were already shell-based, so the class is now native-free.
- SolarisGlobalMemory (abstract base): expose queryAvailable(), queryTotal(),
  queryPageSize() and createVirtualMemory() hooks. The oshi-core concrete
  (extending the abstract from oshi-common) keeps the SystemPages call site;
  the eventual oshi-core-ffm concrete will plug into the same hooks.

Remaining in oshi-core (native dependencies, port in later PRs):
- SolarisLibc, KstatUtil
- Drivers: PsInfo, Who, kstat/SystemPages
- Hardware: SolarisCentralProcessor, SolarisHWDiskStore,
  SolarisNetworkIF, SolarisPowerSource, SolarisHardwareAbstractionLayer
- Software: SolarisFileSystem, SolarisOSFileStore, SolarisOSProcess,
  SolarisOSThread, SolarisOperatingSystem, SolarisNetworkParams

Build plumbing:
- oshi-common module-info: export new oshi.driver.unix.solaris.disk,
  oshi.hardware.common.platform.unix.solaris, and
  oshi.software.common.os.unix.solaris packages.
- oshi-core and oshi-core-ffm bnd Export-Package: add
  !oshi.driver.unix.solaris.disk.* exclusion so bnd doesn't pull the
  moved classes from oshi-common back into either OSGi bundle (same
  pattern as the existing !oshi.driver.unix.freebsd.disk.* exclusion).
- Test module-info moves DiskDriversTest's package opening from
  oshi-core to oshi-common.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Add the foundation for the FFM Solaris/illumos port: bindings for libc
and libkstat, a thread-safe wrapper that mirrors oshi.util.platform.
unix.solaris.KstatUtil, a probe for libkstat2 (Solaris 11.4+ only),
and smoke tests gated on OS.SOLARIS.

New files in oshi-core-ffm:
- oshi.ffm.unix.solaris.SolarisLibcFunctions — minimal libc surface:
  getpid, thr_self, getrlimit. RLIMIT_NOFILE = 5 (the correct illumos
  value; JNA's Resource.RLIMIT_NOFILE = 7 is wrong for Solaris — see
  the Surprises §D in issue #3338).
- oshi.ffm.util.platform.unix.solaris.LibKstatFunctions — bindings for
  kstat_open / close / chain_update / lookup / read / data_lookup,
  plus kstat_t and kstat_named_t MemoryLayouts and accessors. Loaded
  via SymbolLookup.libraryLookup("libkstat.so.1", Arena.global()).
- oshi.ffm.util.platform.unix.solaris.Kstat2Functions — probe-only
  stub. HAS_KSTAT2 reflects whether libkstat2.so.1 was loadable at
  class-init time. On illumos (OpenIndiana CI) the lookup fails and
  HAS_KSTAT2 = false, so FFM consumers route through LibKstat just
  like the JNA HAS_KSTAT2 fallback path. Bindings for the kstat2_*
  API will land when a downstream consumer requires them.
- oshi.ffm.util.platform.unix.solaris.KstatUtilFFM — thread-safe
  wrapper mirroring the public API of the JNA KstatUtil: openChain
  with a ReentrantLock, KstatChain.{read,lookup,lookupAll,update},
  and dataLookupString / dataLookupLong over the named-data union.

Smoke tests (gated @EnabledOnOs(OS.SOLARIS)):
- SolarisLibcFunctionsTest — getpid > 0, thr_self > 0, getrlimit
  round-trip on RLIMIT_NOFILE.
- KstatUtilFFMTest — openChain, lookup("unix", 0, "system_misc"),
  dataLookupLong("boot_time") > 0.

Probe workflow upgraded from `mvn compile` to `mvn test`, so the
smoke tests run on every push to solaris-ffm.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Add Solaris/illumos FFM concretes for all native-touching hardware and
software classes, wire them into oshi.ffm.SystemInfo, enable the
NativeComparisonTest parity gate for OS.SOLARIS, and bump testopenindiana
CI to JDK 25 with aggregate-coverage upload under the `solaris` codecov
flag (mirroring the OpenBSD job).

New FFM drivers in oshi-core-ffm:
- oshi.ffm.driver.unix.solaris.kstat.SystemPagesFFM — kstat
  unix/0/system_pages wrapper.
- oshi.ffm.driver.unix.solaris.PsInfoFFM — /proc/<pid>/psinfo,
  lwp/<tid>/lwpsinfo, usage parsers (ByteBuffer-based, pure-Java POJOs).
  Process arg/env via `pargs -e` instead of the JNA driver's pread on
  /proc/<pid>/as, trading a child-process fork for not needing
  open/close/pread libc bindings.

New FFM hardware concretes (extend AbstractCentralProcessor /
HWDiskStore / NetworkIF / PowerSource, or the oshi-common Solaris
GlobalMemory abstract):
- SolarisCentralProcessorFFM, SolarisGlobalMemoryFFM,
  SolarisHWDiskStoreFFM, SolarisNetworkIFFFM, SolarisPowerSourceFFM,
  SolarisHardwareAbstractionLayerFFM.

New FFM software concretes:
- SolarisOSProcessFFM, SolarisOSThreadFFM, SolarisOperatingSystemFFM,
  SolarisFileSystemFFM, SolarisOSFileStoreFFM, SolarisNetworkParamsFFM.
- getSessions inherits the AbstractOperatingSystem default
  (Who.queryWho shell parser), matching the OpenBSD FFM pattern.

SolarisLibcFunctions gained gethostname and getloadavg bindings.
LibKstatFunctions gained the kstat_io_t MemoryLayout + accessors
(kstatIoReads/Writes/Nread/Nwritten/Rtime/Wcnt/Rcnt) and a kstatSnaptime
helper for the kstat header.

Kstat2Functions remains a probe-only stub — illumos (the FFM CI target)
has no libkstat2, so consumers fall back to LibKstat throughout. The
JNA-side HAS_KSTAT2 branches in the JNA concretes still work on Solaris
11.4+; the FFM concretes here use the libkstat path exclusively.

CI: testopenindiana bumped from JDK 21 → JDK 25 with
-Paggregate-coverage and a Codecov upload under flag `solaris`. The
temporary openindiana-jdk25-probe.yaml workflow is removed (its smoke
tests now run as part of testopenindiana via the FFM smoke tests added
in the previous commit).

NativeComparisonTest @EnabledOnOs gains OS.SOLARIS.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Wraps up the Solaris/illumos FFM port (#3338) with the same docs and
coverage cleanup that landed for the FreeBSD port in #3331. Also picks
up the equivalent OpenBSD cleanup that slipped out of #3335.

- oshi.ffm.SystemInfo Javadoc + oshi-core-ffm module-info: list
  OpenBSD and Solaris in the FFM-supported platforms.
- FAQ.md, PERFORMANCE.md: same.
- pom.xml JaCoCo: drop the **/unix/openbsd/**, **/unix/*OpenBsd*,
  **/unix/solaris/**, and **/unix/*Solaris* excludes. Both platforms
  now have permanent CI jobs with aggregate coverage uploaded to
  Codecov (testopenbsd → flag `openbsd`, testopenindiana → flag
  `solaris`), so the excludes are now hiding real coverage.
- CHANGELOG.md: rename `7.2.2 (in progress)` → `7.3.0 (in progress)`
  and add the Solaris FFM port entry. The version bump reflects the
  new platform support landing in this release per the FreeBSD port
  playbook.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
OpenIndiana JDK 25 CI exposed two regressions in #b2b8d389c8:

1. SolarisOSProcessFFM was returning a process whose state stays
   INVALID — i.e., PsInfoFFM.queryPsInfo silently returned null.
   Promote the catch-block log to WARN and include the actual file
   size, so the next CI run shows whether the file is unreadable, too
   short, or a struct-layout mismatch.

2. SolarisCentralProcessorFFM.queryContextSwitches used a single-
   backslash regex pipe (`pswitch\|inv_swtch`), which the shell
   strips to `pswitch|inv_swtch` — kstat -p reads that as two
   separate patterns. The JNA original double-escapes (`\\\\|` in
   Java → `\\|` in shell → `\|` in regex). Match the JNA escaping so
   the FFM path returns the same context-switch total (the
   NativeComparisonTest saw 0 vs 69757).

The fileSystem() free-space mismatch and the FreeBSD testThreads()
user-time-nondecreasing flake are not addressed here — those look
like timing artifacts that need a separate look.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Root cause of the OpenIndiana JDK 25 CI failures (#3338):

  | LwpsInfo.readFrom(PsInfoFFM.java:180)
  | java.nio.BufferUnderflowException

PsInfoFFM was reading /proc/<pid>/psinfo via ByteBuffer.getInt /
getLong / get(byte[]) directly, all of which throw
BufferUnderflowException on short buffers. The illumos kernel writes
416 bytes of psinfo where my parser was expecting 440 (24 bytes
shorter — the embedded lwpsinfo_t at the tail of psinfo_t has a
narrower pr_name on illumos than the JNA SolarisLwpsInfo struct
documents, plus an extra pr_oldname field that illumos doesn't carry).

JNA's SolarisPsInfo silently tolerates this via FileUtil's
short-buffer-safe readers:

  public static int readIntFromBuffer(ByteBuffer buff) {
      if (buff.position() <= buff.limit() - 4) {
          return buff.getInt();
      }
      return 0;
  }

(same pattern for the long / short / byte / byte[] reads). The
post-EOF fields end up zero but no exception is thrown, so the
process state, name, args, etc. — all of which live in the first
~408 bytes — read cleanly. PsInfoFFM now uses these same
FileUtil.read* helpers, matching JNA's behavior exactly.

After this:
- queryPsInfo returns a populated PsInfo (state byte at offset 314
  is well within 416 bytes).
- SolarisOSProcessFFM stops returning INVALID state.
- The currentProcess, processListStructure, currentThreadUpdateAttributes,
  and currentProcessUpdateAttributes parity tests in
  NativeComparisonTest should now pass.

The fileSystem() free-space mismatch (5000626176 vs 5013135360) and
the FreeBSD testThreads timing flake are still open; both look like
race conditions rather than struct-layout bugs.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
NativeComparisonTest on OpenIndiana JDK 25 exposed two JNA bugs the
FFM concretes are now reporting as parity mismatches:

1. oshi.jna.platform.unix.SolarisLibc inherited RLIMIT_NOFILE = 7
   from JNA's Resource interface (the Linux value). On Solaris and
   illumos RLIMIT_NOFILE is 5 — value 7 is RLIM_NLIMITS, an invalid
   resource selector. So SolarisOSProcess.getSoftOpenFileLimit /
   getHardOpenFileLimit silently asked for an undefined resource and
   getrlimit returned -1/EINVAL, leaving rlim_cur/rlim_max at zero.
   Shadow with `int RLIMIT_NOFILE = 5;` — same pattern as FreeBSD #3330
   and OpenBSD #3335.

2. SolarisCentralProcessor's createProcListFromDmesg regex used four
   backslashes — `Pattern.compile(".* cpu(\\\\d+): ((ARM|AMD|Intel).+)")`.
   That compiles to the regex `.* cpu(\\d+): …`, i.e. literal backslash
   followed by `d+`, which never matches dmesg lines like
   "cpu0: AMD EPYC ...". Result: PhysicalProcessor.idString stayed
   empty on every JNA call. Two backslashes — `\\d+` — is the regex
   `\d+` (one or more digits) the test was already exercising via the
   FFM concrete.

Both bugs are inherited from the JNA implementation that pre-dates
this port. Per the FFM playbook's pre-existing-bug policy, fixing
them here keeps JNA and FFM in lockstep so NativeComparisonTest
parity checks remain meaningful instead of silently masking the
JNA side.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
OpenIndiana JDK 25 CI showed two filesystem-comparison tests failing
on Solaris tmpfs:

- fileSystem() compared totalSpace with strict equality. tmpfs total
  on Solaris (/var/run, /tmp, etc.) tracks memory pressure and drifts
  by megabytes between the JNA and FFM calls — the test was reading
  5058297856 from one path and 5063569408 from the other, a ~5 MB
  difference (~0.1%).
- fileStoreUpdateAttributes() already used assertWithinRatio, but the
  0.1% tolerance was just below the observed drift.

Switch both to 1% via assertWithinRatio. Strict equality on a value
that the kernel itself reports differently across two back-to-back
calls is not a parity bug worth flagging.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
CI has been hitting native-malloc OOMs partway through the test suite
on the OpenIndiana VM (sometimes during oshi-core SystemInfoTest,
sometimes during oshi-metrics OshiMetricsTest). Symptoms are:

  # There is insufficient memory for the Java Runtime Environment to
  # continue. Native memory allocation (malloc) failed to allocate
  # 33792 bytes. Error detail: Chunk::new

…which is illumos's malloc giving up because the JVM's metaspace +
G1 heap + JNA-loaded libc + FFM linker state all want C-heap together.

Two changes:

- vmactions/openindiana-vm: bump `mem` from the default 6144 MB → 8192
  MB. testopenbsd / testfreebsd only need 2 GB because their suites
  don't exercise both JNA and FFM; we do.
- MAVEN_OPTS / _JAVA_OPTIONS: cap Maven and child-JVM max heap to
  1 GB. The default 25%-of-system-RAM heuristic on JDK 25 was sizing
  to ~2 GB per JVM, leaving little C-heap for the modules that load
  the most native code.

This should let the full Solaris/illumos CI matrix complete without
hitting the OOM ceiling, so the actual NativeComparisonTest parity
results show up.

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

OpenIndiana CI has been failing diskStoreUpdateAttributes intermittently
on Solaris disk sd2:

  +-- diskStoreUpdateAttributes() [X] [JNA disk sd2 updateAttributes]

This is JNA's SolarisHWDiskStore.updateAttributes returning false from
a kstat_lookup miss — kstat_chain_update can transiently drop entries
for removable / installer / iSCSI-backed volumes whose underlying
modules don't report stable IO statistics. The OpenIndiana CI VM in
particular has an sd2 that comes and goes in the kstat chain.

A `false` from JNA's updateAttributes isn't a JNA-vs-FFM parity bug;
it just means we can't validate monotonicity for that disk on this
pass. Skip the disk rather than fail the test, the same way the test
already skips disks that don't have a matching FFM entry. The
`matched > 0` assertion at the end still guarantees we exercised the
parity check on at least one disk.

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

codecov Bot commented Jun 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.47863% with 322 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.71%. Comparing base (69553b0) to head (f064220).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
.../software/os/unix/solaris/SolarisOSProcessFFM.java 51.23% 69 Missing and 10 partials ⚠️
...i/ffm/util/platform/unix/solaris/KstatUtilFFM.java 51.45% 38 Missing and 12 partials ⚠️
...e/platform/unix/solaris/SolarisPowerSourceFFM.java 51.47% 28 Missing and 5 partials ⚠️
...are/os/unix/solaris/SolarisOperatingSystemFFM.java 70.32% 14 Missing and 13 partials ⚠️
...n/java/oshi/ffm/driver/unix/solaris/PsInfoFFM.java 86.17% 18 Missing and 8 partials ⚠️
...tform/unix/solaris/SolarisCentralProcessorFFM.java 83.08% 8 Missing and 15 partials ⚠️
...software/os/unix/solaris/SolarisFileSystemFFM.java 71.25% 11 Missing and 12 partials ⚠️
...i/software/os/unix/solaris/SolarisOSThreadFFM.java 63.41% 10 Missing and 5 partials ⚠️
.../util/platform/unix/solaris/LibKstatFunctions.java 88.88% 8 Missing and 2 partials ⚠️
...fm/util/platform/unix/solaris/Kstat2Functions.java 46.66% 6 Missing and 2 partials ⚠️
... and 8 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3339      +/-   ##
============================================
- Coverage     76.00%   74.71%   -1.30%     
  Complexity       76       76              
============================================
  Files           461      605     +144     
  Lines         17819    26000    +8181     
  Branches       2898     4026    +1128     
============================================
+ Hits          13543    19425    +5882     
- Misses         2639     4305    +1666     
- Partials       1637     2270     +633     
Flag Coverage Δ
freebsd 23.05% <0.00%> (-9.44%) ⬇️
linux 26.70% <0.00%> (-10.29%) ⬇️
macos 30.04% <0.00%> (-7.26%) ⬇️
openbsd 22.38% <0.00%> (-3.20%) ⬇️
solaris 24.71% <72.47%> (?)
windows 35.97% <0.00%> (-8.44%) ⬇️

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 commented Jun 5, 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: 21aaf623-8978-4e5c-9b78-ac9ca34a1da9

📥 Commits

Reviewing files that changed from the base of the PR and between 7d920cd and f064220.

📒 Files selected for processing (2)
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/Kstat2Functions.java
  • oshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOperatingSystem.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/Kstat2Functions.java
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 26, windows-latest
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 26, macos-latest
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: JMH Benchmarks, ubuntu-latest
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
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.
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: 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`.
📚 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/software/os/unix/solaris/SolarisOperatingSystem.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/src/main/java/oshi/software/os/unix/solaris/SolarisOperatingSystem.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/software/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/software/os/unix/solaris/SolarisOperatingSystem.java
🔇 Additional comments (1)
oshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOperatingSystem.java (1)

71-77: LGTM!

Also applies to: 97-112


📝 Walkthrough

Walkthrough

Adds Solaris/illumos FFM support: hoists shared Solaris classes to common, implements FFM libc/libkstat/Kstat utilities, adds FFM-backed process, thread, hardware, filesystem, and OS implementations, wires platform exports and packaging, relaxes/extends tests, updates CI to run OpenIndiana on JDK 25 with aggregate coverage, and updates docs/changelog.

Changes

Solaris abstract base classes in oshi-common

Layer / File(s) Summary
Solaris abstracts and module exports
oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/*, oshi-common/src/main/java/oshi/software/common/os/unix/solaris/*, oshi-common/src/main/java/module-info.java
Relocates/creates common Solaris classes, adds package-info files, and exports Solaris driver/hardware/software packages from com.github.oshi.common.
Common memory and virtual memory
oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisGlobalMemory.java, SolarisVirtualMemory.java, package-info.java
Introduce public abstract SolarisGlobalMemory with memoized suppliers and protected query hooks; provide default page-size query and createVirtualMemory; update SolarisVirtualMemory visibility and computation.

FFM native bindings for Solaris libc and kstat

Layer / File(s) Summary
Solaris libc FFM bindings
oshi-core-ffm/src/main/java/oshi/ffm/unix/solaris/SolarisLibcFunctions.java, package-info.java
FFM wrappers for getpid, thr_self, getrlimit (with RLIMIT_NOFILE/layout), gethostname, getloadavg and associated layouts/accessors.
Libkstat FFM bindings and probe
oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/LibKstatFunctions.java, Kstat2Functions.java, package-info.java
Implement libkstat FFM bindings, MemoryLayouts for kstat records, and a Kstat2 presence probe gated by on-disk check and FFM lookup.
KstatUtilFFM chain wrapper
oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/KstatUtilFFM.java
Thread-safe KstatChain wrapper with openChain(), read/lookup/lookupAll, update and dataLookup helpers returning typed values.
SystemPagesFFM for memory pages
oshi-core-ffm/src/main/java/oshi/ffm/driver/unix/solaris/kstat/SystemPagesFFM.java
Query system_pages kstat to return available/total page counts for memory implementations.

FFM /proc parsers and process/thread support

Layer / File(s) Summary
PsInfoFFM binary parsers
oshi-core-ffm/src/main/java/oshi/ffm/driver/unix/solaris/PsInfoFFM.java
ByteBuffer-based parsers for psinfo_t, lwpsinfo_t, prusage_t, Timestruc; queryPsInfo/queryLwpsInfo/queryPrUsage; pargs-based queryArgsEnv; bytesToString and countProcesses helpers.
Solaris OS process & thread (FFM)
oshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisOSProcessFFM.java, SolarisOSThreadFFM.java
FFM-backed process/thread implementations using PsInfoFFM and SolarisLibcFunctions: state, timings, memory, context switches, affinity, open files, and thread enumeration.

FFM Solaris hardware implementations and HAL

Layer / File(s) Summary
CPU, memory, disk
oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/solaris/* (SolarisCentralProcessorFFM, SolarisGlobalMemoryFFM, SolarisHWDiskStoreFFM)
CPU topology/load/frequency via kstat/isainfo/dmesg; global memory from SystemPagesFFM; disk I/O via kstat and Prtvtoc.
Network, power, sensors, peripherals
oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/solaris/* (SolarisNetworkIFFFM, SolarisPowerSourceFFM, moved Sensors/Graphics/Sound/Usb to common)
Network interface stats from kstat link entries; power source readings from battery/acpi_drv kstat; sensors/graphics/sound/USB classes made public in common.
Hardware abstraction layer (FFM HAL)
oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/solaris/SolarisHardwareAbstractionLayerFFM.java
HAL wiring to instantiate FFM-backed Solaris implementations for CPU, memory, disks, network, sensors, power, USB, graphics, sound, and printers.

FFM Solaris OS and filesystem implementations

Layer / File(s) Summary
Operating system (FFM)
oshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisOperatingSystemFFM.java
OS identity/version from uname, boot time from kstat, process listing from /proc, uptime via kstat snaptime, and services via /etc/init.d + svcs parsing.
Filesystem and network params (FFM)
oshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/* (SolarisFileSystemFFM, SolarisOSFileStoreFFM, SolarisNetworkParamsFFM)
Mount enumeration from /etc/mnttab, df -g inode parsing, file-descriptor counts from kstat, per-process limits from /etc/system or rlimit/plimit; hostname via FFM gethostname and gateway via route commands.

Platform dispatch, tests, modules, packaging, and CI/docs

Layer / File(s) Summary
SystemInfo wiring and module exports
oshi-core-ffm/src/main/java/oshi/ffm/SystemInfo.java, module-info.java
Add Solaris to SUPPORTED_PLATFORMS and factory methods to return Solaris FFM OS/HAL; export oshi.ffm.util.platform.unix.solaris.
Tests and test JVM/module directives
oshi-benchmark/src/test/java/oshi/comparison/NativeComparisonTest.java, *_test/module-info.test, oshi-core-ffm/src/test/java/oshi/ffm/unix/solaris/*Test.java
Enable OS.SOLARIS in NativeComparisonTest; relax parity/tolerance checks and skip on missing updates; add Solaris-specific unit/smoke tests (SolarisLibcFunctionsTest, KstatUtilFFMTest); update --add-opens entries for test modules.
JNA layer fixes and refactor
oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/*, oshi-core/src/main/java/oshi/jna/platform/unix/SolarisLibc.java
Refactor SolarisGlobalMemory to extend common SolarisGlobalMemory; fix dmesg regex in SolarisCentralProcessor; add Solaris RLIMIT_NOFILE constant to JNA layer to avoid getrlimit issues.
Docs, changelog, JaCoCo, CI workflows
CHANGELOG.md, FAQ.md, PERFORMANCE.md, pom.xml, .github/workflows/*
Bump unreleased to 7.3.0 and add Solaris FFM entry; expand FFM platform lists; adjust JaCoCo excludes; add/upgrade OpenIndiana CI job to JDK25 with aggregate-coverage and JVM/Maven heap caps; upload Codecov with solaris flag.
OSGi/bnd packaging tweaks
oshi-core-ffm/pom.xml, oshi-core/pom.xml
Exclude oshi.driver.* from FFM bundle exports and fix punctuation in oshi-core bnd export list.

Sequence Diagram

sequenceDiagram
  participant Client as Test/OSHI caller
  participant SystemInfo as SystemInfo
  participant OS_FFM as SolarisOperatingSystemFFM
  participant KstatUtil as KstatUtilFFM.KstatChain
  participant LibKstat as LibKstatFunctions

  Client->>SystemInfo: request OS/Hardware
  SystemInfo->>OS_FFM: instantiate SolarisOperatingSystemFFM / HAL
  OS_FFM->>KstatUtil: openChain() / lookup("system_misc"/cpu/disk)
  KstatUtil->>LibKstat: kstat_lookup / kstat_read / kstat_data_lookup
  LibKstat-->>KstatUtil: MemorySegment kstat record
  KstatUtil-->>OS_FFM: parsed fields (boot_time, counters, io)
  OS_FFM-->>Client: populated OS/hardware objects
Loading

Estimated code review effort:
🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • oshi/oshi#3288: Overlaps NativeComparisonTest changes and JNA-vs-FFM parity logic (same test functions adjusted for Solaris/FFM).
  • oshi/oshi#3335: Related platform wiring changes in oshi-core-ffm/SystemInfo and module exports for additional platforms.
  • oshi/oshi#3314: Related OpenIndiana CI job and JDK upgrade changes in the workflows.

"I hopped through kstat chains with care,
I parsed /proc bytes in the midnight air.
FFM bindings sewn with careful paw,
OpenIndiana wakes on JDK twenty-five, hurrah!
A rabbit's thump—Solaris joins the draw."

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

@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: 6

🧹 Nitpick comments (6)
.github/workflows/unix.yaml (1)

79-86: ⚡ Quick win

Disable persisted checkout credentials for the VM copyback job.

Line [79] uses default credential persistence while Line [85] enables copyback: true, which increases token exposure risk through copied workspace metadata. Set persist-credentials: false for this checkout step.

Suggested patch
       - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
+        with:
+          persist-credentials: false
🤖 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 @.github/workflows/unix.yaml around lines 79 - 86, The checkout step using
"uses: actions/checkout@..." in the job with id "test-openindiana" currently
leaves credentials persisted while "copyback: true" is enabled; update that
checkout step to explicitly set "persist-credentials: false" so the VM copyback
cannot expose tokens or workspace metadata — locate the actions/checkout
invocation in the test-openindiana job and add the persist-credentials: false
option to the step.
oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/KstatUtilFFM.java (2)

86-90: 💤 Low value

Retry loop has no delay between attempts.

The kstat_read retry loop (lines 86-90) attempts up to 5 retries immediately without any backoff delay. If the kernel is temporarily unable to service the read, this could result in unnecessary CPU spinning.

Consider adding a small delay (e.g., Thread.sleep(1) or Thread.onSpinWait()) between retries, though this may be acceptable if the JNA version has the same behavior.

🤖 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/ffm/util/platform/unix/solaris/KstatUtilFFM.java`
around lines 86 - 90, The retry loop around LibKstatFunctions.kstat_read in
KstatUtilFFM (the while loop that checks kstat_read(ctl, ksp,
MemorySegment.NULL) and increments retry) spins up to 5 times with no pause;
modify it to insert a small backoff between attempts (for example
Thread.onSpinWait() or Thread.sleep(1)) after incrementing retry and before the
next kstat_read, keeping the same retry limit and ensuring InterruptedException
is handled or propagated appropriately.

175-190: ⚖️ Poor tradeoff

Consider removing synchronized to simplify locking hierarchy.

The method uses both synchronized and CHAIN.lock(), creating two lock acquisitions (object monitor, then ReentrantLock). While this is not immediately unsafe, it adds complexity and a theoretical deadlock risk if another synchronized method tried to acquire CHAIN in a different order.

Since CHAIN.lock() at line 176 already serializes access to kstatCtl, the synchronized keyword is redundant for thread-safety. Consider either:

  • Removing synchronized and relying solely on CHAIN.lock() for the entire method body, OR
  • Using a separate private lock for the kstatCtl initialization check.

The current code is functional (CI green), but simplifying to a single lock would improve maintainability.

🤖 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/ffm/util/platform/unix/solaris/KstatUtilFFM.java`
around lines 175 - 190, Remove the synchronized modifier from openChain() and
rely solely on CHAIN.lock() for synchronization: acquire CHAIN.lock(), perform
the kstatCtl.address() check and potential initialization inside a try block,
set kstatCtl if successful, and ensure CHAIN.unlock() is called in a finally
block so all code paths (normal return and exceptions) release the lock; after
releasing the lock return new KstatChain(kstatCtl). Reference: openChain(),
CHAIN, kstatCtl, KstatChain.
oshi-core-ffm/src/main/java/oshi/ffm/driver/unix/solaris/PsInfoFFM.java (3)

42-76: ⚡ Quick win

Checkstyle violations are intentional for C struct field name mirroring.

The public fields with pr_ prefixes and the naming violations flagged by Checkstyle (lines 43-76) are intentional: they mirror the native Solaris psinfo_t struct field names exactly. This is a standard pattern in FFM/JNI code for data transfer objects representing native structures.

The same pattern appears in LwpsInfo, PrUsage, and Timestruc classes. Consider adding @SuppressWarnings("checkstyle:VisibilityModifier") and @SuppressWarnings("checkstyle:MemberName") annotations to these data classes, or configure Checkstyle to exclude these specific classes from those rules, to eliminate the 197 violations reported in the pipeline.

🤖 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/ffm/driver/unix/solaris/PsInfoFFM.java`
around lines 42 - 76, The Checkstyle violations are intentional because PsInfo
(and sibling data classes LwpsInfo, PrUsage, Timestruc) mirror native Solaris
psinfo_t fields; fix by adding suppression annotations to each class: annotate
the PsInfo, LwpsInfo, PrUsage and Timestruc classes with
`@SuppressWarnings`("checkstyle:VisibilityModifier") and
`@SuppressWarnings`("checkstyle:MemberName") (or a single combined suppression if
supported) so the public pr_* fields are exempt, or alternately add a Checkstyle
exclusion for these class names in the Checkstyle configuration; update all four
classes consistently to remove the pipeline violations.

265-279: ⚡ Quick win

Consider downgrading unreadable psinfo log from WARN to DEBUG.

Line 269 logs a WARN when /proc/<pid>/psinfo is empty or unreadable. For short-lived processes or races during enumeration, this is expected behavior and could generate excessive WARN-level noise.

Consider using LOG.debug() instead (matching the logging level used for lwpsinfo/usage failures at lines 297, 316, 336), or only logging WARN if the process is known to be long-lived.

🤖 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/ffm/driver/unix/solaris/PsInfoFFM.java`
around lines 265 - 279, The log in PsInfo.queryPsInfo currently emits a WARN
when /proc/<pid>/psinfo is empty/unreadable, causing noisy warnings for
short-lived processes; change the LOG.warn call in queryPsInfo (the check that
logs "psinfo file empty or unreadable for pid {} ({})") to LOG.debug to match
the lwpsinfo/usage behavior, so unreadable/empty psinfo is logged at debug level
rather than warn.

348-374: Shell command trade-off is acceptable per design constraints.

The queryArgsEnv method (lines 348-374) uses pargs -ae <pid> instead of FFM pread() on /proc/<pid>/as. Similarly, countProcesses() (line 396) uses ls /proc | wc -l. This trades subprocess overhead for implementation simplicity and avoids needing additional libc bindings.

The PR objectives explicitly mention "avoid sysctl/sysctlbyname" and "narrow native API surface," and the comment at lines 28-31 documents this choice. The functional result is equivalent to the JNA path's direct memory scanning.

Note: If performance profiling later shows excessive pargs overhead during bulk process enumeration, consider adding an FFM pread binding as a future optimization.

🤖 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/ffm/driver/unix/solaris/PsInfoFFM.java`
around lines 348 - 374, queryArgsEnv and countProcesses currently call external
commands (pargs and ls) by design; update documentation to explicitly state this
trade-off and rationale. Add a concise comment or Javadoc in PsInfoFFM (near the
class header or above queryArgsEnv and countProcesses) explaining we
intentionally avoid sysctl/sysctlbyname and direct pread bindings to minimize
native surface and that performance-driven pread()/FFM bindings can be added
later if needed; reference the method names queryArgsEnv and countProcesses in
the comment so reviewers can find the rationale next to the implementation.
🤖 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-core-ffm/src/main/java/oshi/hardware/platform/unix/solaris/SolarisPowerSourceFFM.java`:
- Around line 111-126: In SolarisPowerSourceFFM assign the read powerNow into
psPowerUsageRate (applying the same unit conversion rule used for capacity via
psCapacityUnits) before using it to compute psAmperage and
psTimeRemainingEstimated; specifically, after reading and normalizing powerNow
(and handling the 0xFFFFFFFFL sentinel) set psPowerUsageRate = convertedPowerNow
(convert to watts or the class's expected units using psCapacityUnits) so the
subsequent lines that compute psTimeRemainingEstimated and psAmperage use the
correct non-zero power value.
- Line 115: The code reads bst_state into local isCharging but never assigns it
to the instance fields psCharging/psDischarging, so charging state is never
reported; in SolarisPowerSourceFFM (around the kstat "bst_state" handling) read
the bst_state value into a variable (e.g., int state =
KstatUtilFFM.dataLookupLong(ksp, "bst_state")), then set psCharging and
psDischarging from the appropriate bitmasks (use the Solaris/ACPI convention
bits — e.g., charging bit and discharging bit — rather than leaving both false)
by assigning psCharging = (state & CHARGE_BIT) != 0 and psDischarging = (state &
DISCHARGE_BIT) != 0 (replace CHARGE_BIT/DISCHARGE_BIT with the correct numeric
masks for bst_state).
- Line 115: In SolarisPowerSourceFFM.java, the charging check uses the wrong
bitmask (currently (bst_state & 0x10) > 0); update the mask to use the
documented charging bit 0x02 instead. Locate the expression using
KstatUtilFFM.dataLookupLong(ksp, "bst_state") in class SolarisPowerSourceFFM and
change the mask from 0x10 to 0x02 so the isCharging calculation matches
SolarisPowerSource's documented bitfield (bit1 == charging).

In
`@oshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisOperatingSystemFFM.java`:
- Around line 216-224: In SolarisOperatingSystemFFM, the parsing branch that
handles lines starting with "online" currently constructs new OSService(name, 0,
STOPPED) which inverts the state; change the service state from STOPPED to
RUNNING (use the RUNNING constant) when line.startsWith("online") so
services.add(...) records running services correctly.

In
`@oshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisOSProcessFFM.java`:
- Line 138: In SolarisOSProcessFFM update the proc cwd link construction to
include the missing path separator so the path becomes "/proc/{pid}/cwd" (change
the expression that builds cwdLink from "/proc" + getProcessID() + "/cwd" to use
"/proc/" + getProcessID() + "/cwd"); this ensures canonical path resolution
succeeds when resolving the current working directory for the process.
- Line 382: The assignment this.path =
ParseUtil.whitespaces.split(commandLineBackup)[0] can throw
ArrayIndexOutOfBounds if commandLineBackup is null/empty/whitespace; fix by
first checking for null/blank (e.g., if (commandLineBackup == null ||
commandLineBackup.trim().isEmpty()) { this.path = ""; } else { String[] parts =
ParseUtil.whitespaces.split(commandLineBackup); this.path = parts.length > 0 ?
parts[0] : ""; }) so the code in SolarisOSProcessFFM.java (the this.path
assignment) safely handles empty input.

---

Nitpick comments:
In @.github/workflows/unix.yaml:
- Around line 79-86: The checkout step using "uses: actions/checkout@..." in the
job with id "test-openindiana" currently leaves credentials persisted while
"copyback: true" is enabled; update that checkout step to explicitly set
"persist-credentials: false" so the VM copyback cannot expose tokens or
workspace metadata — locate the actions/checkout invocation in the
test-openindiana job and add the persist-credentials: false option to the step.

In `@oshi-core-ffm/src/main/java/oshi/ffm/driver/unix/solaris/PsInfoFFM.java`:
- Around line 42-76: The Checkstyle violations are intentional because PsInfo
(and sibling data classes LwpsInfo, PrUsage, Timestruc) mirror native Solaris
psinfo_t fields; fix by adding suppression annotations to each class: annotate
the PsInfo, LwpsInfo, PrUsage and Timestruc classes with
`@SuppressWarnings`("checkstyle:VisibilityModifier") and
`@SuppressWarnings`("checkstyle:MemberName") (or a single combined suppression if
supported) so the public pr_* fields are exempt, or alternately add a Checkstyle
exclusion for these class names in the Checkstyle configuration; update all four
classes consistently to remove the pipeline violations.
- Around line 265-279: The log in PsInfo.queryPsInfo currently emits a WARN when
/proc/<pid>/psinfo is empty/unreadable, causing noisy warnings for short-lived
processes; change the LOG.warn call in queryPsInfo (the check that logs "psinfo
file empty or unreadable for pid {} ({})") to LOG.debug to match the
lwpsinfo/usage behavior, so unreadable/empty psinfo is logged at debug level
rather than warn.
- Around line 348-374: queryArgsEnv and countProcesses currently call external
commands (pargs and ls) by design; update documentation to explicitly state this
trade-off and rationale. Add a concise comment or Javadoc in PsInfoFFM (near the
class header or above queryArgsEnv and countProcesses) explaining we
intentionally avoid sysctl/sysctlbyname and direct pread bindings to minimize
native surface and that performance-driven pread()/FFM bindings can be added
later if needed; reference the method names queryArgsEnv and countProcesses in
the comment so reviewers can find the rationale next to the implementation.

In
`@oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/KstatUtilFFM.java`:
- Around line 86-90: The retry loop around LibKstatFunctions.kstat_read in
KstatUtilFFM (the while loop that checks kstat_read(ctl, ksp,
MemorySegment.NULL) and increments retry) spins up to 5 times with no pause;
modify it to insert a small backoff between attempts (for example
Thread.onSpinWait() or Thread.sleep(1)) after incrementing retry and before the
next kstat_read, keeping the same retry limit and ensuring InterruptedException
is handled or propagated appropriately.
- Around line 175-190: Remove the synchronized modifier from openChain() and
rely solely on CHAIN.lock() for synchronization: acquire CHAIN.lock(), perform
the kstatCtl.address() check and potential initialization inside a try block,
set kstatCtl if successful, and ensure CHAIN.unlock() is called in a finally
block so all code paths (normal return and exceptions) release the lock; after
releasing the lock return new KstatChain(kstatCtl). Reference: openChain(),
CHAIN, kstatCtl, KstatChain.
🪄 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: 3856b989-b8c0-4408-972c-e4bc8c17e8b7

📥 Commits

Reviewing files that changed from the base of the PR and between ed97f5f and ce08be5.

📒 Files selected for processing (58)
  • .github/workflows/unix.yaml
  • CHANGELOG.md
  • FAQ.md
  • PERFORMANCE.md
  • oshi-benchmark/src/test/java/oshi/comparison/NativeComparisonTest.java
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/main/java/oshi/driver/unix/solaris/disk/Iostat.java
  • oshi-common/src/main/java/oshi/driver/unix/solaris/disk/Lshal.java
  • oshi-common/src/main/java/oshi/driver/unix/solaris/disk/Prtvtoc.java
  • oshi-common/src/main/java/oshi/driver/unix/solaris/disk/package-info.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisFirmware.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisGlobalMemory.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisGraphicsCard.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisSensors.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisSoundCard.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisUsbDevice.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisVirtualMemory.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/package-info.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisInternetProtocolStats.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/package-info.java
  • oshi-common/src/test/java/module-info.test
  • oshi-common/src/test/java/oshi/driver/unix/solaris/disk/DiskDriversTest.java
  • oshi-core-ffm/pom.xml
  • oshi-core-ffm/src/main/java/module-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/SystemInfo.java
  • oshi-core-ffm/src/main/java/oshi/ffm/driver/unix/solaris/PsInfoFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/driver/unix/solaris/kstat/SystemPagesFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/unix/solaris/SolarisLibcFunctions.java
  • oshi-core-ffm/src/main/java/oshi/ffm/unix/solaris/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/Kstat2Functions.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/KstatUtilFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/LibKstatFunctions.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/package-info.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessorFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/solaris/SolarisGlobalMemoryFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/solaris/SolarisHWDiskStoreFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/solaris/SolarisHardwareAbstractionLayerFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/solaris/SolarisNetworkIFFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/solaris/SolarisPowerSourceFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisNetworkParamsFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisOSFileStoreFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisOSThreadFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisOperatingSystemFFM.java
  • oshi-core-ffm/src/test/java/module-info.test
  • oshi-core-ffm/src/test/java/oshi/ffm/unix/solaris/SolarisLibcFunctionsTest.java
  • oshi-core-ffm/src/test/java/oshi/ffm/util/platform/unix/solaris/KstatUtilFFMTest.java
  • oshi-core/pom.xml
  • oshi-core/src/main/java/oshi/driver/unix/solaris/disk/package-info.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisGlobalMemory.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/SolarisLibc.java
  • oshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOperatingSystem.java
  • oshi-core/src/test/java/module-info.test
  • pom.xml
💤 Files with no reviewable changes (2)
  • oshi-core/src/main/java/oshi/driver/unix/solaris/disk/package-info.java
  • oshi-core/src/test/java/module-info.test

Three logical pieces, kept together because they all came out of the
same CodeRabbit/code-review pass:

Checkstyle
- LibKstatFunctions accessor methods now have proper @param/@return
  Javadoc tags, matching the OpenBsdLibcFunctions/FreeBsdLibcFunctions
  pattern.
- PsInfoFFM Timestruc.toMillis gets a @return tag.
- SystemPagesFFM: drop the empty `if (HAS_KSTAT2) {}` block (no-op
  today; documented in the surrounding comment that the FFM Kstat2
  binding is stubbed) and the now-unused import.
- checkstyle-suppressions.xml: PsInfoFFM (and its inner LwpsInfo /
  PrUsage / Timestruc data classes) mirror the kernel psinfo_t /
  lwpsinfo_t / prusage_t fields, so suppress MemberName and
  VisibilityModifier on that file — same convention the JNA
  SolarisLibc.SolarisPsInfo inner classes get via the [\\/]jna[\\/]
  suppression.

Codecov reach
- pom.xml: drop the broad **/ffm/** JaCoCo exclude. It was hiding 731
  lines of new Solaris FFM code (and would have hidden OpenBSD FFM
  too if anyone had been looking). Add narrower **/CupsPrinterFFM*
  and **/CupsFunctions* excludes to match the existing
  **/CupsPrinterJNA* — the rationale ("requires print service") is
  identical regardless of binding.
- pr.yaml: add a testopenindiana job mirroring testfreebsd /
  testopenbsd (8 GB VM, 1 GB JVM heap caps, mvnw test -Paggregate-
  coverage, codecov flag `solaris`). Without this the only place
  testopenindiana ran was unix.yaml on master pushes, so PRs got no
  Solaris coverage signal until merge.

PR-review nits
- SolarisOSProcessFFM + SolarisOSProcess: getCurrentWorkingDirectory
  built `"/proc" + pid + "/cwd"` — missing the separator means the
  path is always `/proc1234/cwd` which never resolves, so the method
  always returned "". Fixed in both bindings.
- Same two files: updateAttributes assigned
  `this.path = ParseUtil.whitespaces.split(commandLineBackup)[0]`,
  which throws ArrayIndexOutOfBounds when commandLineBackup is empty
  (kernel threads with no command line). Guard with parts.length > 0.
- PsInfoFFM.queryPsInfo: downgrade the "psinfo file empty or
  unreadable" log from WARN to DEBUG. Short-lived processes routinely
  disappear from /proc between enumeration and read; the warning was
  diagnostic-era and now just noise.
- KstatUtilFFM.read: add exponential backoff (16/32/64/128/256 ms)
  between kstat_read retries to match the JNA KstatUtil pattern,
  instead of busy-spinning. Interrupts restore the interrupt flag
  and bail.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- KstatUtilFFM / PsInfoFFM / SystemPagesFFM / SolarisLibcFunctions
  class Javadoc: cross-module {@link oshi.util.platform.unix.solaris.KstatUtil}
  (and the four sibling references) were unresolvable because the FFM
  module doesn't depend on oshi-core, breaking javadoc:javadoc. Switched
  to {@code …}, the same pattern OpenBsdSysctlUtilFFM already uses.

@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: 1

🤖 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 @.github/workflows/pr.yaml:
- Line 140: The checkout step using
actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 should explicitly
disable credential persistence to avoid exposing the token in VM copyback jobs;
update the checkout step (the step that contains uses:
actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10) to include with:
persist-credentials: false so credentials are not retained across
workspace/artifact boundaries.
🪄 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: 081c5abe-1698-4be5-9d9a-e48620a94666

📥 Commits

Reviewing files that changed from the base of the PR and between f11d648 and 7d920cd.

📒 Files selected for processing (10)
  • .github/workflows/pr.yaml
  • config/checkstyle-suppressions.xml
  • oshi-core-ffm/src/main/java/oshi/ffm/driver/unix/solaris/PsInfoFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/driver/unix/solaris/kstat/SystemPagesFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/unix/solaris/SolarisLibcFunctions.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/KstatUtilFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/LibKstatFunctions.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisOSProcessFFM.java
  • oshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOSProcess.java
  • pom.xml
✅ Files skipped from review due to trivial changes (1)
  • config/checkstyle-suppressions.xml
🚧 Files skipped from review as they are similar to previous changes (5)
  • pom.xml
  • oshi-core-ffm/src/main/java/oshi/ffm/unix/solaris/SolarisLibcFunctions.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/KstatUtilFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/LibKstatFunctions.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisOSProcessFFM.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: Test JDK 26, windows-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: JMH Benchmarks, ubuntu-latest
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
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.
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: 3307
File: .github/workflows/netbsd.yaml:4-8
Timestamp: 2026-05-30T02:27:59.447Z
Learning: In the oshi/oshi repository, the `.github/workflows/netbsd.yaml` CI workflow intentionally triggers only on `push` to the `netbsd-port` branch during development. Before the final merge to master, NetBSD CI will be integrated into the main Unix CI workflow (e.g., `.github/workflows/pr.yaml` or equivalent). Do not flag the limited trigger scope as an issue on this PR.
📚 Learning: 2026-04-20T03:07:05.660Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3176
File: oshi-core-java25/src/main/java/oshi/hardware/platform/windows/WindowsVirtualMemoryFFM.java:53-60
Timestamp: 2026-04-20T03:07:05.660Z
Learning: In OSHI's Windows FFM paging file implementation (`oshi-core-java25/src/main/java/oshi/hardware/platform/windows/WindowsVirtualMemoryFFM.java`), the `querySwapUsed()` method uses the Windows PDH raw counter for "% Usage" on the paging file. Despite its name, this raw counter returns page counts: `FirstValue` is the number of pages currently used and `SecondValue` is the total number of pages in the swap file. The formatted counter performs the division and multiplies by 100% to yield a true percentage. Therefore, computing swap used bytes as `pageSize * used.get()` (pages × page size) is correct — do not treat the return value as a percentage.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/ffm/driver/unix/solaris/kstat/SystemPagesFFM.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/software/os/unix/solaris/SolarisOSProcess.java
📚 Learning: 2026-05-30T02:27:59.447Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3307
File: .github/workflows/netbsd.yaml:4-8
Timestamp: 2026-05-30T02:27:59.447Z
Learning: In the oshi/oshi repository, the `.github/workflows/netbsd.yaml` CI workflow intentionally triggers only on `push` to the `netbsd-port` branch during development. Before the final merge to master, NetBSD CI will be integrated into the main Unix CI workflow (e.g., `.github/workflows/pr.yaml` or equivalent). Do not flag the limited trigger scope as an issue on this PR.

Applied to files:

  • .github/workflows/pr.yaml
📚 Learning: 2026-05-31T05:53:04.246Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3311
File: .github/workflows/site.yaml:21-21
Timestamp: 2026-05-31T05:53:04.246Z
Learning: When a GitHub Actions workflow verifies that a pinned commit SHA matches a version tag, dereference annotated tags before comparing to a commit SHA. The API `GET /repos/{owner}/{repo}/git/refs/tags/{tag}` returns the tag *object* SHA for annotated tags (not the underlying commit SHA), so comparing it directly to a commit SHA will cause false mismatches. Instead: (1) fetch the tag object SHA via `GET /repos/{owner}/{repo}/git/refs/tags/{tag}`; (2) resolve that tag object to the underlying commit by calling `GET /repos/{owner}/{repo}/git/tags/{tag_object_sha}`; (3) compare the pinned commit SHA to the resolved commit at `.object.sha`.

Applied to files:

  • .github/workflows/pr.yaml
🪛 zizmor (1.25.2)
.github/workflows/pr.yaml

[warning] 140-140: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)

🔇 Additional comments (3)
oshi-core-ffm/src/main/java/oshi/ffm/driver/unix/solaris/kstat/SystemPagesFFM.java (1)

15-16: LGTM!

Also applies to: 30-32

oshi-core-ffm/src/main/java/oshi/ffm/driver/unix/solaris/PsInfoFFM.java (1)

25-31: LGTM!

Also applies to: 253-257, 273-275

oshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOSProcess.java (1)

144-144: LGTM!

Also applies to: 386-387

Comment thread .github/workflows/pr.yaml Resolved
OpenIndiana JDK 25 CI has intermittently SIGSEGV'd in libc strlen+0x30
during oshi-core test launch:

  # SIGSEGV (0xb) at pc=0x00007fffaf3590d0, pid=..., tid=24
  # JRE: OpenJDK 25 (build 25+-adhoc.oi.jdk25u-jdk-25-36)
  # Problematic frame:
  # C  [libc.so.1+0x790d0]  strlen+0x30

SolarisOperatingSystem's static initializer runs a HAS_KSTAT2 probe
that calls Kstat2.INSTANCE, which on illumos is supposed to throw
UnsatisfiedLinkError (libkstat2 only exists on Solaris 11.4+) and be
caught. JNA 5.19 on JDK 25 has been seen to occasionally crash in
Native.load's strlen path instead of throwing cleanly — and once
that happens, the whole oshi-core test JVM is gone before any test
runs.

Fix at the source: check whether the library file exists on disk
before letting JNA attempt the native load. On illumos and Solaris
< 11.4 it simply doesn't, so we skip the JNA call entirely and
HAS_KSTAT2 falls through to false (which is the right answer there
anyway — the legacy LibKstat path handles everything). The existing
try / catch around Native.load stays as a second line of defense for
the "file is there but library is broken" case.

Match on `libkstat2.so*` (any suffix) rather than the current `.1`
SONAME so a future Solaris release that bumps to `.so.2` keeps
working without code changes. The four standard library search paths
(/lib/64, /usr/lib/64, /lib, /usr/lib) match Solaris's crle defaults.

Same pattern applied to Kstat2Functions on the FFM side
(SymbolLookup.libraryLookup uses dlopen internally and could plausibly
hit the same illumos JNI bug). Replaces the testopenindiana workflow
workaround from the previous attempt at this commit, which set
-Doshi.os.solaris.allowkstat2=false to sidestep the probe entirely.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@dbwiddis
dbwiddis merged commit 11dcff0 into oshi:master Jun 5, 2026
21 of 22 checks passed
@dbwiddis
dbwiddis deleted the solaris-ffm branch June 5, 2026 08:06
dbwiddis added a commit that referenced this pull request Jun 5, 2026
* Post-3339 audit: docs, CI hygiene, and Solaris PowerSource bug fix

Audit pass after the Solaris/illumos FFM port (#3339) merged.

Docs: CHANGELOG entry, README + index.md add the (illumos) parenthetical
and an OpenBSD/Solaris row in the factory table, FAQ + PERFORMANCE +
SystemInfo + package-info now list FreeBSD/OpenBSD/Solaris (illumos)
consistently in the FFM-supported set.

Coverage / module config: add OpenBSD and Solaris PowerSource to the
JaCoCo excludes for parity with the other platforms; drop three stale
add-opens for oshi.driver.mac{,.disk,.net} from the FFM test
module-info (no tests exist in those packages).

Tests: add OS.SOLARIS to the @EnabledOnOs annotation on five FFM smoke
tests (SystemInfoTest, VirtualMemoryFFMTest, OperatingSystemFFMTest,
GlobalMemoryFFMTest, ForeignFunctionsTest) so the new Solaris CI run
actually exercises them.

Benchmarks: new .github/workflows/benchmarks-unix.yaml is a one-shot
workflow_dispatch capture for FreeBSD/OpenBSD/OpenIndiana JMH numbers,
with OpenIndiana mem bumped to 12288 to give back-to-back JVM forks a
chance against illumos's native malloc pool. Temporary push-trigger on
this branch so the numbers can be captured before merge; will be
removed before PR.

Pre-existing JNA bug fix in SolarisPowerSource (and the FFM port that
inherited it): psPowerUsageRate was declared 0d and never assigned,
which also forced psAmperage to 0; psCharging/psDischarging were never
written from bst_state (only a local isCharging was read); and the
bit mask was 0x10 despite the inline comment naming bit 1 (= 0x02) as
the charging bit. Now assigns psPowerUsageRate = bst_rate, masks 0x01
for discharging and 0x02 for charging per ACPI BST spec, and uses
psDischarging (rather than !isCharging) to gate the time-remaining
calc.

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

* Move all JMH benchmark jobs into a single manual workflow

Previously each OS workflow (linux.yaml, macos.yaml, windows.yaml) ran a
JMH benchmark job on every push and the FreeBSD/OpenBSD/OpenIndiana jobs
that I'd added in the previous commit followed the same pattern. We
aren't tracking the numbers automatically — they only feed PERFORMANCE.md
— so running them on every push wastes CI minutes.

Consolidate all six platforms into a single Benchmarks (manual) workflow
gated to workflow_dispatch (plus a temporary push trigger on this branch
so the numbers can be captured before merge; will be removed before PR).
Drop the benchmarks: job from linux/macos/windows.

OpenBSD: pkg_add maven wraps mvn with its own JAVA_HOME shim but a bare
`java -jar` invocation needs PATH/JAVA_HOME set explicitly; the first
capture pass failed with `sh: java: not found` for exactly this reason.

PERFORMANCE.md: populate FreeBSD and Solaris (illumos) tables from the
first manual run (https://github.com/dbwiddis/oshi/actions/runs/27003767696).
OpenBSD left as TODO pending a successful follow-up run.

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

* PERFORMANCE.md: refresh all six benchmark tables from one run

Replaces the older per-platform numbers (which were collected at
different times against different commits) with a single consistent
snapshot from the latest Benchmarks (manual) workflow run, so the
JNA-vs-FFM comparisons across platforms are apples-to-apples. OpenBSD
numbers are populated for the first time; the JAVA_HOME/PATH fix in the
previous commit lets the bare `java -jar` step find the JDK.

Also drops the temporary push: trigger from benchmarks.yaml; the
workflow is now workflow_dispatch-only as originally intended.

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 8, 2026
…3356)

* Move oshi.ffm.driver.* to oshi.driver.* (mirror JNA driver location)

FFM driver classes are internal implementations (not exported via
JPMS), and per project convention should live alongside their JNA
equivalents in `oshi.driver.*` — same arrangement as the
`oshi.hardware.*` / `oshi.software.os.*` namespaces. The
`oshi.ffm.driver.*` location was an organic placement from the AIX
(#3350) and Solaris (#3339) FFM ports; the earlier Mac/Linux/Windows
FFM drivers already used `oshi.driver.*`, so this aligns the four
ports under one rulebook.

Moves (13 files + 2 package-info):

* `oshi.ffm.driver.unix.aix.PsInfoFFM` and the 7
  `oshi.ffm.driver.unix.aix.perfstat.Perfstat*FFM` drivers move to
  `oshi.driver.unix.aix.*`, next to the JNA `Perfstat*JNA` peers.
* `oshi.ffm.driver.unix.solaris.PsInfoFFM` and
  `oshi.ffm.driver.unix.solaris.kstat.SystemPagesFFM` move to
  `oshi.driver.unix.solaris.*`.
* `oshi.ffm.driver.windows.registry.InstalledAppsDataFFM` moves to
  `oshi.driver.windows.registry.*` next to the other Windows registry
  FFM drivers.

No JPMS export changes — `oshi.ffm.driver.*` was never exported, and
`oshi.driver.*` is also internal-only.

13 consumer files (in `oshi.hardware.platform.unix.{aix,solaris}.*`,
`oshi.software.os.unix.{aix,solaris}.*`, and
`oshi.software.os.windows.*`) had their imports rewritten by sed.
`module-info.test` add-opens lines updated to match the new package
names.

First commit in a multi-commit FFM package restructure; final state
ships as one PR. See [[project_ffm_structural_cleanup]] memory for
the full plan.

* Move CupsPrinterFFM to oshi.hardware.platform.unix (mirror JNA peer)

`CupsPrinterFFM` is an implementation class (extends the abstract
`CupsPrinter` from `oshi-common`), not an FFM mapping. Its JNA peer
`CupsPrinterJNA` lives at `oshi.hardware.platform.unix.CupsPrinterJNA`;
this move lines the two up.

It was sharing `oshi.ffm.unix` with `CupsFunctions` (the actual libcups
FFM mapping, which stays put). The same-package access to
`CupsFunctions` becomes an explicit import.

Six consumers (the `*HardwareAbstractionLayerFFM` classes on Linux,
Mac, FreeBSD, OpenBSD, Solaris, and AIX) had their imports rewritten.

* Move oshi.ffm.{linux,mac,unix,windows}.* under oshi.ffm.platform.*

Mirrors the existing JNA layout (`oshi.jna.platform.<lang>.*`) so the
mapping/wrapper layer lives under one clear sub-package. After this:

* All FFM mapping declarations and tightly-coupled struct/constant/
  exception types live under `oshi.ffm.platform.<lang>.*`.
* `oshi.ffm.util.*` retains the real utility classes (unchanged).
* `oshi.ffm.common.*` (NvmlFunctions) and the `oshi.ffm` root files
  (`SystemInfo`, `ForeignFunctions`, `NativeHandle`) stay put.

This is purely a `git mv` + package/import rewrite — no behaviour
changes. Counts: ~150 source files renamed, ~120 import paths
rewritten across consumers and tests. `module-info.test` add-opens
updated for the four renamed packages.

Third commit in the FFM package restructure series; final state ships
as one PR.

* Move LibKstatFunctions out of the util tree to oshi.ffm.platform.unix.solaris

`LibKstatFunctions` extends `ForeignFunctions` — it's the libkstat FFM
mapping, not a utility class. It was sitting in
`oshi.ffm.util.platform.unix.solaris.*` next to `KstatUtilFFM` (a real
utility) and `Kstat2Functions` (a probe-only stub). Move it to
`oshi.ffm.platform.unix.solaris.*` alongside the other libc mappings.

`Kstat2Functions` retains its same-package `{@link LibKstatFunctions}`
javadoc reference, now resolved through an explicit import.

* Refine JaCoCo excludes to match the new FFM/JNA layer structure

After the FFM package restructure (`oshi.ffm.{linux,mac,unix,windows}.*`
→ `oshi.ffm.platform.*`, driver classes moved out, CupsPrinterFFM
moved out), the FFM mapping layer is now a clean glob target. Add an
exclude block that mirrors the JNA exclude block:

* `**/ffm/common/**` — cross-platform mappings (NvmlFunctions).
* `**/ffm/platform/**` — per-language mappings and their tightly-coupled
  struct/constant/exception types.
* `**/ffm/ForeignFunctions*` — base helper (and its nested
  `ArenaCallable` family of functional interfaces).
* `**/ffm/NativeHandle*` — pointer-lifetime AutoCloseable wrapper.

Util classes (`oshi.ffm.util.*`) and the public SPI entry point
(`oshi.ffm.SystemInfo`) stay in coverage by design.

Also narrows the JNA exclude — the previous `**/jna/**` pattern was a
catch-all that accidentally dropped `oshi.jna.util.*` (real utilities)
from coverage. Replaced with the same shape as the FFM block:
`**/jna/common/**`, `**/jna/platform/**`, plus the two top-level files
(`ByRef`, `Struct`) by name. `oshi.jna.util.*` is now covered.

Last commit in the FFM package restructure series; ships as one PR.

* Fix same-package access broken by the LibKstatFunctions move; drop one inline FQN

CI on JDK 25/26 caught a missing import in `KstatUtilFFM` — it relied on
same-package access to `LibKstatFunctions` (and used the class name
directly in 6 call sites like `LibKstatFunctions.kstat_read(...)`,
which the existing static-imported constants don't cover). When
LibKstatFunctions moved out of `oshi.ffm.util.platform.unix.solaris`
to `oshi.ffm.platform.unix.solaris`, those bare references stopped
resolving. Add the explicit import.

Local incremental builds passed because stale `LibKstatFunctions.class`
files at the OLD package path lingered in `target/classes`; CI does
clean builds and rightly rejects the file.

Also folds in the deferred inline-FQN cleanup in
`IOReportClientFFM.cfRelease`:
`oshi.ffm.platform.mac.CoreFoundationFunctions.CFRelease(seg)` becomes
a static import + `CFRelease(seg)` per project convention.
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.

FFM port for Solaris/illumos

1 participant