Skip to content

Make the Linux nullability contracts honest - #3634

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:jspecify-linux-only
Aug 15, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:jspecify-linux-only

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Aug 15, 2026 •

Copy link
Copy Markdown
Member

Ninth step of draining oshi-core and oshi-core-ffm. Covers the Linux hardware, file-system,
process and login-session components in both implementations. Reactor findings 94 → 70 measured
against master; this branch is cut from master rather than stacked on #3633, so the two are
independent and can land in either order.

Declarations catching up with contracts oshi-common already states

  • queryStatvfs is documented as returning null on failure and declared long @Nullable [] in the
    abstract base.
  • enumerateCpuSyspathsViaUdev likewise, for a system without udev.
  • getProcess for a process that is not running, which OperatingSystem has always declared
    @Nullable.
  • The Linux disk enumerator takes a null store to mean "enumerate every disk" rather than refresh
    one, which is how its own no-argument overload calls it.
  • The FFM session reader reports a session it cannot read with null, which its caller skips.

One guard the analyzer could not read

WhoJNA tested its pointers with nativeValue(ttyPointer) != 0, which was already correct:
JNA's Pointer.nativeValue returns 0 for a null pointer in 5.18.1, the version this project uses.
The added ttyPointer != null is redundant at runtime and exists only to make that invariant
visible. Worth stating precisely, because the JNA jar that happens to sit in a local ~/.m2 may be
3.4.0, where that method dereferences p.peer with no null check — checking the version actually in
use is what turns this from "bug fix" into "no-op".

Also: three flaky comparison assertions

Unrelated to the marking, but folded in here rather than spending another push cycle. The
OpenIndiana job failed on:

[process.contextSwitches: expected=2708.000000, actual=3496.000000]

Context switches are cumulative and the FFM snapshot is taken second, so it can never be the lower
of the two — the same shape as the kernelTime and userTime assertions immediately above, which
already use isGreaterThanOrEqualTo. A ratio bound is unusable: a JVM accumulates thousands of
switches per second and this test runs on one only seconds old, so 20% amounts to requiring the two
snapshots be under half a second apart. All three context-switch assertions are converted to the
ordering form, which still catches the wrong-field or wrong-process binding they exist to detect.
The system-wide counter at processorContextSwitchesAndInterrupts keeps its 0.01 ratio; it has not
flaked.

This failure is not related to #3633 — Solaris context switches come from /proc/<pid>/usage
(pr_vctx/pr_ictx) in SolarisOSProcess, which that PR does not touch.

No behavior change

No CHANGELOG entry. Verified by diffing against master and cancelling every line whose only
difference is an annotation: 11 of the 12 source files have zero residue, the twelfth being the
WhoJNA guard above.

Full gate on macOS: spotless:apply sortpom:sort spotless:check checkstyle:check install forbiddenapis:check javadoc:javadoc plus -Perror-prone clean install. All modules green, 1561
tests, 0 failures. This is Linux code, so nothing here is verified beyond compilation and CI.

Part of #3593.

Summary by CodeRabbit

  • Bug Fixes

    • Improved Linux system monitoring when optional process, session, disk, CPU, filesystem, or terminal information is unavailable.
    • Prevented errors when system-provided terminal or remote-host details are missing.
    • Improved handling of invalid or unavailable process information.
  • Tests

    • Updated process monitoring checks to reliably validate context-switch counters as values progress over time.

Ninth step of draining oshi-core and oshi-core-ffm. Covers the Linux hardware,
file-system, process and login-session components in both implementations.

All of it is declarations catching up with contracts that oshi-common already
states: queryStatvfs is documented as returning null on failure and declared
long @nullable [] in the abstract base, enumerateCpuSyspathsViaUdev the same for
a system without udev, and getProcess for a process that is not running, which
OperatingSystem has always declared @nullable. The Linux disk enumerator takes a
null store to mean "enumerate every disk" rather than refresh one, which is how
its own no-argument overload calls it, and the FFM session reader reports a
session it cannot read with null, which its caller skips.

WhoJNA needed an explicit null test the analyzer could read. The existing guard,
nativeValue(ttyPointer) != 0, was already correct: JNA's Pointer.nativeValue
returns 0 for a null pointer in 5.18.1, the version this project uses. So the
added ttyPointer != null is redundant at runtime and exists only to make that
invariant visible; it changes no behavior.

Part of #3593.
@coderabbitai

coderabbitai Bot commented Aug 15, 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 Plus

Run ID: 5aa689ca-e4fb-4fe6-a8ac-e00881f9a839

📥 Commits

Reviewing files that changed from the base of the PR and between d99b023 and 2003028.

📒 Files selected for processing (13)
  • oshi-benchmark/src/test/java/oshi/comparison/NativeComparisonTest.java
  • oshi-core-ffm/src/main/java/oshi/driver/linux/WhoFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java
  • oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxFileSystemJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystemJNA.java
📜 Recent review details
⏰ Context from checks skipped due to timeout. (7)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Error Prone
  • GitHub Check: Analyze (java)
  • GitHub Check: Lint (ForbiddenAPIs, Javadoc, SLF4J)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle)
🧰 Additional context used
📓 Path-based instructions (5)
**/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

**/src/main/java/**/*.java: Before writing any parsing helper, check whether ParseUtil already has one.
Do not use fully-qualified class names in
code or in javadoc — including inside {@link ...}. Import the type and link the simple name.
Every public and protected type and method needs javadoc.
New files get a current-year-only
header (Copyright 2026 The OSHI Project Contributors / SPDX-License-Identifier: MIT)
new classes are
expected to declare one
Do not reach for @Nullable to make a null return legal: the convention is a sentinel, not a
null

System calls are expensive, and callers poll. Values that are constant (CPU model,
serial number) or expensive-but-slow-changing are wrapped in
oshi.util.Memoizer.memoize(supplier, ...)

Files:

  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java
  • oshi-core-ffm/src/main/java/oshi/driver/linux/WhoFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxFileSystemFFM.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystemJNA.java
  • oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxFileSystemJNA.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java
**/*.{java,xml,md}

📄 CodeRabbit inference engine (AGENTS.md)

Do not commit generated output, target/, or IDE files.

Files:

  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java
  • oshi-benchmark/src/test/java/oshi/comparison/NativeComparisonTest.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java
  • oshi-core-ffm/src/main/java/oshi/driver/linux/WhoFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxFileSystemFFM.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystemJNA.java
  • oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxFileSystemJNA.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java
**/*Test.java

📄 CodeRabbit inference engine (AGENTS.md)

Test files are named *Test.java.

Files:

  • oshi-benchmark/src/test/java/oshi/comparison/NativeComparisonTest.java
**/src/test/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

**/src/test/java/**/*.java: In test sources, assert rather than suppress
Assert on invariants (non-null, correct type, ordering, a plausible range), not on specific values.

Files:

  • oshi-benchmark/src/test/java/oshi/comparison/NativeComparisonTest.java
oshi-core-ffm/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

oshi-core-ffm may not reference com.sun.jna.**.

Files:

  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java
  • oshi-core-ffm/src/main/java/oshi/driver/linux/WhoFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java
🧠 Learnings (8)
📚 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/linux/LinuxHWDiskStoreJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystemJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxFileSystemJNA.java
📚 Learning: 2026-07-06T19:25:59.225Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:25:59.225Z
Learning: In this repo’s SLF4J 1.x-compatible logging code, do not flag cases where a logger call uses SLF4J 1.6+ implicit-cause handling—e.g., `log.error("...{}", value, t)` (or similar with a single `{}` placeholder) where `t` is passed as the final/trailing argument. SLF4J will attach `t` as the log event’s cause with the full stack trace; this is equivalent to SLF4J 2.x’s fluent `atLevel(...).setCause(t).log(...)` and is intentionally used to preserve SLF4J 1.x runtime compatibility.

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java
  • oshi-core-ffm/src/main/java/oshi/driver/linux/WhoFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxFileSystemFFM.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystemJNA.java
  • oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxFileSystemJNA.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java
📚 Learning: 2026-07-30T00:35:22.638Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3547
File: oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdFirmware.java:82-82
Timestamp: 2026-07-30T00:35:22.638Z
Learning: In OSHI, treat changes as “API-breaking” only when they affect classes (or relevant API surface) annotated with `PublicAPI`. Public classes/members that are not annotated with `PublicAPI` should be reviewed as internal implementation details, even if they are public (e.g., classes like `oshi.hardware.common.platform.unix.BsdFirmware`). Also, respect intentional visibility decisions used for tests—e.g., methods like `BsdFirmware.parseDmesg(List<String>)` may be intentionally package-private to support tests within the same package; avoid widening visibility or altering signatures unless the related `PublicAPI` contract requires it.

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java
  • oshi-core-ffm/src/main/java/oshi/driver/linux/WhoFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxFileSystemFFM.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystemJNA.java
  • oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxFileSystemJNA.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java
📚 Learning: 2026-08-03T00:46:14.953Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3566
File: oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdNetworkParams.java:18-22
Timestamp: 2026-08-03T00:46:14.953Z
Learning: In the OSHI Java codebase, do not require duplicate Javadoc on public methods annotated with Override when the inherited Javadoc from the parent declaration adequately documents the method. The general public-member Javadoc requirement should not flag these overrides solely because they lack redundant documentation.

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java
  • oshi-benchmark/src/test/java/oshi/comparison/NativeComparisonTest.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java
  • oshi-core-ffm/src/main/java/oshi/driver/linux/WhoFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxFileSystemFFM.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystemJNA.java
  • oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxFileSystemJNA.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java
📚 Learning: 2026-08-15T14:25:48.170Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3625
File: oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxNetworkIF.java:65-69
Timestamp: 2026-08-15T14:25:48.170Z
Learning: In OSHI Java code, treat `oshi.util.Util.isBlank(String)` as equivalent to `value == null || value.isEmpty()`: it does not consider whitespace-only strings blank. Do not report a behavior change when code replaces `!Util.isBlank(value)` with the equivalent `value != null && !value.isEmpty()` condition.

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java
  • oshi-benchmark/src/test/java/oshi/comparison/NativeComparisonTest.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java
  • oshi-core-ffm/src/main/java/oshi/driver/linux/WhoFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxFileSystemFFM.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystemJNA.java
  • oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxFileSystemJNA.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java
📚 Learning: 2026-08-15T15:43:29.296Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3628
File: oshi-core-ffm/src/main/java/oshi/driver/windows/registry/HkeyUserDataFFM.java:108-108
Timestamp: 2026-08-15T15:43:29.296Z
Learning: In the OSHI Java codebase, use the sentinel-over-null convention at public API boundaries. Private helpers may return an explicitly JSpecify-annotated nullable value when the caller handles the missing result clearly and locally; callers must check for null before accessing the result. For example, methods such as lookupAccountBySid(String) may return String Nullable [] when queryUserSessions() performs the required null check.

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java
  • oshi-benchmark/src/test/java/oshi/comparison/NativeComparisonTest.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java
  • oshi-core-ffm/src/main/java/oshi/driver/linux/WhoFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxFileSystemFFM.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystemJNA.java
  • oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxFileSystemJNA.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java
📚 Learning: 2026-08-15T15:59:20.875Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3629
File: oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java:75-75
Timestamp: 2026-08-15T15:59:20.875Z
Learning: For OSHI backend twin classes whose filenames end in JNA.java or FFM.java, do not flag missing Javadoc on public forwarding constructors when config/checkstyle-suppressions.xml exempts them. Treat the documented abstract parent constructor as the contract location and avoid requiring duplicate Javadoc for the forwarded parameters.

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java
  • oshi-core-ffm/src/main/java/oshi/driver/linux/WhoFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxFileSystemFFM.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystemJNA.java
  • oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxFileSystemJNA.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java
📚 Learning: 2026-08-02T23:56:23.866Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3565
File: oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/PosixLibcFunctions.java:51-56
Timestamp: 2026-08-02T23:56:23.866Z
Learning: For Java FFM bindings in the oshi-core-ffm module, assume a 64-bit JVM and 64-bit operating system. Do not flag 32-bit native ABI or memory-layout compatibility concerns, consistent with the project's JDK 25 support policy, unless that policy changes.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java
  • oshi-core-ffm/src/main/java/oshi/driver/linux/WhoFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java
🔇 Additional comments (13)
oshi-core-ffm/src/main/java/oshi/driver/linux/WhoFFM.java (1)

18-19: LGTM!

Also applies to: 141-141

oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java (1)

22-22: LGTM!

Also applies to: 129-129

oshi-core/src/main/java/oshi/software/os/linux/LinuxFileSystemJNA.java (1)

7-7: LGTM!

Also applies to: 26-26

oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystemJNA.java (1)

12-12: LGTM!

Also applies to: 123-123

oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java (1)

158-158: LGTM!

Also applies to: 175-175

oshi-benchmark/src/test/java/oshi/comparison/NativeComparisonTest.java (1)

446-456: LGTM!

oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java (1)

17-17: LGTM!

Also applies to: 44-44

oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java (1)

16-16: LGTM!

Also applies to: 54-54

oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxFileSystemFFM.java (1)

12-12: LGTM!

Also applies to: 29-29

oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOSProcessFFM.java (1)

15-15: LGTM!

Also applies to: 38-38

oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java (1)

12-12: LGTM!

Also applies to: 42-42

oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java (1)

14-14: LGTM!

Also applies to: 56-56

oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcessJNA.java (1)

10-11: LGTM!

Also applies to: 30-30


📝 Walkthrough

Walkthrough

The change adds JSpecify @Nullable annotations to Linux FFM and JNA APIs, checks optional WhoJNA pointers before native access, and replaces context-switch ratio assertions with nondecreasing comparisons.

Changes

Linux native nullability and validation

Layer / File(s) Summary
Nullable Linux API contracts
oshi-core-ffm/src/main/java/oshi/..., oshi-core/src/main/java/oshi/...
FFM and JNA methods now declare existing nullable sessions, CPU paths, disk parameters, filesystem results, context-switch results, and process lookups.
Native pointer and comparison validation
oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java, oshi-benchmark/src/test/java/oshi/comparison/NativeComparisonTest.java
WhoJNA checks optional pointers before native address access. Process comparison tests assert nondecreasing context-switch counters.

Estimated code review effort: 2 (Simple) | ~15 minutes

Merge Risk: ⚪ Minimal · up to 20030

This PR aligns Linux nullability declarations and adjusts flaky comparison assertions without introducing an actionable merge-blocking risk; it is merge-ready after normal checks and review.

Possibly related PRs

Poem

A rabbit checks each pointer twice,
Marks nullable paths with care.
Context switches hop ahead,
No ratio traps remain to snare.
Native trails grow clear and fair.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: aligning Linux nullability annotations with actual contracts.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.91%. Comparing base (d99b023) to head (2003028).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3634      +/-   ##
============================================
- Coverage     79.98%   79.91%   -0.08%     
- Complexity     3863     4100     +237     
============================================
  Files           697      697              
  Lines         24275    24275              
  Branches       4006     4006              
============================================
- Hits          19417    19400      -17     
- Misses         2719     2738      +19     
+ Partials       2139     2137       -2     
Flag Coverage Δ
linux 37.68% <ø> (ø)
macos 38.51% <ø> (-0.05%) ⬇️
windows 45.29% <ø> (+<0.01%) ⬆️

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.

@dbwiddis
dbwiddis merged commit d0bd18d into oshi:master Aug 15, 2026
18 checks passed
@dbwiddis
dbwiddis deleted the jspecify-linux-only branch August 15, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant