Skip to content

Fix remaining Error Prone findings: API-shape + mechanical cleanup - #3604

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:fix-tail-cleanup-warnings
Aug 13, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:fix-tail-cleanup-warnings

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Aug 13, 2026 •

Copy link
Copy Markdown
Member

Summary

Combines two lower-risk tail groups per triage discussion on #3600-3603: API-shape findings that only look like public API (verified none touch @PublicApi or the oshi.hardware/oshi.software.os semver surface), plus purely mechanical syntax modernization.

API-shape (NonApiType, InvalidParam, EffectivelyPrivate, ImmutableEnumChecker) — checked each site's actual visibility before fixing:

  • WindowsFileSystemJNA/WindowsFileSystemFFM's getLocalVolumes: package-private (not even accessible outside the package), returns ArrayList where only List interface methods are ever used on the result — narrowed to List.
  • LinuxOSProcess/LinuxOSThread: public int getOrder() on a private nested enum — the public modifier is a no-op since the enum itself can't be referenced outside the enclosing class. Dropped it.
  • AbstractCentralProcessor.CpuidFeature.names: String[] → Collections.unmodifiableList(Arrays.asList(...)), suppressed the one further warning about List not being a nominally-immutable type (no Guava dependency to satisfy that literally).
  • LinuxHWDiskStore.UdevStat.order: added the missing final — assigned once, in the constructor, never reassigned.
  • LibKstatFunctions/IOReport javadoc: suppressed — {@code name}/{@code null} in the doc text refer to a native struct field name and a value-to-pass respectively, unrelated to the similarly-spelled parameter (named/null3) the checker flagged them against.

Mechanical cleanup (StatementSwitchToExpressionSwitch, UnnecessaryLambda, UnnecessaryParentheses, AssignmentExpression, UnusedVariable):

  • 6 statement switches converted to arrow-style switch statements/expressions (oshi-core-ffm, Java 25 — no fallthrough existed before, so no behavior change).
  • 5 lambdas stored in test constants or returned from a helper method replaced with method references to a directly-implemented method (per the checker's own suggested fix).
  • WhoJNA's while (nonNull(ut = LIBC.getutxent())) is the standard C-iterator-style idiom; suppressed rather than restructured.
  • Removed a redundant parenthesized subexpression (AbstractCentralProcessor), a dead initial value unconditionally overwritten before any read (WmiQueryHandler.initCOM), and a test field assigned in @BeforeAll but never read anywhere (OshiMetricsTest).
  • OperatingSystemTest.descendantNotLessThanChild: traced all three per-category blocks before touching this — the variable is correctly used and asserted on in two of the three blocks; only its very first initializer (before an unrelated block that never touches it) was dead. Moved the declaration to where it's first actually needed rather than leaving a redundant reset.
  • DiskMetrics.diskStores was already correctly documented as an intentional GC anchor (holds a strong reference so Micrometer's WeakReference doesn't get collected), but the existing @SuppressWarnings only carried Sonar's rule id (java:S1068), not Error Prone's own check name — added it.

Test plan

  • ./mvnw clean install -Perror-prone -DskipTests: 0 ERROR; all listed categories → 0
  • ./mvnw -pl oshi-common,oshi-core,oshi-core-ffm,oshi-metrics -am test: 0 tests failed
  • ./mvnw checkstyle:check, forbiddenapis:check, clean compile javadoc:javadoc: all pass

Summary by CodeRabbit

  • Refactor

    • Modernized internal control-flow and collection declarations without changing runtime behavior.
    • Improved immutability and visibility safeguards across hardware, operating-system, and platform integrations.
    • Preserved existing processor, disk, process, filesystem, WMI, and service-state handling.
  • Tests

    • Simplified test helpers and fixtures while retaining existing assertions and coverage.
    • Standardized test formatting and removed unused setup code.
  • Chores

    • Added clarifying comments and warning suppressions for intentional platform-specific code patterns.

API-shape findings (NonApiType, InvalidParam, EffectivelyPrivate,
ImmutableEnumChecker) - verified none touch @publicapi or the
oshi.hardware/oshi.software.os semver surface before fixing:
- WindowsFileSystemJNA/FFM.getLocalVolumes: package-private, return
  List instead of ArrayList.
- LinuxOSProcess/LinuxOSThread: dropped the pointless `public` on a
  method of a private nested enum.
- AbstractCentralProcessor.CpuidFeature.names: String[] -> unmodifiable
  List; LinuxHWDiskStore.UdevStat.order: added missing final.
- LibKstatFunctions/IOReport javadoc: suppressed InvalidParam - "name"/
  "null" in the doc text is unrelated to the similarly-spelled
  parameter it was flagged against.

Mechanical cleanup (StatementSwitchToExpressionSwitch,
UnnecessaryLambda, UnnecessaryParentheses, AssignmentExpression,
UnusedVariable):
- Converted 6 statement switches to arrow-style switch
  statements/expressions (oshi-core-ffm, Java 25).
- Replaced 5 lambdas stored in test constants/returned from helper
  methods with method references to a directly-implemented method.
- WhoJNA's assignment-in-while-condition is the standard "loop while
  getutxent() returns non-null" idiom; suppressed rather than changed.
- Removed a redundant parenthesized subexpression, a dead initial
  value that was unconditionally overwritten before any read, and an
  orphaned test field that was assigned but never read anywhere.
- OperatingSystemTest's descendantNotLessThanChild dead initializer:
  moved the declaration to where it's actually first used; traced all
  three call sites to confirm this isn't a missing assertion.
- DiskMetrics.diskStores was already correctly explained as an
  intentional GC anchor, but only suppressed Sonar's rule id, not
  Error Prone's; added the missing key.
@coderabbitai

coderabbitai Bot commented Aug 13, 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: 9aaaa920-f6f6-4ead-9e1f-6dfd9902f292

📥 Commits

Reviewing files that changed from the base of the PR and between b3de8bb and 99c5cf8.

📒 Files selected for processing (22)
  • oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSThread.java
  • oshi-common/src/main/java/oshi/software/os/OperatingSystem.java
  • oshi-common/src/test/java/oshi/driver/common/unix/bsd/disk/DisklabelTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxGraphicsCardTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/mac/MacGpuStatsTest.java
  • oshi-core-ffm/src/main/java/oshi/driver/windows/LogicalProcessorInformationFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/LibKstatFunctions.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/KstatUtilFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WbemcliUtilFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WmiQueryHandlerFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/IOReport.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
  • oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java
  • oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.java
  • oshi-metrics/src/main/java/oshi/metrics/DiskMetrics.java
  • oshi-metrics/src/test/java/oshi/metrics/OshiMetricsTest.java
💤 Files with no reviewable changes (1)
  • oshi-metrics/src/test/java/oshi/metrics/OshiMetricsTest.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, FreeBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Error Prone
  • GitHub Check: Lint (ForbiddenAPIs, Javadoc, SLF4J)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle)
  • GitHub Check: Analyze (java)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{java,properties}

📄 CodeRabbit inference engine (AGENTS.md)

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

Files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSThread.java
  • oshi-common/src/test/java/oshi/driver/common/unix/bsd/disk/DisklabelTest.java
  • oshi-common/src/main/java/oshi/software/os/OperatingSystem.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WmiQueryHandlerFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WbemcliUtilFFM.java
  • oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/driver/windows/LogicalProcessorInformationFFM.java
  • oshi-metrics/src/main/java/oshi/metrics/DiskMetrics.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/LibKstatFunctions.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/KstatUtilFFM.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/IOReport.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/mac/MacGpuStatsTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxGraphicsCardTest.java
  • oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.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/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSThread.java
  • oshi-common/src/test/java/oshi/driver/common/unix/bsd/disk/DisklabelTest.java
  • oshi-common/src/main/java/oshi/software/os/OperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/mac/MacGpuStatsTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxGraphicsCardTest.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-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSThread.java
  • oshi-common/src/test/java/oshi/driver/common/unix/bsd/disk/DisklabelTest.java
  • oshi-common/src/main/java/oshi/software/os/OperatingSystem.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WmiQueryHandlerFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WbemcliUtilFFM.java
  • oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/driver/windows/LogicalProcessorInformationFFM.java
  • oshi-metrics/src/main/java/oshi/metrics/DiskMetrics.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/LibKstatFunctions.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/KstatUtilFFM.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/IOReport.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/mac/MacGpuStatsTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxGraphicsCardTest.java
  • oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.java
**/*Test.java

📄 CodeRabbit inference engine (AGENTS.md)

**/*Test.java: Test files are named *Test.java.
Tests must pass there and on real hardware.

  • Assert on invariants (non-null, correct type, ordering, a plausible range), not on specific values.

Files:

  • oshi-common/src/test/java/oshi/driver/common/unix/bsd/disk/DisklabelTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/mac/MacGpuStatsTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxGraphicsCardTest.java
  • oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.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/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WmiQueryHandlerFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WbemcliUtilFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/driver/windows/LogicalProcessorInformationFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/LibKstatFunctions.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/KstatUtilFFM.java
oshi-core/src/test/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

oshi-core/src/test/java/**/*.java: Any oshi-core test that allocates JNA needs
@DisabledIfSystemProperty(named = "os.name", matches = "(?i).*netbsd.*"); the NetBSD CI runner
has no libjnidispatch.

Files:

  • oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.java
🧠 Learnings (29)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3530
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:43-48
Timestamp: 2026-07-26T23:06:49.011Z
Learning: In the oshi/oshi repository, `oshi.util.ExceptionUtil` is intentionally outside the binary-compatibility surface: japicmp enforces compatibility only for types annotated `oshi.annotation.PublicApi`, and `ExceptionUtil` is not annotated. Therefore, do not flag in-place public method descriptor changes in `ExceptionUtil` merely because precompiled third-party callers could receive `NoSuchMethodError`; source compatibility and lockstep module releases are the applicable expectations. If this guarantee is desired later, annotating `ExceptionUtil` with `PublicApi` is the policy mechanism rather than adding numerous forwarding overloads.
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:51.516Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:26:05.716Z
Learning: In oshi/oshi, `oshi-common/src/main/java/oshi/util/ExceptionUtil.java`'s private `logAtLevel(Logger, Level, String, Throwable)` helper (and the similar pattern in `oshi-core-ffm/src/main/java/oshi/ffm/ForeignFunctions.java` and `oshi-core/src/main/java/oshi/util/platform/windows/PerfDataUtil.java`) intentionally calls SLF4J 1.x-compatible methods like `log.error(msg, t.getMessage(), t)` with a single `{}` placeholder in `msg` and the `Throwable t` as the trailing argument. This is not a bug: SLF4J's implicit-cause handling (since 1.6.0) detects a trailing `Throwable` argument and attaches it as the log event's cause with full stack trace, equivalent to the SLF4J 2.x-only `.atLevel(level).setCause(t).log(...)` fluent API that this PR deliberately avoids for SLF4J 1.x runtime compatibility. Do not flag these calls as losing the throwable cause/stack trace.
Learnt from: CR
Repo: oshi/oshi PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-08-12T22:15:37.668Z
Learning: Applies to oshi-common/**/*.java : `oshi-common` may not reference `com.sun.jna.**`, `java.lang.foreign.**`, or any
  `System.load`/`loadLibrary`. It must stay pure JDK.
📚 Learning: 2026-04-05T05:40:45.797Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceFFM.java:62-65
Timestamp: 2026-04-05T05:40:45.797Z
Learning: In OSHI's Linux FFM and JNA udev code, a null guard on `udev_enumerate_new()` is intentionally absent and should not be flagged. This is consistent across all four FFM classes (LinuxPowerSourceFFM, LinuxHWDiskStoreFFM, LinuxLogicalVolumeGroupFFM, LinuxUsbDeviceFFM) and the JNA implementation (which also does not guard `enumerateNew()` for null). Per libudev semantics, `udev_enumerate_new()` only returns NULL when udev itself is broken (e.g. OOM), so a successful `udev_new()` (which is guarded) implies `udev_enumerate_new()` will succeed. Adding a null guard would be both redundant and inconsistent with the established pattern.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/LibKstatFunctions.java
📚 Learning: 2026-04-06T04:45:51.516Z
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:51.516Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSThread.java
  • oshi-common/src/main/java/oshi/software/os/OperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.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/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSThread.java
  • oshi-common/src/main/java/oshi/software/os/OperatingSystem.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WmiQueryHandlerFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WbemcliUtilFFM.java
  • oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/driver/windows/LogicalProcessorInformationFFM.java
  • oshi-metrics/src/main/java/oshi/metrics/DiskMetrics.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/LibKstatFunctions.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/KstatUtilFFM.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/IOReport.java
📚 Learning: 2026-04-05T05:39:21.126Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceFFM.java:62-65
Timestamp: 2026-04-05T05:39:21.126Z
Learning: In OSHI's Linux FFM/JNA udev code, a null guard on `udev_enumerate_new()` is unnecessary if `udev_new()` has already been guarded: per libudev semantics, `udev_enumerate_new()` only returns NULL when udev itself is broken (e.g. OOM), so a successful `udev_new()` implies `udev_enumerate_new()` will succeed as well. Do not flag missing null checks on `udev_enumerate_new()` as an issue.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java
📚 Learning: 2026-06-26T05:09:03.075Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3410
File: oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSFileStore.java:18-18
Timestamp: 2026-06-26T05:09:03.075Z
Learning: In `oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSFileStore.java`, the `unreachable` flag on `LinuxOSFileStore` should be treated as per-instance snapshot state for stale NFS handling, not as mutable recovery state. If an NFS server later recovers, callers are expected to create a new `LinuxFileSystem` and obtain a fresh set of `OSFileStore` objects rather than mutating an existing `LinuxOSFileStore` back to reachable. For this design, a documentation note may be appropriate, but no code fix is required.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.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/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSThread.java
  • oshi-common/src/main/java/oshi/software/os/OperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.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/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSThread.java
  • oshi-common/src/main/java/oshi/software/os/OperatingSystem.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WmiQueryHandlerFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WbemcliUtilFFM.java
  • oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/driver/windows/LogicalProcessorInformationFFM.java
  • oshi-metrics/src/main/java/oshi/metrics/DiskMetrics.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/LibKstatFunctions.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/KstatUtilFFM.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/IOReport.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/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSThread.java
  • oshi-common/src/test/java/oshi/driver/common/unix/bsd/disk/DisklabelTest.java
  • oshi-common/src/main/java/oshi/software/os/OperatingSystem.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WmiQueryHandlerFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WbemcliUtilFFM.java
  • oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/driver/windows/LogicalProcessorInformationFFM.java
  • oshi-metrics/src/main/java/oshi/metrics/DiskMetrics.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/LibKstatFunctions.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/KstatUtilFFM.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/IOReport.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/mac/MacGpuStatsTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxGraphicsCardTest.java
  • oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.java
📚 Learning: 2026-05-31T04:49:19.668Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3310
File: oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdOperatingSystem.java:164-166
Timestamp: 2026-05-31T04:49:19.668Z
Learning: In the oshi/oshi project, the NetBSD platform intentionally removes all JNA/native library dependencies (PR `#3310`). `NetBsdOperatingSystem.getThreadId()` uses `(int) Thread.currentThread().getId()` rather than `NetBsdLibc._lwp_self()` because the JNA native library is not bundled with the Maven dependency for the NetBSD platform. The mismatch between Java thread ids and kernel LWP ids is an accepted trade-off. Do not suggest reintroducing JNA-based calls (such as `NetBsdLibc._lwp_self()`) in NetBSD platform code.

Applied to files:

  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSThread.java
  • oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java
📚 Learning: 2026-07-26T23:06:49.011Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3530
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:43-48
Timestamp: 2026-07-26T23:06:49.011Z
Learning: In the oshi/oshi repository, `oshi.util.ExceptionUtil` is intentionally outside the binary-compatibility surface: japicmp enforces compatibility only for types annotated `oshi.annotation.PublicApi`, and `ExceptionUtil` is not annotated. Therefore, do not flag in-place public method descriptor changes in `ExceptionUtil` merely because precompiled third-party callers could receive `NoSuchMethodError`; source compatibility and lockstep module releases are the applicable expectations. If this guarantee is desired later, annotating `ExceptionUtil` with `PublicApi` is the policy mechanism rather than adding numerous forwarding overloads.

Applied to files:

  • oshi-common/src/main/java/oshi/software/os/OperatingSystem.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WmiQueryHandlerFFM.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
📚 Learning: 2026-05-04T04:58:36.843Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3227
File: oshi-metrics/src/main/java/oshi/metrics/OshiMetrics.java:35-48
Timestamp: 2026-05-04T04:58:36.843Z
Learning: In `oshi-metrics/src/main/java/oshi/metrics/OshiMetrics.java`, the `private final OperatingSystem os` field is intentionally stored in the constructor even though it is not yet used. It is a placeholder for future OS-level metrics (e.g., process metrics) that will be added incrementally. Do not flag it as dead code.

Applied to files:

  • oshi-common/src/main/java/oshi/software/os/OperatingSystem.java
  • oshi-metrics/src/main/java/oshi/metrics/DiskMetrics.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/LibKstatFunctions.java
  • oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.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/WindowsOperatingSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WmiQueryHandlerFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WbemcliUtilFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/driver/windows/LogicalProcessorInformationFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/LibKstatFunctions.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/KstatUtilFFM.java
📚 Learning: 2026-04-18T22:53:56.149Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3173
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java:107-193
Timestamp: 2026-04-18T22:53:56.149Z
Learning: In OSHI's `WmiQueryHandlerFFM` (oshi-core-java25) and the JNA `WmiQueryHandler` (oshi-core), the `failedWmiClassNames` cache intentionally keys failures by WMI class name only (not namespace). This is a pre-existing, accepted pattern shared between both implementations. Do not flag this as a bug in future reviews — the project maintainer (dbwiddis) confirmed it does not impact callers and the added complexity of a composite namespace+class key is not warranted.

Applied to files:

  • oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WmiQueryHandlerFFM.java
📚 Learning: 2026-03-29T20:03:00.830Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java:87-89
Timestamp: 2026-03-29T20:03:00.830Z
Learning: In the OSHI FFM codebase (oshi-core-java25), all PDH/Kernel32/COM wrapper methods in classes like PdhFFM, Kernel32FFM, etc. declare `throws Throwable` solely as a compiler artifact of `MethodHandle.invokeExact`. They are native calls and do not throw Java checked exceptions in practice. The enclosing `getOpenFileDescriptors()` method in PdhUtilFFM already has an outer `catch (Throwable t)` that covers the entire method body including any `finally` blocks, so no exception-masking concern exists for cleanup calls like `PdhCloseQuery` in `finally`.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WmiQueryHandlerFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/LibKstatFunctions.java
📚 Learning: 2026-08-12T22:15:37.668Z
Learnt from: CR
Repo: oshi/oshi PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-08-12T22:15:37.668Z
Learning: Applies to oshi-core-ffm/**/*.java : `oshi-core-ffm` may not reference `com.sun.jna.**`.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WmiQueryHandlerFFM.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/driver/windows/LogicalProcessorInformationFFM.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/IOReport.java
📚 Learning: 2026-04-18T23:21:43.993Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3173
File: oshi-common/src/main/java/oshi/driver/common/windows/wmi/Win32LogicalDisk.java:44-46
Timestamp: 2026-04-18T23:21:43.993Z
Learning: In OSHI's `Win32LogicalDisk.buildWmiClassNameWithWhere` (oshi-common), the `nameToMatch` parameter is always internally controlled (e.g., a drive name from a prior WMI query result), not arbitrary user input. Do not flag missing WQL escape sequences (backslash, single-quote) as a bug — the project maintainer (dbwiddis) confirmed only the existing double-quote escaping is needed.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WmiQueryHandlerFFM.java
📚 Learning: 2026-04-19T01:28:47.155Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3174
File: oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java:237-257
Timestamp: 2026-04-19T01:28:47.155Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`, the WMI comparison tests (e.g., `testProcessor`) intentionally validate only index 0 and a few representative fields per WMI data type (String, uint16, uint32, uint64). Exhaustive row-by-row comparison is deliberately avoided for numerically heavy multi-row tables. The design rationale is: matching row counts + a few selected fields covering each data type is sufficient to verify JNA vs FFM driver parity. Do not suggest looping over all rows for these tests.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WmiQueryHandlerFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WbemcliUtilFFM.java
📚 Learning: 2026-04-03T02:07:49.467Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3110
File: oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHWDiskStoreFFM.java:119-121
Timestamp: 2026-04-03T02:07:49.467Z
Learning: In `oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHWDiskStoreFFM.java` (and similar FFM/API implementations in OSHI), the `updateAttributes()` method intentionally uses `catch (Throwable e) { return false; }` without logging. This is by design: `updateAttributes()` is a public API method whose contract is to return `false` on failure; callers consume the boolean and would never see log output, so adding a log statement is not desired.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WmiQueryHandlerFFM.java
📚 Learning: 2026-04-10T22:44:36.786Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3136
File: oshi-core-java25/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java:46-53
Timestamp: 2026-04-10T22:44:36.786Z
Learning: In OSHI's `AuxvFFM.queryAuxv()` (oshi-core-java25/src/main/java/oshi/driver/linux/proc/AuxvFFM.java), the do-while loop is safe even when `/proc/self/auxv` cannot be read: `FileUtil.readAllBytesAsBuffer` returns an empty ByteBuffer on failure, and `FileUtil.readLongFromBuffer`/`readIntFromBuffer` return 0L when reading past the buffer limit. This 0L equals AT_NULL, causing the loop to exit immediately with an empty map, which triggers the `getconf`/hardcoded-default fallback in callers like `LinuxOperatingSystemFFM`. Do not flag this do-while loop or the static initializer that calls `AuxvFFM.queryAuxv()` as unsafe.

Applied to files:

  • oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java
📚 Learning: 2026-04-08T00:58:10.736Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3125
File: oshi-core-java25/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java:131-133
Timestamp: 2026-04-08T00:58:10.736Z
Learning: In `oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceJNA.java` and `oshi-core-java25/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java`, the `getPowerSources()` method intentionally returns a singleton list wrapping a single `getPowerSource("System Battery")` call, and the enumeration loop short-circuits after the first eligible battery pack. This matches the longstanding JNA behavior and is not a bug. A broader refactor to support zero-or-more batteries across both implementations is planned for a later date. Do not flag this as an issue.

Applied to files:

  • oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.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/WindowsFileSystemJNA.java
📚 Learning: 2026-03-29T20:01:06.452Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java11/src/main/java/module-info.java:10-17
Timestamp: 2026-03-29T20:01:06.452Z
Learning: In the oshi project, `oshi-core-java25/src/main/java/module-info.java` intentionally does NOT export `oshi.util.platform.unix.freebsd`, `oshi.util.platform.unix.openbsd`, or `oshi.util.platform.unix.solaris`, because the FFM (Foreign Function & Memory) implementation only supports Windows, macOS, and Linux. This differs from `oshi-core-java11/src/main/java/module-info.java` which exports all Unix platform packages. The asymmetry is by design.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/LibKstatFunctions.java
📚 Learning: 2026-04-03T18:44:48.200Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3112
File: oshi-core/src/main/java/oshi/PlatformEnum.java:63-66
Timestamp: 2026-04-03T18:44:48.200Z
Learning: In oshi/oshi PlatformEnum.java, the DRAGONFLYBSD enum constant is intentionally added for platform detection only (no implementation classes exist yet). It allows UnsupportedOperationException messages to say "DragonFly BSD" rather than "Unknown". Full DragonFly BSD support is tracked in issue `#2583`. Do not flag the missing switch-case implementations as a bug.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/KstatUtilFFM.java
📚 Learning: 2026-07-28T18:20:41.673Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 0
File: :0-0
Timestamp: 2026-07-28T18:20:41.673Z
Learning: In `oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java`, `MacCentralProcessor.initProcessorCounts()` constructs every `PhysicalProcessor` with a non-null ID string: an absent IORegistry `compatible` property is normalized to `""`. Therefore, the production call `MacCentralProcessor.deriveMicroarchitecture(getPhysicalProcessors())` may safely call `PhysicalProcessor#getIdString()` without a null guard.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/mac/MacGpuStatsTest.java
📚 Learning: 2026-04-12T19:34:59.050Z
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:34:59.050Z
Learning: The counterintuitive naming of `PhysicalProcessor.getEfficiency()` / `EfficiencyClass` in OSHI (where a higher value means MORE performance and LESS efficiency, so P-cores get higher values than E-cores) is intentionally inherited from Microsoft's `PROCESSOR_RELATIONSHIP.EfficiencyClass` Win32 API: "A core with a higher value for the efficiency class has intrinsically greater performance and less efficiency." OSHI follows this same convention for cross-platform consistency. Do not flag P-cores being assigned higher efficiency values as a bug.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
📚 Learning: 2026-04-15T04:56:18.352Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3163
File: oshi-core-java25/src/test/java/oshi/ffm/mac/CoreFoundationTest.java:97-103
Timestamp: 2026-04-15T04:56:18.352Z
Learning: In CoreFoundationTest.java (oshi-core-java25/src/test/java/oshi/ffm/mac/CoreFoundationTest.java), asserting exact CFGetRetainCount deltas (+1 after retain, -1 after release) is intentional and considered reliable for freshly created CF objects (e.g., CFStringRef via CFStringRef.createCFString) where the test holds sole ownership. Do not flag these assertions as flaky — the Apple "avoid CFGetRetainCount" advisory applies to shared/framework-managed objects, not exclusively owned objects in unit tests.

Applied to files:

  • oshi-core/src/main/java/oshi/jna/platform/mac/IOReport.java
📚 Learning: 2026-04-18T03:18:06.205Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:06.205Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).

Applied to files:

  • oshi-common/src/test/java/oshi/hardware/common/platform/mac/MacGpuStatsTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxGraphicsCardTest.java
📚 Learning: 2026-04-11T05:51:52.684Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3139
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxGpuStatsFFM.java:36-58
Timestamp: 2026-04-11T05:51:52.684Z
Learning: In OSHI's `LinuxGpuStats` (oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxGpuStats.java), the abstract `nvml*` methods (nvmlGetVramUsed, nvmlGetCoreClockMhz, nvmlGetMemoryClockMhz, nvmlGetTemperature, nvmlGetPowerDraw, nvmlGetFanSpeedPercent) are contractually expected to return `-1` (long or double) on failure. The base class applies `if (val >= 0)` guards before using any NVML result and falls through to sysfs/hwmon paths when negative. Subclasses (LinuxGpuStatsJNA, LinuxGpuStatsFFM) correctly pass through the -1 sentinel unchanged — do not flag this as a missing clamp or contract violation.

Applied to files:

  • oshi-common/src/test/java/oshi/hardware/common/platform/mac/MacGpuStatsTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxGraphicsCardTest.java
🔇 Additional comments (21)
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxGraphicsCardTest.java (1)

36-44: LGTM!

Also applies to: 58-58, 72-72, 180-180, 197-223, 235-244, 255-255, 264-266, 291-296, 329-331, 353-353, 364-366, 375-375, 388-388, 399-399, 413-421, 446-446

oshi-common/src/test/java/oshi/hardware/common/platform/mac/MacGpuStatsTest.java (1)

157-168: LGTM!

Also applies to: 177-209, 219-227, 248-248, 259-260

oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.java (1)

309-309: LGTM!

Also applies to: 333-333

oshi-metrics/src/main/java/oshi/metrics/DiskMetrics.java (1)

52-52: LGTM!

oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java (1)

294-301: LGTM!

Also applies to: 398-398

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

81-87: LGTM!

oshi-core-ffm/src/main/java/oshi/driver/windows/LogicalProcessorInformationFFM.java (1)

91-96: LGTM!

oshi-core-ffm/src/main/java/oshi/ffm/util/platform/unix/solaris/KstatUtilFFM.java (1)

219-230: LGTM!

Also applies to: 258-266

oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WbemcliUtilFFM.java (1)

241-256: LGTM!

oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/WmiQueryHandlerFFM.java (1)

217-223: LGTM!

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

101-101: LGTM!

Also applies to: 144-145

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

94-94: LGTM!

Also applies to: 132-133

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

404-405: LGTM!

oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java (1)

345-345: LGTM!

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

481-483: LGTM!

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

134-136: LGTM!

oshi-common/src/test/java/oshi/driver/common/unix/bsd/disk/DisklabelTest.java (1)

40-44: LGTM!

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

174-178: LGTM!

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

50-52: LGTM!

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

10-13: LGTM!

Also applies to: 58-60

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

225-231: LGTM!


📝 Walkthrough

Walkthrough

This pull request applies behavior-preserving Java cleanup across OSHI modules. It modernizes switch syntax, narrows visibility and collection types, documents native interop suppressions, and updates test helpers and formatting.

Changes

Java modernization and cleanup

Layer / File(s) Summary
Common API and state cleanup
oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java, oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java, oshi-common/src/main/java/oshi/software/common/os/linux/*, oshi-common/src/main/java/oshi/software/os/OperatingSystem.java, oshi-common/src/test/java/oshi/driver/common/unix/bsd/disk/DisklabelTest.java
Processor feature names use an unmodifiable list. Order fields and accessors use narrower mutability and visibility. The no-sort comparator and disk-label test use named methods.
FFM switch and collection modernization
oshi-core-ffm/src/main/java/oshi/driver/windows/LogicalProcessorInformationFFM.java, oshi-core-ffm/src/main/java/oshi/ffm/util/platform/{unix/solaris,windows}/*, oshi-core-ffm/src/main/java/oshi/software/os/windows/*
Traditional switches use arrow cases or switch expressions. Windows file-system collections use List<OSFileStore>. Existing mappings and fallback behavior remain unchanged.
Native interop warning cleanup
oshi-core/src/main/java/oshi/driver/linux/WhoJNA.java, oshi-core/src/main/java/oshi/jna/platform/mac/IOReport.java, oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java, oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/solaris/LibKstatFunctions.java
Native declarations document intentional parameters and suppress targeted warnings. COM initialization assigns the initial result directly.
Test and metrics maintenance
oshi-common/src/test/java/oshi/hardware/common/platform/{linux/LinuxGraphicsCardTest.java,mac/MacGpuStatsTest.java}, oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.java, oshi-metrics/src/{main,test}/java/oshi/metrics/*
Tests receive formatting updates, a nullSampler helper, adjusted variable initialization, and removal of unused operating-system setup state. The disk metrics suppression list is expanded.

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

Mergeability Score: ⚪ Minimal · up to 99c5c

This PR makes localized API-shape and mechanical cleanup changes, with the reported validation checks passing; no actionable merge-blocking risk remains beyond normal review.

Possibly related PRs

  • oshi/oshi#3595: Directly overlaps with the warning and maintainability cleanup in several modified files.
  • oshi/oshi#3598: Overlaps in LinuxHWDiskStore, LinuxOSProcess, and LinuxOSThread.
  • oshi/oshi#3601: Both changes modify LogicalProcessorInformationFFM.getLogicalProcessorInformationEx.

Poem

I hop through switches, neat and bright,
With lists made safe and warnings light.
Tests stand tidy, helpers sing,
No behavior changed in anything.
Thump-thump—clean code takes its flight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 29.79% 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 accurately summarizes the Error Prone fixes, including API-shape adjustments and mechanical cleanup.
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 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 56.41026% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.90%. Comparing base (b3de8bb) to head (99c5cf8).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...i/ffm/util/platform/unix/solaris/KstatUtilFFM.java 46.15% 5 Missing and 2 partials ⚠️
...oshi/ffm/util/platform/windows/WbemcliUtilFFM.java 41.66% 7 Missing ⚠️
...software/os/windows/WindowsOperatingSystemFFM.java 60.00% 1 Missing and 1 partial ⚠️
...oshi/hardware/common/AbstractCentralProcessor.java 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3604      +/-   ##
============================================
+ Coverage     79.89%   79.90%   +0.01%     
- Complexity       76     4240    +4164     
============================================
  Files           710      710              
  Lines         24255    24242      -13     
  Branches       4057     4057              
============================================
- Hits          19378    19371       -7     
+ Misses         2720     2714       -6     
  Partials       2157     2157              
Flag Coverage Δ
freebsd 33.49% <7.69%> (+0.02%) ⬆️
linux 37.58% <7.69%> (+<0.01%) ⬆️
macos 38.41% <7.69%> (-0.01%) ⬇️
openbsd 32.67% <7.69%> (+0.02%) ⬆️
solaris 34.16% <23.07%> (+0.02%) ⬆️
windows 45.35% <41.02%> (+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 694e806 into oshi:master Aug 13, 2026
19 checks passed
@dbwiddis
dbwiddis deleted the fix-tail-cleanup-warnings branch August 13, 2026 16:41
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