Skip to content

Make the operating system layer's nullability contracts honest - #3622

Merged
dbwiddis merged 2 commits into
oshi:masterfrom
dbwiddis:jspecify-os
Aug 15, 2026
Merged

dbwiddis merged 2 commits into
oshi:masterfrom
dbwiddis:jspecify-os

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Aug 15, 2026 •

Copy link
Copy Markdown
Member

Fifth group of the backlog #3618 left at WARN, following #3619, #3620 and #3621. Takes oshi-common from 158 warnings to 103 and clears oshi.software.common.

Eighteen process attribute fields now start empty rather than null

AbstractOSProcess.name, and the user, group, id, working directory and command-line-backup fields on MacOSProcess, AbstractProcOSProcess, BsdOSProcess and LinuxOSProcess, are populated by updateAttributes rather than by a constructor.

Whether that leaves a window depends on the subclass: LinuxOSProcess and MacOSProcess call updateAttributes from their constructors, while the AbstractProcOSProcess, BsdOSProcess and SolarisOSProcess hierarchies do not. So the gap is real for some callers and merely unprovable for the rest, and either way a getter reaching a field early returned null through a signature promising otherwise.

AbstractOSThread already declared protected volatile String name = "";. The rest now match it, which is a defensive guard rather than a new convention.

A real failure on the BSDs

BsdOSProcess.updateAttributes read the ps state column as psMap.get(BsdPsKeyword.STATE).charAt(0), and BsdOSThread did the same. A ps variant that does not emit that column would throw partway through the update, leaving the process or thread object half-populated with no indication why. An absent state column now falls through to OTHER and the rest of the update completes.

Five overrides repeat what their interface already says

An override cannot narrow a parameter, so these restate an annotation the API has carried since #3614: the filter and sort arguments of the three process listing methods, and the prior snapshot of getProcessCpuLoadBetweenTicks and getThreadCpuLoadBetweenTicks.

getProcess(int) is annotated in five implementations. OperatingSystem.getProcess(int) has documented returning null for a process that is not running since #3614, so those signatures had been contradicting the interface.

The rest were documented but unstated

The release-file readers on Linux (readOsRelease, readLsbRelease, execLsbRelease, readDistribRelease), the plist readers on macOS, the ps output columns on the BSDs, and the getFileStoreMatching implementations whose name argument is null to mean "match everything".

queryStatvfs and queryContextSwitches return long @Nullable [] — note the annotation goes after the type for an array, since @Nullable long[] would annotate the element type instead.

Scope

The second commit matches the overrides in WindowsOperatingSystem and WindowsOSProcess's JNA and FFM implementations, since the abstract signatures changed here. The forwarding calls and returns those same signatures surface in those files are left for the group that covers oshi-core and oshi-core-ffm; the reactor total drops 554 to 505.

Verification

Full gate green locally on macOS/JDK 25: ./mvnw clean spotless:apply sortpom:sort checkstyle:check install forbiddenapis:check javadoc:javadoc, 1561 tests passing, plus ./mvnw -Perror-prone clean install -DskipTests building successfully across the reactor.

Summary by CodeRabbit

  • Improvements
    • Expanded nullability annotations across process, thread, operating-system, filesystem, and parsing APIs.
    • Clarified which optional inputs may be omitted and which lookups may return no result.
    • Added safer empty-string defaults for unavailable process metadata.
    • Improved resilience when system data is incomplete, including missing process states and application names.
    • Preserved existing behavior for date parsing, process discovery, filesystem queries, and CPU-load calculations.

Fifth group of the backlog #3618 left at WARN. Takes oshi-common from 158
warnings to 103 and clears oshi.software.common.

Eighteen process attribute fields now start as empty strings rather than null.
They are populated by updateAttributes, which LinuxOSProcess and MacOSProcess
call from their constructors but the AbstractProcOSProcess, BsdOSProcess and
SolarisOSProcess hierarchies do not, so the window between construction and
the first update was real for some callers and merely unprovable for the rest.
AbstractOSThread already declared its name this way; the rest now match. A
getter that reached a field early returned null through a signature promising
otherwise, and returns an empty string now.

Five overrides repeat an annotation their interface already carries, because
an override cannot narrow a parameter: the filter and sort of the three
process listing methods, and the prior snapshot of the two
getXxxCpuLoadBetweenTicks methods. getProcess(int) is annotated in five
implementations of the interface that has documented returning null for a
process that is not running since #3614.

The rest were documented but unstated: the release-file readers on Linux, the
plist readers on macOS, the ps output columns on the BSDs, and the file store
lookups whose name argument is null to mean "match everything". BsdOSProcess
and BsdOSThread read a ps column that may be missing, which previously threw
from charAt(0) partway through an update; an absent state column now falls
through to OTHER, leaving the rest of the update intact.
The abstract signatures in WindowsOperatingSystem and WindowsOSProcess now
declare the pid collection, thread map, perf counter block and WTS info as
optional, and an override cannot narrow a parameter, so the implementations
repeat the annotation.

Only the override mismatches are addressed. The forwarding calls and returns
those signatures surface in the same files belong to the group that covers
oshi-core and oshi-core-ffm.
@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: 0d2d2157-accd-42fd-91e3-1c9bda7dc9ad

📥 Commits

Reviewing files that changed from the base of the PR and between 198dbfa and d35e7d9.

📒 Files selected for processing (28)
  • oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/nativefree/LinuxFileSystemNF.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/nativefree/LinuxOperatingSystemNF.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacInstalledApps.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/AbstractProcOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSThread.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.java
📜 Recent review details
⏰ Context from checks skipped due to timeout. (9)
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Analyze (java)
  • GitHub Check: Lint (ForbiddenAPIs, Javadoc, SLF4J)
  • GitHub Check: Lint (Spotless, Checkstyle)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Error Prone
🧰 Additional context used
📓 Path-based instructions (3)
**/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

**/src/main/java/**/*.java: Before writing any parsing helper, check whether ParseUtil already has one.
Every public and protected type and method needs javadoc.
Do not use fully-qualified class names in
code or in javadoc — including inside {@link ...}. Import the type and link the simple name.

Files:

  • oshi-common/src/main/java/oshi/software/common/os/linux/nativefree/LinuxOperatingSystemNF.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSThread.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/nativefree/LinuxFileSystemNF.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacOSProcess.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/AbstractProcOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacInstalledApps.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.java
oshi-common/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

oshi-common/src/main/java/**/*.java: oshi-common may not reference com.sun.jna.**, java.lang.foreign.**, or any
System.load/loadLibrary. It must stay pure JDK.

Files:

  • oshi-common/src/main/java/oshi/software/common/os/linux/nativefree/LinuxOperatingSystemNF.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSThread.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/nativefree/LinuxFileSystemNF.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/AbstractProcOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacInstalledApps.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.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/software/os/windows/WindowsOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
🧠 Learnings (7)
📚 Learning: 2026-04-12T19:22:09.716Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:22:09.716Z
Learning: When reviewing OSHI hardware platform code that uses or implements `CentralProcessor`/`PhysicalProcessor.getEfficiency()`, remember the API’s counterintuitive semantics: a *higher* efficiency-class value indicates *greater performance* (lower efficiency). P-cores/“performance cores” should therefore have higher values (e.g., 1) than E-cores/“efficiency cores” (e.g., 0), as documented in the `CentralProcessor` Javadoc. Do not flag code as incorrect solely because ARM_P_CORES or Intel P-cores are assigned higher efficiency values.

Applied to files:

  • oshi-common/src/main/java/oshi/software/common/os/linux/nativefree/LinuxOperatingSystemNF.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSThread.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/nativefree/LinuxFileSystemNF.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/AbstractProcOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacInstalledApps.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.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-common/src/main/java/oshi/software/common/os/linux/nativefree/LinuxOperatingSystemNF.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSThread.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/nativefree/LinuxFileSystemNF.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacOSProcess.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/AbstractProcOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacInstalledApps.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.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-common/src/main/java/oshi/software/common/os/linux/nativefree/LinuxOperatingSystemNF.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSThread.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/nativefree/LinuxFileSystemNF.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacOSProcess.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/AbstractProcOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacInstalledApps.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.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-common/src/main/java/oshi/software/common/os/linux/nativefree/LinuxOperatingSystemNF.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSThread.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/nativefree/LinuxFileSystemNF.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacOSProcess.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/AbstractProcOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacInstalledApps.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.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/software/os/windows/WindowsOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.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/windows/WindowsOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.java
📚 Learning: 2026-08-15T03:54:58.500Z
Learnt from: CR
Repo: oshi/oshi PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-08-15T03:54:58.500Z
Learning: Applies to oshi-common/src/main/java/**/*.java : `oshi-common` may not reference `com.sun.jna.**`, `java.lang.foreign.**`, or any
  `System.load`/`loadLibrary`. It must stay pure JDK.

Applied to files:

  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxFileSystem.java
🔇 Additional comments (29)
oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java (1)

12-13: LGTM!

Also applies to: 32-32, 135-135

oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java (1)

13-14: LGTM!

Also applies to: 138-138

oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java (1)

24-25: LGTM!

Also applies to: 108-109, 123-124, 147-148

oshi-common/src/main/java/oshi/util/ParseUtil.java (1)

1585-1585: LGTM!

oshi-common/src/main/java/oshi/software/common/os/unix/AbstractProcOSProcess.java (1)

52-56: LGTM!

oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java (1)

15-16: LGTM!

Also applies to: 55-55

oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java (1)

25-26: LGTM!

Also applies to: 120-120

oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSProcess.java (1)

40-49: LGTM!

Also applies to: 185-198, 239-248

oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSThread.java (1)

10-11: LGTM!

Also applies to: 70-72, 118-118

oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOperatingSystem.java (1)

19-19: LGTM!

Also applies to: 79-79

oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java (1)

14-15: LGTM!

Also applies to: 52-52

oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.java (1)

14-15: LGTM!

Also applies to: 99-99

oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisFileSystem.java (1)

14-15: LGTM!

Also applies to: 56-56

oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOperatingSystem.java (1)

17-18: LGTM!

Also applies to: 75-75

oshi-common/src/main/java/oshi/software/common/os/linux/LinuxFileSystem.java (1)

30-30: LGTM!

Also applies to: 101-101, 148-149, 288-288

oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java (1)

28-28: LGTM!

Also applies to: 91-92, 329-329

oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOperatingSystem.java (1)

23-23: LGTM!

Also applies to: 295-305, 341-352, 390-401, 440-454

oshi-common/src/main/java/oshi/software/common/os/linux/nativefree/LinuxFileSystemNF.java (1)

7-8: LGTM!

Also applies to: 20-20

oshi-common/src/main/java/oshi/software/common/os/linux/nativefree/LinuxOperatingSystemNF.java (1)

10-11: LGTM!

Also applies to: 78-78

oshi-common/src/main/java/oshi/software/common/os/mac/MacInstalledApps.java (1)

21-21: LGTM!

Also applies to: 101-102, 227-227, 253-253, 304-304

oshi-common/src/main/java/oshi/software/common/os/mac/MacOSProcess.java (1)

68-72: LGTM!

oshi-common/src/main/java/oshi/software/common/os/mac/MacOperatingSystem.java (1)

23-23: LGTM!

Also applies to: 110-110

oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java (1)

21-22: LGTM!

Also applies to: 221-221

oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.java (2)

21-22: LGTM!

Also applies to: 73-74, 82-83, 91-92, 100-101, 109-109, 131-132, 142-142, 167-167, 177-177


128-129: 🗄️ Data Integrity & Integration

Check the nullable threadMap contract in WindowsOSProcess.

When USE_PROCSTATE_SUSPENDED is false, processMapToList can pass null. Ensure that the constructor parameter and the AtomicReference value type use @Nullable, because getThreadDetails handles a null map.

oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java (1)

41-41: LGTM!

Also applies to: 124-124

oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java (1)

32-32: LGTM!

Also applies to: 268-269, 273-275, 279-280, 284-285, 289-290, 294-295

oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java (1)

14-14: LGTM!

Also applies to: 109-109

oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.java (1)

22-22: LGTM!

Also applies to: 113-114, 118-120, 124-125, 129-130, 134-135, 139-140


📝 Walkthrough

Walkthrough

The pull request adds JSpecify @Nullable annotations across shared, Linux, macOS, Unix, BSD, and Windows APIs. It also initializes selected process fields with empty strings and adds fallbacks for missing BSD and macOS metadata.

Changes

Nullability rollout

Layer / File(s) Summary
Shared API contracts
oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java, AbstractOSThread.java, AbstractOperatingSystem.java, oshi/util/ParseUtil.java
Shared process, thread, process-query, and date-parsing APIs now declare nullable parameters or results.
Linux and macOS contracts
oshi-common/src/main/java/oshi/software/common/os/linux/**, oshi-common/src/main/java/oshi/software/common/os/mac/**
Linux and macOS helpers declare nullable values. Missing process metadata uses empty strings, and missing macOS application names use Constants.UNKNOWN.
Unix and BSD null handling
oshi-common/src/main/java/oshi/software/common/os/unix/**
Unix process lookups and filesystem filters declare nullable values. BSD parsing handles missing state, identity, path, and command-line fields.
Windows API contracts
oshi-common/src/main/java/oshi/software/common/os/windows/**, oshi-core/src/main/java/oshi/software/os/windows/**, oshi-core-ffm/src/main/java/oshi/software/os/windows/**
Windows base, JNA, and FFM APIs declare nullable process data, PID collections, thread maps, and process results.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: 🔵 Low · up to d35e7

Windows process thread details may still have an inaccurate nullability contract when no thread map is available, which could cause misleading API guarantees or follow-up static-check work. The change remains mergeable with explicit owner awareness.

Possibly related issues

  • Issue 3593 — The pull request implements the proposed JSpecify nullability rollout across OSHI APIs and internals.

Possibly related PRs

  • oshi/oshi#3614 — Both changes implement the JSpecify nullability rollout across OSHI classes.
  • oshi/oshi#3615 — Both changes add nullable contracts, including updates in oshi.util.
  • oshi/oshi#3620 — Both changes update nullable API contracts in different OSHI areas.

Poem

A rabbit reviewed each nullable sign,
And found empty strings in a neat little line.
BSD states now safely rest,
Windows maps declare what’s best.
“JSpecify hops!” the rabbit cried,
As nulls stood clearly side by side.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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 summarizes the main change: correcting nullability contracts across the operating system layer.
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

❌ Patch coverage is 90.62500% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.98%. Comparing base (198dbfa) to head (d35e7d9).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...oshi/software/common/os/unix/bsd/BsdOSProcess.java 87.50% 0 Missing and 2 partials ⚠️
.../oshi/software/common/os/unix/bsd/BsdOSThread.java 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3622      +/-   ##
============================================
- Coverage     80.07%   79.98%   -0.09%     
+ Complexity     3868      200    -3668     
============================================
  Files           697      697              
  Lines         24231    24252      +21     
  Branches       3999     4001       +2     
============================================
- Hits          19402    19398       -4     
- Misses         2715     2724       +9     
- Partials       2114     2130      +16     
Flag Coverage Δ
freebsd 33.55% <50.00%> (-0.01%) ⬇️
linux 37.69% <46.87%> (-0.02%) ⬇️
macos 38.55% <59.37%> (-0.04%) ⬇️
openbsd 32.74% <50.00%> (+0.02%) ⬆️
solaris 34.23% <56.25%> (+0.02%) ⬆️
windows 45.32% <40.62%> (-0.02%) ⬇️

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 c5e1f80 into oshi:master Aug 15, 2026
19 checks passed
@dbwiddis
dbwiddis deleted the jspecify-os branch August 15, 2026 04:51
dbwiddis added a commit that referenced this pull request Aug 15, 2026
…st (#3628)

* Make the Windows registry and WMI drivers' nullability contracts honest

Third step of draining oshi-core and oshi-core-ffm, covering the registry, WMI
and performance-data drivers in both implementations. Reactor findings 292 -> 253.

ApplicationInfo's getters each document an empty string for a value the platform
did not report, but the constructor stored what it was given, so a Windows
application whose registry key omits DisplayVersion or Publisher reached callers
with null from getVersion() or getVendor(). The constructor now normalizes all
three strings, which also makes the call-site normalization added for macOS in
#3622 redundant rather than load-bearing.

The rest is contract marking. The performance-data readers that return null on a
failed registry read say so, as do HkeyUserDataFFM's account lookup and the
registry readers behind the installed-application list. The optional arguments
are annotated: the WMI process-id filter, the perf-counter process name, and the
counter text array that is null when the registry read failed.

Three lookups into maps the surrounding code has already proved complete are
read through defaults instead: the counter offset and size maps, which are
filled in one loop from the same key, so an absent offset now falls into the
existing unusable-size branch rather than throwing; the window z-order map,
which the line above populates when absent; and the counter index map, whose
absent entry now logs and returns null instead of throwing inside a
synchronized read. None is reachable.

Two more instance-filter expressions tested a nullable argument with
Util.isBlank, which the analyzer cannot see through, and are rewritten as the
null-or-empty check that method performs.

Also raises two Windows comparison-test tolerances that measure the wall-clock
gap between two process-data collections rather than anything about the values.
Both overran their floor by a hair on recent runs - 1267 against 1200 in
RegistryComparisonTest, 579 against 564 in NativeComparisonTest, where the floor
had never governed because the 10%-of-uptime term is computed from a JVM only a
few seconds old. Both floors are now 1500ms. The uptime derivation itself is
unchanged by this arc: the registry path still takes its reference time from the
perf-data triplet and the perf-counter path from currentTimeMillis.

Part of #3593.

* Address review: correct two contracts the annotations left half-stated

- The uptime-tolerance comment blamed memoization, but setUp sets the memoizer
  expiration to 0, so what the tolerance covers is only the cost of two
  sequential collections. Says so now.
- Win32Process.buildWmiClassNameWithPidFilter null-checks its argument and its
  javadoc documents null, but the parameter did not say so; queryCommandLines
  already passes a @nullable set straight into it.
- HkeyPerformanceDataUtilFFM's javadoc did not mention the null return its
  annotation declares, while the JNA twin's already did.
- Documents the null pidsToQuery contract on both queryCommandLines twins.
dbwiddis added a commit that referenced this pull request Aug 15, 2026
* Make the remaining Unix and FFM nullability contracts honest

Tenth and last step of draining oshi-core and oshi-core-ffm. Covers AIX,
FreeBSD, NetBSD, OpenBSD, the sysctl and foreign-function utilities, and the
handful of leftovers elsewhere. The reactor now reports zero NullAway findings.

Most of it is the familiar shape: a query that reports "no such entry" or "the
native call failed" with null, whose abstract declaration in oshi-common already
documented it - the AIX disk and interface stats, the AIX TCP and UDP stats, the
FreeBSD and OpenBSD host and domain names, and the FreeBSD CPU tick arrays.

The sysctl families needed the contract stated once at the bottom. Both the JNA
and FFM helpers pass a null buffer on the first call to ask only for the size,
and return null when the call fails; the per-platform wrappers hand that result
straight back. Annotating the two call interfaces and the wrappers propagated
through every BSD and macOS caller.

Four things worth calling out:

- ForeignFunctions' three pointer readers are documented as returning null for a
  null pointer, and getByteArrayFromNativePointer needed the array form of the
  annotation - byte @nullable [] - since a byte cannot itself be null.
- The logging varargs are @nullable Object... through both ForeignFunctions and
  ExceptionUtil, because the values being reported are often the very lookup
  arguments that were null.
- ParseUtil's two byte-array parsers were left non-null on purpose. They
  dereference the array immediately, so annotating them would have declared a
  contract they do not honor; the FreeBSD FFM caller checks its own read instead.
- NativeHandle.get() is @nullable, as its javadoc has always said, and close()
  reads the handle into a local so the isNull() guard is one the analyzer can
  follow. Its three consumers check the value they were already relying on.

The one suppression in the arc is on NativeHandleTest.testNullCloserThrows,
which passes null for a @nonnull parameter deliberately: rejecting it is what
the test asserts.

Part of #3593.

* Add the missing tests, and fix a null check that missed the NULL segment

Tests for the behavior this arc changed, which several of its commits altered
without covering:

- ForeignFunctions' three raw pointer readers, for a null pointer, for
  MemorySegment.NULL, and - so the guards cannot quietly cost the readers their
  job - a round trip through a real segment. Writing these showed the three
  pointer parameters were declared non-null while every body tests for null and
  every javadoc documents it, so they are annotated now.
- FreeBsdNetworkParams.getDomainName, which converts the resolver's null to the
  empty string its interface promises.
- ApplicationInfo's constructor, which normalizes an absent name, version or
  vendor. That was changed in #3628 and went out untested.
- BsdOSProcess with a ps row missing its STATE column, which used to throw
  partway through updateAttributes. Changed in #3622, also untested.

Lspv's skip of a volume with no type or partition count stays untested: the maps
it reads are filled together from one lspv run, so the path is unreachable
through the public parser without adding a seam for its own sake.

Review fixes:

- MacNetworkParamsFFM and WindowsOSProcessFFM tested the handle for null but not
  for the NULL segment, which NativeHandle.isNull() covers and which a failed
  getaddrinfo or OpenProcessToken produces. They now test both, written against
  the local so the analyzer can still follow it.
- queryProcesses documents its null pid filter on both twins, matching
  queryCommandLines.
- FreeBsdNetworkParams.queryDomainName's javadoc claimed subclasses return an
  empty string on failure; they return null, which is what its annotation says.
- The FreeBSD FFM stat suppliers hold a nullable segment.
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