Skip to content

Mark the API and util packages, and the modules, for nullability - #3618

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:jspecify-mark-clean
Aug 15, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:jspecify-mark-clean

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Aug 15, 2026 •

Copy link
Copy Markdown
Member

Establishes the end state for #3593 across oshi-common, oshi-core and oshi-core-ffm, then leaves NullAway at WARN while the backlog it reports is drained. It returns to ERROR once the count reaches zero — the same approach #3597 took with the SLF4J check, which spent a release cycle at WARN while its 74 sites were fixed.

Nothing here changes behavior. The two bug fixes described at the end were found by the marking.

Two mechanisms, each aimed at what it can reach

A package annotation is the only one every consumer sees. A JDK 8 user has no module system at all, and a JDK 9+ user on the classpath does not resolve module annotations either — those are only observed when the jar is on the module path. So the split is by audience rather than by convenience:

scope mechanism
packages holding @PublicApi types — oshi, oshi.hardware, oshi.software.os, oshi.util, oshi.spi, oshi.annotation, oshi.ffm @NullMarked on package-info.java
the whole oshi.util tree, which callers do sometimes reach for @NullMarked on package-info.java
everything else — per-OS implementations, abstract bases, drivers @NullMarked on module-info.java

The second group is what the project already documents as not meant for outside use. Marking it at the module level exists so we can check our own code, and it needs no upkeep as packages are added — which is the one real weakness of per-package marking.

The native mappings are opted out

@NullUnmarked on oshi.jna, oshi.jna.common, oshi.jna.platform.*, oshi.ffm.common and oshi.ffm.platform.*. Those describe someone else's memory layout rather than our contracts, and are already exempt from the javadoc rules for the same reason.

Their utility packages are not opted out: oshi.jna.util and oshi.ffm.util.* follow the rules like any other code, and oshi.jna.util.SysctlUtilJNA duly reports findings.

Build changes this needs

oshi-common and oshi-core compile at release 9 under -Perror-prone only. Their sources target release 8, which predates JPMS and therefore excludes module-info.java from the compilation — so NullAway never sees the module annotation and marking the module does nothing. Under this profile the whole module compiles at release 9 with module-info.java included. The released jars are unchanged, still built at release 8 by the default profile, and every test job still compiles at release 8, so a Java 9+ API would still fail there.

oshi-core and oshi-core-ffm gain the jspecify dependency and requires static org.jspecify, since oshi-common declares it optional and it is therefore not transitive.

-Xmaxerrs joins the -Xmaxwarns that #3597 set. NullAway reports at ERROR once the backlog is drained, and javac caps errors at 100 by default just as silently as it caps warnings. This is not hypothetical: a survey of oshi-common reported exactly 100 findings until this was set, against a real 288.

Two false contracts the marking exposed

WmiResult.getValue declared a non-null return that every caller already distrusted. All four call sites in WmiUtil do Object o = result.getValue(...); if (o == null) {...}. A WMI row that does not carry the requested property returns null through a signature promising otherwise, so the null check was load-bearing and the signature was wrong.

NetBsdCentralProcessor.parseCpTime opens with if (cpTimeStr == null || cpTimeStr.isEmpty()) on a parameter it declared non-null.

Two tests also asserted on a map lookup without checking the key was present — a miss would have failed with a NullPointerException rather than naming the key — and one called main(null) where an empty array says the same thing.

Where the backlog stands

682 warnings: oshi-common 306, oshi-core-ffm 219, oshi-core 157; 648 in main sources and 34 in tests. Largest clusters are oshi.driver.common.windows.registry 54, oshi.ffm.util.gpu 38, oshi.hardware.common.platform.windows 31, oshi.hardware.common.platform.mac 24, oshi.util.gpu 24. oshi-demo has no module-info.java and is left alone for now.

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 over the whole reactor building successfully at WARN.

Note the clean on that last command. Without it Maven finds the classes up to date, skips recompilation, and Error Prone reports success having analysed nothing.

Summary by CodeRabbit

  • New Features
    • Added comprehensive nullability annotations across core, common, native, and platform-specific APIs.
    • Clarified that certain WMI values may be absent.
  • Bug Fixes
    • Improved handling and validation of potentially missing parsed data.
  • Tests
    • Strengthened test assertions for absent or invalid values.
  • Chores
    • Added validation support for nullability analysis while preserving Java 8 compatibility.

@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: 6085ba24-a4ca-49c3-a91b-5fb86c655b97

📥 Commits

Reviewing files that changed from the base of the PR and between 1a881a7 and a78cba1.

📒 Files selected for processing (38)
  • oshi-common/pom.xml
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/main/java/oshi/util/common/gpu/package-info.java
  • oshi-common/src/main/java/oshi/util/common/platform/mac/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/linux/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/linux/proc/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/unix/package-info.java
  • oshi-core-ffm/pom.xml
  • oshi-core-ffm/src/main/java/module-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/common/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/linux/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/mac/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/aix/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/dragonflybsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/freebsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/openbsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/com/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/package-info.java
  • oshi-core/pom.xml
  • oshi-core/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/jna/common/package-info.java
  • oshi-core/src/main/java/oshi/jna/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/linux/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/windows/package-info.java
  • oshi-core/src/main/java/oshi/package-info.java
  • oshi-core/src/main/java/oshi/util/gpu/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/mac/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/freebsd/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/netbsd/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/openbsd/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/solaris/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/windows/package-info.java
  • pom.xml
📜 Recent review details
⏰ Context from checks skipped due to timeout. (11)
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Error Prone
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Analyze (java)
  • GitHub Check: Lint (Spotless, Checkstyle)
  • GitHub Check: Lint (ForbiddenAPIs, Javadoc, SLF4J)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{java,properties}

📄 CodeRabbit inference engine (AGENTS.md)

Before writing any parsing helper, check whether ParseUtil already has one.

Files:

  • oshi-core/src/main/java/oshi/jna/common/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/openbsd/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/mac/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/linux/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/linux/proc/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/windows/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/com/package-info.java
  • oshi-common/src/main/java/oshi/util/common/platform/mac/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/aix/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/freebsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/dragonflybsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/mac/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/openbsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/common/package-info.java
  • oshi-core/src/main/java/oshi/package-info.java
  • oshi-core/src/main/java/oshi/jna/package-info.java
  • oshi-core/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/freebsd/package-info.java
  • oshi-common/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/solaris/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/linux/package-info.java
  • oshi-common/src/main/java/oshi/util/common/gpu/package-info.java
  • oshi-core/src/main/java/oshi/util/gpu/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/netbsd/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/unix/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/windows/package-info.java
  • oshi-core-ffm/src/main/java/module-info.java
  • oshi-common/src/main/java/oshi/util/driver/linux/package-info.java
**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

**/*.java: 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.
New files get a current-year-only
header (Copyright 2026 The OSHI Project Contributors / SPDX-License-Identifier: MIT), even when
copied from an older file; spotless maintains end years on existing files.
Never add a line range to
config/checkstyle-suppressions.xml — a range breaks the moment anything above it shifts, including a
single added import, and the failure looks unrelated to the change that caused it.
new classes are
expected to declare one, and matching the annotation of the class you are modeling yours on is the
right default.
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/jna/common/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/openbsd/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/mac/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/linux/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/linux/proc/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/windows/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/com/package-info.java
  • oshi-common/src/main/java/oshi/util/common/platform/mac/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/aix/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/freebsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/dragonflybsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/mac/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/openbsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/common/package-info.java
  • oshi-core/src/main/java/oshi/package-info.java
  • oshi-core/src/main/java/oshi/jna/package-info.java
  • oshi-core/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/freebsd/package-info.java
  • oshi-common/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/solaris/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/linux/package-info.java
  • oshi-common/src/main/java/oshi/util/common/gpu/package-info.java
  • oshi-core/src/main/java/oshi/util/gpu/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/netbsd/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/unix/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/windows/package-info.java
  • oshi-core-ffm/src/main/java/module-info.java
  • oshi-common/src/main/java/oshi/util/driver/linux/package-info.java
oshi-common/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

oshi-common/**/*.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/util/driver/linux/proc/package-info.java
  • oshi-common/src/main/java/oshi/util/common/platform/mac/package-info.java
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/main/java/oshi/util/common/gpu/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/unix/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/linux/package-info.java
oshi-core-ffm/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

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

Files:

  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/com/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/aix/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/freebsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/dragonflybsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/mac/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/openbsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/common/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/linux/package-info.java
  • oshi-core-ffm/src/main/java/module-info.java
🧠 Learnings (6)
📚 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/jna/common/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/openbsd/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/mac/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/linux/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/linux/proc/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/windows/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/com/package-info.java
  • oshi-common/src/main/java/oshi/util/common/platform/mac/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/aix/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/freebsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/dragonflybsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/mac/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/openbsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/common/package-info.java
  • oshi-core/src/main/java/oshi/package-info.java
  • oshi-core/src/main/java/oshi/jna/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/freebsd/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/solaris/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/linux/package-info.java
  • oshi-common/src/main/java/oshi/util/common/gpu/package-info.java
  • oshi-core/src/main/java/oshi/util/gpu/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/netbsd/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/unix/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/windows/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/linux/package-info.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/jna/common/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/openbsd/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/mac/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/linux/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/linux/proc/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/windows/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/com/package-info.java
  • oshi-common/src/main/java/oshi/util/common/platform/mac/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/aix/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/freebsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/dragonflybsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/mac/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/openbsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/common/package-info.java
  • oshi-core/src/main/java/oshi/package-info.java
  • oshi-core/src/main/java/oshi/jna/package-info.java
  • oshi-core/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/freebsd/package-info.java
  • oshi-common/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/solaris/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/linux/package-info.java
  • oshi-common/src/main/java/oshi/util/common/gpu/package-info.java
  • oshi-core/src/main/java/oshi/util/gpu/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/netbsd/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/unix/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/windows/package-info.java
  • oshi-core-ffm/src/main/java/module-info.java
  • oshi-common/src/main/java/oshi/util/driver/linux/package-info.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/jna/common/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/openbsd/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/mac/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/linux/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/linux/proc/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/windows/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/com/package-info.java
  • oshi-common/src/main/java/oshi/util/common/platform/mac/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/aix/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/freebsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/dragonflybsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/mac/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/openbsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/common/package-info.java
  • oshi-core/src/main/java/oshi/package-info.java
  • oshi-core/src/main/java/oshi/jna/package-info.java
  • oshi-core/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/freebsd/package-info.java
  • oshi-common/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/solaris/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/linux/package-info.java
  • oshi-common/src/main/java/oshi/util/common/gpu/package-info.java
  • oshi-core/src/main/java/oshi/util/gpu/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/netbsd/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/unix/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/windows/package-info.java
  • oshi-core-ffm/src/main/java/module-info.java
  • oshi-common/src/main/java/oshi/util/driver/linux/package-info.java
📚 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/util/driver/linux/proc/package-info.java
  • oshi-common/src/main/java/oshi/util/common/platform/mac/package-info.java
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/main/java/oshi/util/common/gpu/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/unix/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/linux/package-info.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/ffm/platform/windows/com/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/aix/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/freebsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/dragonflybsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/mac/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/openbsd/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/common/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/package-info.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/linux/package-info.java
  • oshi-core-ffm/src/main/java/module-info.java
📚 Learning: 2026-03-29T20:01:01.877Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java11/src/main/java/module-info.java:10-17
Timestamp: 2026-03-29T20:01:01.877Z
Learning: In this repo’s `module-info.java` files, keep exports aligned with which platform implementations are actually supported by the current FFM (Foreign Function & Memory) backend. Do not export FreeBSD, OpenBSD, or Solaris packages (e.g., `oshi.util.platform.unix.freebsd|openbsd|solaris`) in modules where the FFM implementation only supports Windows/macOS/Linux; this asymmetry vs older Java targets (e.g., the java11 module-info that exports all Unix packages) is intentional and should not be flagged as an omission unless the underlying support changes.

Applied to files:

  • oshi-core-ffm/src/main/java/module-info.java
🔇 Additional comments (38)
pom.xml (1)

1240-1246: LGTM!

Also applies to: 1277-1277

oshi-common/pom.xml (1)

131-157: LGTM!

oshi-core/pom.xml (1)

38-43: LGTM!

Also applies to: 178-204

oshi-core-ffm/pom.xml (1)

26-31: LGTM!

oshi-common/src/main/java/module-info.java (1)

1-2: LGTM!

Also applies to: 22-22

oshi-core-ffm/src/main/java/module-info.java (1)

1-2: LGTM!

Also applies to: 22-22, 37-37

oshi-core/src/main/java/oshi/util/platform/unix/netbsd/package-info.java (1)

8-11: LGTM!

oshi-core/src/main/java/oshi/util/platform/unix/openbsd/package-info.java (1)

8-11: LGTM!

oshi-core/src/main/java/oshi/util/platform/unix/solaris/package-info.java (1)

8-11: LGTM!

oshi-core/src/main/java/oshi/util/platform/windows/package-info.java (1)

8-11: LGTM!

oshi-core/src/main/java/module-info.java (1)

1-2: LGTM!

Also applies to: 22-22, 44-44

oshi-common/src/main/java/oshi/util/common/gpu/package-info.java (1)

8-11: LGTM!

oshi-common/src/main/java/oshi/util/common/platform/mac/package-info.java (1)

8-11: LGTM!

oshi-common/src/main/java/oshi/util/driver/linux/package-info.java (1)

4-7: LGTM!

oshi-core/src/main/java/oshi/jna/platform/unix/package-info.java (1)

9-12: LGTM!

oshi-core/src/main/java/oshi/jna/platform/windows/package-info.java (1)

9-12: LGTM!

oshi-core/src/main/java/oshi/package-info.java (1)

63-66: LGTM!

oshi-core/src/main/java/oshi/util/gpu/package-info.java (1)

8-11: LGTM!

oshi-core/src/main/java/oshi/util/platform/mac/package-info.java (1)

8-11: LGTM!

oshi-core/src/main/java/oshi/util/platform/unix/freebsd/package-info.java (1)

8-11: LGTM!

oshi-common/src/main/java/oshi/util/driver/linux/proc/package-info.java (1)

4-7: LGTM!

oshi-common/src/main/java/oshi/util/driver/unix/package-info.java (1)

8-11: LGTM!

oshi-core-ffm/src/main/java/oshi/ffm/common/package-info.java (1)

8-11: LGTM!

oshi-core-ffm/src/main/java/oshi/ffm/package-info.java (1)

8-11: LGTM!

oshi-core-ffm/src/main/java/oshi/ffm/platform/linux/package-info.java (1)

4-7: LGTM!

oshi-core/src/main/java/oshi/jna/common/package-info.java (1)

9-12: LGTM!

oshi-core/src/main/java/oshi/jna/package-info.java (1)

9-12: LGTM!

oshi-core/src/main/java/oshi/jna/platform/linux/package-info.java (1)

9-12: LGTM!

oshi-core/src/main/java/oshi/jna/platform/mac/package-info.java (1)

9-12: LGTM!

oshi-core-ffm/src/main/java/oshi/ffm/platform/mac/package-info.java (1)

8-11: LGTM!

oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/aix/package-info.java (1)

8-11: LGTM!

oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/dragonflybsd/package-info.java (1)

8-11: LGTM!

oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/freebsd/package-info.java (1)

4-7: LGTM!

oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/openbsd/package-info.java (1)

4-7: LGTM!

oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/package-info.java (1)

8-11: LGTM!

oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/package-info.java (1)

4-7: LGTM!

oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/com/package-info.java (1)

10-13: LGTM!

oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/package-info.java (1)

8-11: LGTM!


📝 Walkthrough

Walkthrough

The PR integrates JSpecify nullability across OSHI modules and packages. It adds explicit nullable contracts, updates affected tests, and configures Error Prone and NullAway analysis.

Changes

JSpecify nullability rollout

Layer / File(s) Summary
Build and module nullability integration
pom.xml, oshi-common/pom.xml, oshi-core/pom.xml, oshi-core-ffm/pom.xml, */src/main/java/module-info.java
The build adds JSpecify dependencies, Java 9 analysis profiles, higher diagnostic limits, and warning-level NullAway findings. Module descriptors use @NullMarked and static JSpecify requirements.
Package nullness defaults
oshi-common/src/main/java/**/package-info.java, oshi-core/src/main/java/**/package-info.java, oshi-core-ffm/src/main/java/**/package-info.java
Selected packages now use JSpecify @NullMarked or @NullUnmarked defaults.
Explicit nullable contracts
oshi-common/src/main/java/oshi/driver/common/windows/wmi/WmiResult.java, oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdCentralProcessor.java, oshi-common/src/test/java/oshi/driver/common/windows/wmi/WmiUtilTest.java
WmiResult.getValue and parseCpTime declare nullable values or parameters. The WMI mock and null-validation test match these contracts.
Nullability validation
oshi-common/src/test/java/oshi/driver/common/unix/freebsd/disk/GeomDiskListTest.java, oshi-common/src/test/java/oshi/driver/common/unix/solaris/disk/IostatTest.java, oshi-common/src/test/java/oshi/nativefree/SystemInfoTest.java
Disk parser tests assert that results exist before dereferencing them. The platform test passes an empty argument array instead of null.

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

Merge Risk: ⚪ Minimal · up to a78cb

This PR adds nullability coverage and related build/test corrections without any identified merge-blocking risk; it is merge-ready after normal checks and review.

Possibly related issues

Possibly related PRs

  • oshi/oshi#3614 — Directly advances the same JSpecify nullability rollout and related module metadata.
  • oshi/oshi#3594 — Provides the Error Prone build groundwork extended by this PR.
  • oshi/oshi#3595 — Also modifies the root Error Prone profile.

Poem

I’m a small rabbit, pleased to see
Null marks spread from tree to tree.
Nullable paths now clearly show,
Tests guard fields before they grow.
Error Prone keeps watch tonight. 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% 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
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary changes: adding nullability annotations to API and utility packages and Java modules.
✨ 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.96%. Comparing base (675c5c9) to head (a78cba1).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3618      +/-   ##
============================================
- Coverage     79.99%   79.96%   -0.03%     
- Complexity     3864     4224     +360     
============================================
  Files           696      696              
  Lines         24219    24219              
  Branches       3997     3997              
============================================
- Hits          19373    19367       -6     
- Misses         2720     2728       +8     
+ Partials       2126     2124       -2     
Flag Coverage Δ
freebsd 33.56% <ø> (ø)
linux 37.73% <ø> (+0.01%) ⬆️
macos 38.55% <ø> (-0.03%) ⬇️
openbsd 32.73% <ø> (+<0.01%) ⬆️
solaris 34.22% <ø> (+<0.01%) ⬆️
windows 45.33% <ø> (-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.

Establishes the end state for #3593 across oshi-common, oshi-core and
oshi-core-ffm. NullAway runs at WARN until the backlog it reports is drained,
following the precedent set for the SLF4J check in #3597; it goes back to
ERROR once the count reaches zero.

Two mechanisms, aimed at what each can actually reach. A package annotation is
the only one every consumer sees: a JDK 8 user has no module system at all,
and a JDK 9+ user on the classpath does not resolve module annotations either.
So the packages a caller touches are annotated individually -- those holding
@publicapi types, and the whole oshi.util tree, which callers do sometimes
reach for. Everything below that line is per-OS implementation, abstract bases
and drivers, which the project already documents as not meant for outside use;
those are covered by @NullMarked on the module declaration, which exists to let
us check our own code and needs no per-package upkeep as packages are added.

The native mapping packages are opted out with @NullUnmarked. The struct and
library bindings under oshi.jna and oshi.ffm.platform describe someone else's
memory layout rather than our contracts, and are already exempt from the
javadoc rules for the same reason. Their utility packages, oshi.jna.util and
oshi.ffm.util, are not opted out.

oshi-common and oshi-core compile their sources at release 8, which predates
JPMS and therefore excludes module-info.java, leaving the module annotation
invisible to NullAway. Under -Perror-prone only, they now compile at release 9
with module-info.java included. The released jars are unchanged, still built at
release 8. oshi-core and oshi-core-ffm gain the jspecify dependency and a
requires static clause, since oshi-common declares it optional and it is
therefore not transitive.

-Xmaxerrs joins the -Xmaxwarns that #3597 set. NullAway reports at ERROR once
the backlog is drained, and javac caps errors at 100 by default just as
silently as warnings: a survey of oshi-common reported exactly 100 findings
until this was set, against a real 288.

Marking oshi.driver.common.windows.wmi showed WmiResult.getValue declaring a
non-null return that every caller in WmiUtil immediately null-checks, so a WMI
row without the property was already returning null through a signature that
promised otherwise. NetBsdCentralProcessor.parseCpTime likewise null-checks the
argument it declared non-null. Both are annotated now. Two tests asserted on a
map lookup without checking it was present, and one called main(null).
@dbwiddis
dbwiddis force-pushed the jspecify-mark-clean branch from 1a881a7 to a78cba1 Compare August 15, 2026 02:52
@dbwiddis dbwiddis changed the title Mark the null-clean packages and fix the silent -Xmaxerrs truncation Mark the API and util packages, and the modules, for nullability Aug 15, 2026
@dbwiddis
dbwiddis merged commit 5764906 into oshi:master Aug 15, 2026
19 checks passed
@dbwiddis
dbwiddis deleted the jspecify-mark-clean branch August 15, 2026 03:04
dbwiddis added a commit that referenced this pull request Aug 15, 2026
* Resolve the Windows registry package's nullability findings

Adds PerfCounterValues, giving the two performance-data classes typed
lookups into their property maps. HkeyPerformanceDataUtil.getCounterIndices
returns null unless it resolved an index for every constant of the counter
enum, so the maps are all-or-nothing and a missing key means the data was
assembled inconsistently rather than that a counter is optional. The
accessors say so, naming the property instead of failing later with a bare
NullPointerException, and the call sites lose their casts.

Annotates the returns that were already documented as nullable:
getCounterIndices, RegistryValueUtil.registryValueToString, and the four
buildXxxMap methods, plus registryValueToLong's argument, which it
null-checks.

* Make the driver package's nullability contracts honest

Clears oshi.driver.common, the first group of the backlog left at WARN by
#3618. oshi-common goes from 306 warnings to 229; one finding remains in
DxgiUtil, which belongs with the GPU group.

The two performance-data classes gain PerfCounterValues, a set of typed
lookups into their property maps. HkeyPerformanceDataUtil.getCounterIndices
returns null unless it resolved an index for every constant of the counter
enum, so the maps are all-or-nothing and a missing key means the data was
assembled inconsistently rather than that a counter is optional. The
accessors say so, naming the property instead of failing later with a bare
NullPointerException, and the call sites lose their casts.

Three contracts were wrong rather than merely unstated. PdhCounterProperty
.getInstance returns the PDH instance filter, which the enum constants for
counters without one set to null literally; the interface and PerfCounter now
say so. Lscfg documents that its model, serial and version may each be absent
and returns them in a tuple; the tuple type parameters now permit that. The
psinfo readers on Solaris and AIX return null when the process is gone.

The tuple classes therefore declare their type parameters as extending
@nullable Object. This permits a nullable element without requiring one, and
is forced by oshi.util.tuples being marked: its type variables otherwise
default to non-null, which no caller storing an absent value can satisfy.

Lspv reads three maps it fills together and its comment notes they share
keys; that is now expressed rather than assumed. AixBaseboard and the Solaris
process and thread classes follow the drivers they call, as do the JNA and FFM
forwarding twins of the performance-data classes.

Making these honest surfaces 25 warnings in oshi-core and oshi-core-ffm, in
the Windows registry and operating system stack. Resolving them here would
mean editing nine more files and changing an abstract signature in the
operating system group, so they are left for the group that covers those
modules; the warning count tracks them.

* Preserve the nullable result through the memoized Solaris queries

CodeRabbit review of #3619. SolarisOSProcess.getPsInfo documented returning
null when the psinfo could not be read, but declared otherwise, and the
suppliers feeding it were typed non-null despite memoizing a query that
returns null for a process that has exited.

Memoizer's type parameter now extends @nullable Object. It holds whatever
the supplier produces, and a memoized nullable value is otherwise silently
absorbed by the type variable, which is why this was not reported.

PsInfoJNA.queryArgsEnv and queryArgsEnvAddrs receive that value and both
already open by checking it for null; they now say so.

* Say in the javadoc that the psinfo argument may be absent

CodeRabbit review of #3619. Both methods accept a null psinfo and check for
it, but their parameter descriptions still said "a populated SolarisPsInfo".
queryArgsEnv's return also needed a word: unlike queryArgsEnvAddrs, which
documents returning null, it always returns a pair and reports failure as
empty collections.

queryArgsEnvAddrs's @return already documented its null, so it is unchanged.
dbwiddis added a commit that referenced this pull request Aug 15, 2026
Fourth group of the backlog #3618 left at WARN. Takes oshi-common from 172
warnings to 158 and clears the GPU classes; the reactor drops 568 to 554 with
nothing newly surfaced.

Two of these describe themselves. LinuxGpuStats caches the NVML device id in a
field commented "null means not yet resolved, empty string means unavailable",
which is three states in a type that admitted two. findDrmInfo documents
"the PCI slot address, or null to use first-match" on both overloads, and is
passed as a Function whose input the callers may not know.

The rest follow: WindowsGpuStats' two lazily populated caches, MacGpuStats'
sampler, which is null when the IOReport subscription could not be created and
which the constructor already checks and logs, and DxgiUtil.findMatch with its
JNA forwarder.

LinuxGraphicsCard and its native-free subclass are here rather than with the
peripherals group, because they share findDrmInfo and the DRM lookup function
with the GpuStats classes; splitting them would mean deciding one contract in
two places.
dbwiddis added a commit that referenced this pull request Aug 15, 2026
* Make the operating system layer's nullability contracts honest

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.

* Match the overrides in the Windows JNA and FFM implementations

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.
dbwiddis added a commit that referenced this pull request Aug 15, 2026
* Make CentralProcessor's nullability contracts honest

Sixth group of the backlog #3618 left at WARN. Takes oshi-common from 103
warnings to 59 and clears CentralProcessor across all eight platform
implementations.

initProcessorCounts returns a quartet whose physical processor and cache
lists several platforms cannot discover: AIX and Solaris pass null for one or
both outright, and the BSDs pass a value that may be absent. The abstract
signature now says so.

processTickData took sixteen counter lists and null-checked all of them, but
the check for the ten utility counters sat inside the USE_CPU_UTILITY branch,
which the analyzer cannot correlate with the same flag being read later. That
guard also discarded the whole sample: with the utility counters enabled but
any one of them unavailable, it returned all-zero ticks, throwing away the
five raw counters that had been read successfully. The utility counters now
refine the raw ticks when they are all present, and are skipped when they are
not.

Windows lazily initializes its NUMA node map and utility multiplier. The map
now starts empty rather than null, following AbstractOSThread and the process
attributes in the previous group, and the capacity tick supplier, which only
exists when the utility counters are in use, is checked where it is read.

The rest were documented but unstated: the cpuid and IORegistry readers, the
per-core property pairs on Apple Silicon whose compatible and cluster-type
values are read separately and may each be absent, the BSD cache string
parser, and the udev enumeration that returns null when udev is unavailable.

* Do not give the NUMA map a field initializer

CodeRabbit review of #3623. AbstractCentralProcessor's constructor calls
initProcessorCounts, and the Windows implementations populate the NUMA node
map from there. A field initializer on the subclass runs after the superclass
constructor, so the empty map added in the previous commit overwrote the map
that had just been built.

On a NUMA machine every NUMA-qualified counter instance would then fail to
resolve, and processTickData would skip it and report zero ticks.

The field carries no initializer now. It is genuinely null until that virtual
call assigns it, so it says so, and the getter substitutes an empty map for
readers.
dbwiddis added a commit that referenced this pull request Aug 15, 2026
* Make the system identity classes' nullability contracts honest

Seventh group of the backlog #3618 left at WARN. Takes oshi-common from 59
warnings to 19 and clears ComputerSystem, Baseboard and Firmware across every
platform. Only the peripherals group remains.

These classes read manufacturer, model, serial number, UUID and firmware
version from whatever the platform will say: dmidecode, lshw, lsattr, smbios,
the IORegistry, WMI. Each of those may report nothing, and each class carries
the values in a tuple or a small holder whose fields were declared non-null.

The public getters must not change: Baseboard.getManufacturer and its
neighbours are @publicapi and promise a value. They returned the tuple element
straight through, so a platform that reported nothing returned null through
that promise. They now report Constants.UNKNOWN, which is what the rest of the
API does for a value it could not read.

Solaris asked smbTypesMap for three sections that the smbios output need not
contain, then dereferenced the results, and built the map with a get().put()
that assumed the section already existed. Both go through
getOrDefault/computeIfAbsent now.

MacBaseboard and MacComputerSystem spell out the blank test for the
manufacturer they default to "Apple Inc.", since Util.isBlank is a predicate
the analyzer cannot see through.

* Address review: drop annotations the normalization makes unreachable

- LsattrStrings normalizes every field through getStringValueOrUnknown in its
  constructor, so the fields and accessors cannot be null. The @nullable stays
  on the constructor parameters, which are the raw parsed values.
- FreeBsdComputerSystem.readDmiDecode likewise normalizes every component before
  returning, so the memoized Quintet's type arguments are non-null and the
  getters' getStringValueOrUnknown wrappers were redundant. parseDmiDecode keeps
  its nullable component types; it is the raw parse.
- MacBaseboard.decodeProperty duplicated what ParseUtil.decodeNulTerminated
  already does: it accepts a null array and returns an empty string. The call
  sites test the result with isBlank or getStringValueOrUnknown, which treat
  null and empty alike, so calling ParseUtil directly is equivalent.
dbwiddis added a commit that referenced this pull request Aug 15, 2026
NullAway has run at WARN since #3618 so the backlog it exposed could be drained
without blocking the build. That backlog is now zero across oshi-common,
oshi-core and oshi-core-ffm, so the check moves to ERROR and a signature that
contradicts its annotations fails the build rather than adding to a list.

Verified by building the whole reactor under -Perror-prone with the flip in
place: zero findings, BUILD SUCCESS.

Updates the two pom comments that still described this as groundwork for
annotations that had not landed, and the FAQ, which claimed only oshi.hardware
and oshi.software.os were marked and that a violation fails CI - the first was
out of date and the second was not true while the check ran at WARN.

Re-summarizes the CHANGELOG for the whole arc as one entry: what was adopted,
then what the sweep fixed, then the user-facing behavior changes as a list. One
pull request link per line, for readability of the raw markdown.
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