Skip to content

Extract oshi-common module and resolve JPMS split-package violations - #3132

Merged
dbwiddis merged 3 commits into
oshi:masterfrom
dbwiddis:util-jna
Apr 9, 2026
Merged

dbwiddis merged 3 commits into
oshi:masterfrom
dbwiddis:util-jna

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Apr 9, 2026 •

Copy link
Copy Markdown
Member

Fixes LayerInstantiationException/ResolutionException errors in oshi-core-java11 and oshi-core-java25 caused by JPMS split-package violations — multiple named modules exporting the same package. Establishes oshi-common as a proper JNA-free JPMS module.

Root Causes

  • Core API interfaces, utility classes, and oshi.util.tuples were split across com.github.oshi and com.github.oshi.common jars
  • The parent pom.xml bnd config Export-Package: oshi.*;-noimport:=true physically inlined all oshi.* dependency classes from oshi-common into oshi-core-java25's jar, causing oshi.util.tuples etc. to appear in both named modules at runtime
  • oshi-core-java11 compiled oshi-common sources directly into itself but also declared oshi-common as a Maven dependency, putting the same packages into two named modules at runtime

Changes

oshi-common

  • Move remaining hardware/OS interfaces to oshi-common: CentralProcessor, GlobalMemory, HardwareAbstractionLayer, HWDiskStore, HWPartition, PhysicalMemory, OperatingSystem, OSProcess, OSThread
  • Move JNA-free util classes to oshi-common: Constants, FileUtil, FormatUtil, GlobalConfig, Memoizer, ParseUtil, PrivilegedUtil, Util, UserGroupInfo, ExecutingCommand, oshi.util.tuples
  • Move EdidUtil, FileSystemUtil, ProcUtil from oshi-core to oshi-common
  • Move PlatformEnum from oshi package to oshi.util package (permanent home — avoids split with oshi package owned by oshi-core)
  • Add SystemInfoHelper to main sources — static print helpers extracted from SystemInfoTest, available to oshi-core-java25 tests without test-jar complexity
  • forbiddenapis confirms zero native (JNA/FFM) violations across all 80 classes

oshi-core

  • Extract JNA-specific FileUtil buffer methods (readNativeLongFromBuffer, readSizeTFromBuffer, readPointerFromBuffer, freeMemory) into new oshi.jna.util.FileUtilJNA; update all callers
  • Replace Platform.isAIX/isLinux/isWindows/isSolaris JNA calls with PlatformEnum equivalents in UserGroupInfo, Who, ExecutingCommand
  • Move OperatingSystem default method bodies (isElevated, getSessions, getDesktopWindows) to AbstractOperatingSystem overrides
  • Add deprecated stub oshi.PlatformEnum delegating to oshi.util.PlatformEnum for backward compatibility
  • Remove stale package-info.java duplicates for oshi.hardware and oshi.software.os
  • Split FileUtilTest: JNA buffer read tests moved to FileUtilJNATest

oshi-core-java11

  • Remove oshi-common as a Maven dependency — its sources are compiled directly into this module, so having it as a separate jar on the module path caused the ResolutionException
  • Add --add-opens com.github.oshi/oshi.jna.util=org.junit.platform.commons to module-info.test for FileUtilJNATest

oshi-core-java25

  • Override bnd plugin to export only packages owned by this module, excluding all oshi-common-owned packages from the jar
  • Update module-info.java: remove exports of oshi-common-owned packages, add requires transitive com.github.oshi.common
  • Move FFM test classes from oshi.hardware/oshi.software.os packages to oshi.ffm as standalone tests
  • Simplify module-info.test to only open oshi.ffm and oshi.jna.util

Notes

  • oshi-core intentionally retains the original bnd config — it bundles all oshi.* packages for backward compatibility with non-modular consumers
  • oshi-core-java11 is a to-be-removed module but must be maintained until the next major version

Summary by CodeRabbit

  • New Features

    • Added a SystemInfoHelper to format and emit comprehensive system, hardware, and OS details.
  • Bug Fixes

    • OS default queries made conservative/stubbed to avoid unexpected platform calls (elevation, sessions, desktop windows).
  • Chores

    • Module and build packaging reorganized; manifest/module boundaries adjusted; widespread copyright year updates.
  • Tests

    • Many new and updated unit tests covering hardware, OS, and JNA-related utilities.

dbwiddis added 2 commits April 8, 2026 22:36
- Move remaining hardware/OS interfaces to oshi-common: CentralProcessor,
  GlobalMemory, HardwareAbstractionLayer, HWDiskStore, HWPartition,
  PhysicalMemory, OperatingSystem, OSProcess, OSThread
- Move JNA-free util classes to oshi-common: Constants, FileUtil, FormatUtil,
  GlobalConfig, Memoizer, ParseUtil, PrivilegedUtil, Util, UserGroupInfo,
  ExecutingCommand, and oshi.util.tuples package
- Extract JNA-specific FileUtil methods (readNativeLongFromBuffer,
  readSizeTFromBuffer, readPointerFromBuffer, freeMemory) into new
  oshi.jna.util.FileUtilJNA class; update all callers
- Replace Platform.isAIX/isLinux/isWindows/isSolaris JNA calls with
  PlatformEnum equivalents in UserGroupInfo, Who, ExecutingCommand
- Move OperatingSystem default method bodies (isElevated, getSessions,
  getDesktopWindows) to AbstractOperatingSystem overrides
- Split FileUtilTest: JNA buffer read tests moved to FileUtilJNATest
- forbiddenapis confirms 0 native violations in oshi-common (80 classes)
… issues

- Move EdidUtil, FileSystemUtil, ProcUtil, package-info.java from oshi-core to oshi-common
- Move PlatformEnum from oshi.PlatformEnum (oshi-common) to oshi.util.PlatformEnum (oshi-common)
- Add deprecated stub oshi.PlatformEnum in oshi-core for backward compatibility
- Remove stale package-info.java duplicates from oshi-core (oshi.hardware, oshi.software.os)
- Add oshi.jna.util/package-info.java to oshi-core
- Add SystemInfoHelper to oshi-common main sources for use by oshi-core-java25 tests
- Rewrite oshi-core-java25 FFM tests as standalone classes in oshi.ffm package
- Override bnd in oshi-core-java25 to exclude oshi-common-owned packages from jar
- Update oshi-core-java25 module-info: remove oshi-common package exports, add requires transitive com.github.oshi.common
- Fix oshi-core-java11 split-package: remove oshi-common dependency (sources compiled in directly)
- Add --add-opens oshi.jna.util to oshi-core-java11 module-info.test for FileUtilJNATest
@coderabbitai

coderabbitai Bot commented Apr 9, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3fa2e9a8-8728-4576-a69c-815866037a66

📥 Commits

Reviewing files that changed from the base of the PR and between d02c788 and bde5be5.

📒 Files selected for processing (29)
  • .github/workflows/linux.yaml
  • .gitignore
  • config/import-control-test.xml
  • oshi-benchmark/pom.xml
  • oshi-benchmark/scripts/run-benchmarks.sh
  • oshi-common/pom.xml
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/test/java/module-info.test
  • oshi-common/src/test/java/oshi/hardware/CentralProcessorTest.java
  • oshi-common/src/test/java/oshi/hardware/GpuTicksTest.java
  • oshi-common/src/test/java/oshi/hardware/HWPartitionTest.java
  • oshi-common/src/test/java/oshi/hardware/HardwareAbstractionLayerTest.java
  • oshi-common/src/test/java/oshi/hardware/NetworkIFTest.java
  • oshi-common/src/test/java/oshi/hardware/PhysicalMemoryTest.java
  • oshi-common/src/test/java/oshi/software/os/ApplicationInfoTest.java
  • oshi-common/src/test/java/oshi/software/os/InternetProtocolStatsTest.java
  • oshi-common/src/test/java/oshi/software/os/OSDesktopWindowTest.java
  • oshi-common/src/test/java/oshi/software/os/OSProcessTest.java
  • oshi-common/src/test/java/oshi/software/os/OSServiceTest.java
  • oshi-common/src/test/java/oshi/software/os/OSSessionTest.java
  • oshi-common/src/test/java/oshi/software/os/OSThreadTest.java
  • oshi-common/src/test/java/oshi/software/os/OperatingSystemTest.java
  • oshi-core-java11/pom.xml
  • oshi-core-java11/src/main/java/module-info.java
  • oshi-core-java25/pom.xml
  • oshi-core-java25/src/test/java/module-info.test
  • oshi-demo/pom.xml
  • oshi-dist/pom.xml
  • pom.xml
✅ Files skipped from review due to trivial changes (20)
  • .gitignore
  • oshi-dist/pom.xml
  • oshi-demo/pom.xml
  • oshi-common/src/test/java/oshi/hardware/GpuTicksTest.java
  • config/import-control-test.xml
  • oshi-common/src/test/java/module-info.test
  • oshi-common/src/test/java/oshi/software/os/OSDesktopWindowTest.java
  • oshi-common/src/test/java/oshi/hardware/PhysicalMemoryTest.java
  • oshi-common/src/test/java/oshi/hardware/HWPartitionTest.java
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/test/java/oshi/hardware/HardwareAbstractionLayerTest.java
  • oshi-common/src/test/java/oshi/software/os/InternetProtocolStatsTest.java
  • oshi-common/src/test/java/oshi/software/os/OSServiceTest.java
  • oshi-core-java11/src/main/java/module-info.java
  • oshi-common/src/test/java/oshi/software/os/OSSessionTest.java
  • oshi-core-java25/src/test/java/module-info.test
  • oshi-common/src/test/java/oshi/hardware/CentralProcessorTest.java
  • pom.xml
  • oshi-common/src/test/java/oshi/software/os/OSThreadTest.java
  • oshi-common/src/test/java/oshi/hardware/NetworkIFTest.java
🚧 Files skipped from review as they are similar to previous changes (6)
  • .github/workflows/linux.yaml
  • oshi-benchmark/scripts/run-benchmarks.sh
  • oshi-core-java11/pom.xml
  • oshi-common/src/test/java/oshi/software/os/OSProcessTest.java
  • oshi-common/src/test/java/oshi/software/os/ApplicationInfoTest.java
  • oshi-common/pom.xml
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 25, windows-latest
  • GitHub Check: Test JDK 25, ubuntu-latest
  • GitHub Check: Test JDK 25, macos-latest
  • GitHub Check: Test JDK 11, windows-latest
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 11, macos-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java11/src/main/java/module-info.java:10-17
Timestamp: 2026-03-29T20:01:06.452Z
Learning: In the oshi project, `oshi-core-java25/src/main/java/module-info.java` intentionally does NOT export `oshi.util.platform.unix.freebsd`, `oshi.util.platform.unix.openbsd`, or `oshi.util.platform.unix.solaris`, because the FFM (Foreign Function & Memory) implementation only supports Windows, macOS, and Linux. This differs from `oshi-core-java11/src/main/java/module-info.java` which exports all Unix platform packages. The asymmetry is by design.
Learnt from: dbwiddis
Repo: oshi/oshi PR: 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.
📚 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-core-java25/pom.xml
  • oshi-common/src/test/java/oshi/software/os/OperatingSystemTest.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-java25/pom.xml
  • oshi-common/src/test/java/oshi/software/os/OperatingSystemTest.java
🔇 Additional comments (11)
oshi-benchmark/pom.xml (2)

21-24: Good benchmark-build defaults for test and shading behavior.

Setting maven.test.skip and defaulting shade.phase to none is a clean way to keep routine module builds lightweight while leaving uber-jar creation as an explicit opt-in path.


64-64: Property-driven shade phase is a solid toggle.

Using ${shade.phase} here makes the shade execution controllable without editing the POM, and it aligns with the benchmark script’s explicit -Dshade.phase=package override.

oshi-common/src/test/java/oshi/software/os/OperatingSystemTest.java (5)

25-97: Stub baseline is appropriately minimal and deterministic.

This fixture isolates default-method behavior cleanly without introducing unrelated platform behavior.


98-177: MINIMAL and OVERRIDING fixtures are well-structured for behavior separation.

Good split between “default path” and “explicit override path,” which keeps assertions straightforward.


179-224: Default-method coverage is strong and targeted.

These tests validate non-null/empty defaults and getProcess(pid)-null filtering behavior effectively.


226-233: Override-path sanity checks look good.

The assertions confirm overridden methods supersede interface defaults as expected.


235-248: OSVersionInfo getter and formatting cases are well covered.

Both fully-populated and null optional-field cases are validated.

oshi-core-java25/pom.xml (4)

97-99: LGTM!

The simplification to copy only from oshi-core (not oshi-common) aligns with the PR objective to establish oshi-common as a proper JPMS dependency. The TODO comment helpfully documents the intent to eventually consolidate.


110-112: LGTM!

Removing oshi-common from the javadoc sourcepath is consistent with the module separation. Javadoc for oshi-common classes will be part of that module's documentation.


113-123: LGTM!

Using the JAVA executor is appropriate for running tests with proper JPMS module isolation. The --show-version option provides useful diagnostic output in CI logs.


75-84: Confirm the scope of bnd directives in Export-Package.

The -noimport:=true;-split-package:=merge-first directives are positioned at the end of the line and apply only to oshi.util.platform.* in bnd syntax. Each package pattern in the comma-separated list can have its own directives appended with a semicolon; directives only affect the immediately preceding pattern.

Verify that these directives should apply only to oshi.util.platform.* and not to the other exported packages. If oshi.util.platform.* is the only package with split-package violations in this module, the configuration is correct. If other packages also need these directives, apply them individually to each pattern (e.g., oshi.ffm.*;-noimport:=true;-split-package:=merge-first).


📝 Walkthrough

Walkthrough

Extracts common API into a new com.github.oshi.common module, relocates JNA-specific helpers into oshi.jna.util.FileUtilJNA, moves/renames PlatformEnum to oshi.util, updates module exports and build/test configs, adds many tests, removes package-info docs, and replaces native memory/buffer helpers across JNA code and drivers.

Changes

Cohort / File(s) Summary
Module / packaging & build
oshi-common/src/main/java/module-info.java, oshi-core-java11/src/main/java/module-info.java, oshi-core-java25/src/main/java/module-info.java, oshi-common/pom.xml, oshi-core-java11/pom.xml, oshi-core-java25/pom.xml, pom.xml, oshi-benchmark/pom.xml, oshi-demo/pom.xml, oshi-dist/pom.xml
Added com.github.oshi.common module, adjusted exports/requires across core modules, changed build/javadoc/test plugin configs, introduced OSGi/bnd and test-skip/shade-phase controls.
PlatformEnum relocation & platform checks
oshi-core/src/main/java/oshi/PlatformEnum.java, oshi-common/src/main/java/oshi/util/PlatformEnum.java, .../Who.java, .../AbstractCentralProcessor.java, .../ExecutingCommand.java, test imports*
Moved/added PlatformEnum under oshi.util, updated callers to PlatformEnum.getCurrentPlatform() replacing direct JNA Platform checks and updated imports in code/tests.
JNA utilities extraction
oshi-core/src/main/java/oshi/jna/util/FileUtilJNA.java, oshi-common/src/main/java/oshi/util/FileUtil.java, oshi-core/src/main/java/oshi/util/Util.java
Introduced FileUtilJNA with JNA buffer readers and freeMemory; removed JNA-specific read/free helpers from FileUtil and Util.freeMemory.
JNA/native memory call sites updated
oshi-core/src/main/java/oshi/jna/..., oshi-core/src/main/java/oshi/jna/platform/..., oshi-core/src/main/java/oshi/jna/platform/unix/SolarisLibc.java, oshi-core/src/main/java/oshi/jna/platform/windows/PowrProf.java, oshi-core/src/main/java/oshi/jna/ByRef.java, oshi-core/src/main/java/oshi/jna/Struct.java
Replaced uses of Util.freeMemory and oshi.util.FileUtil native-read calls with oshi.jna.util.FileUtilJNA equivalents; updated imports and close() implementations.
OperatingSystem defaults / AbstractOperatingSystem
oshi-common/src/main/java/oshi/software/os/OperatingSystem.java, oshi-core/src/main/java/oshi/software/common/AbstractOperatingSystem.java
Moved Unix helper implementations into AbstractOperatingSystem; OperatingSystem default methods stubbed (false/empty) while AbstractOperatingSystem delegates to UserGroupInfo, Who, and Xwininfo.
New helpers & package docs
oshi-common/src/main/java/oshi/util/SystemInfoHelper.java, oshi-core/src/main/java/oshi/jna/util/package-info.java
Added SystemInfoHelper (many print helpers) and package-level docs for oshi.jna.util.
Tests: add/remove/adjust
oshi-common/src/test/java/... (many new), oshi-core-java25/src/test/java/oshi/ffm/* (added), removed some old FFM tests, oshi-core/src/test/java/... (adjusted)
Large set of new unit tests under common/core, moved/added FFM tests for Java25, removed/updated several legacy test classes and imports.
File/buffer & JNA tests
oshi-core/src/test/java/oshi/jna/util/FileUtilJNATest.java, oshi-core/src/test/java/oshi/util/FileUtilTest.java
Added tests for FileUtilJNA native reads; simplified legacy FileUtil test to remove JNA-size-dependent assertions.
Misc cleanup & headers
multiple oshi-common and oshi-core source files, .gitignore, .github/workflows/linux.yaml, config/import-control-test.xml
Header year bumps, import/Javadoc cleanups, removed several package-info.java docs, CI: added pre-test mvn install -DskipTests, updated .gitignore and import-control test allow rules.
Removed package-info docs
oshi-common/src/main/java/oshi/package-info.java, oshi-core/src/main/java/oshi/hardware/package-info.java, oshi-core/src/main/java/oshi/software/os/package-info.java
Deleted package-level Javadoc files (documentation only).

Sequence Diagram(s)

sequenceDiagram
    participant App as Application/Test
    participant Core as oshi-core
    participant Common as oshi-common
    participant JNAUtil as oshi.jna.util.FileUtilJNA
    participant Native as JNA/Native

    App->>Common: request SystemInfo / OperatingSystem / Hardware
    Common->>Core: call platform/driver APIs (e.g., Who, Xwininfo, drivers)
    Core->>JNAUtil: readNativeLong/readSizeT/readPointer or freeMemory
    JNAUtil->>Native: inspect Native.LONG_SIZE/SIZE_T_SIZE, operate on Memory/Pointer
    Native-->>JNAUtil: parsed values / free confirmation
    JNAUtil-->>Core: return parsed values / freed resources
    Core-->>Common: return populated domain objects
    Common-->>App: formatted data / helper output
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Suggested reviewers

  • rohan-coder02

Poem

"I, a rabbit, nudge the code to grow,
Modules hop apart, then tidy in a row.
Platform enum moved to a warmer den,
JNA helpers snug, freed memory again.
Tests pop up like clover — small joys for the pen!" 🐇✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.59% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and specifically summarizes the main objective: extracting oshi-common as a module and resolving JPMS split-package violations, which aligns with the substantial refactoring evident in the file changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

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

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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
oshi-core/src/main/java/oshi/PlatformEnum.java (1)

119-149: Consider delegating to oshi.util.PlatformEnum to reduce code duplication.

The platform detection logic is duplicated between this deprecated stub and the canonical oshi.util.PlatformEnum. While keeping a separate copy ensures this stub works even if oshi-common isn't on the classpath, if that's not a concern, you could simplify by delegating:

private static final PlatformEnum CURRENT_PLATFORM = 
    PlatformEnum.values()[oshi.util.PlatformEnum.getCurrentPlatform().ordinal()];

This assumes enum ordinals are kept in sync, which is the stated contract. If backward compatibility with unusual classpath configurations is needed, the current approach is fine.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-core/src/main/java/oshi/PlatformEnum.java` around lines 119 - 149,
Replace the duplicated platform-detection static block in PlatformEnum by
delegating to the canonical oshi.util.PlatformEnum: obtain the current platform
from oshi.util.PlatformEnum (via its getCurrentPlatform() method), map its
ordinal to this enum's values() to set CURRENT_PLATFORM, and fall back to the
existing detection logic only if the oshi.util.PlatformEnum class or its method
is unavailable (catch ClassNotFoundException/Throwable). Update references to
CURRENT_PLATFORM accordingly in the PlatformEnum class.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@oshi-benchmark/dependency-reduced-pom.xml`:
- Around line 43-52: The reduced POM's <transformer> entries are missing their
required implementation attributes (and one is empty), which breaks JMH uberjar
generation; restore the explicit Shade transformer implementations used in the
canonical POM by adding the correct implementation values for the transformers
that set <mainClass> (org.openjdk.jmh.Main) and those that add resources
META-INF/BenchmarkList and META-INF/CompilerHints, and remove the empty
<transformer/> entry so each <transformer> block references a concrete
implementation class as in the original pom.

In `@oshi-common/src/main/java/oshi/util/SystemInfoHelper.java`:
- Around line 302-304: The inode percentage calculation can divide by zero when
fs.getTotalInodes() is 0; update the code in SystemInfoHelper where
FormatUtil.formatValue(fs.getFreeInodes(), "") and 100d * fs.getFreeInodes() /
fs.getTotalInodes() are used to compute a safe inode percentage (e.g., compute a
local double inodePercent = fs.getTotalInodes() == 0 ? 0d : 100d *
fs.getFreeInodes() / fs.getTotalInodes()) and pass
FormatUtil.formatValue(fs.getFreeInodes(), ""),
FormatUtil.formatValue(fs.getTotalInodes(), ""), and
FormatUtil.formatValue(inodePercent, "%") (or appropriate formatter) instead of
the raw division to avoid NaN/Infinity when getTotalInodes() returns 0.

In `@oshi-common/src/main/java/oshi/util/UserGroupInfo.java`:
- Around line 18-20: Update the mismatched Javadocs in class UserGroupInfo so
the comments accurately reflect the implementation: change the class-level and
relevant method Javadoc (including the Javadoc around lines 49-51) to state the
actual cache expiry used in the code (five minutes) instead of one minute, and
correct the description for getUser to indicate it returns a String username
(not a pair). Reference the UserGroupInfo class and the getUser method when
making these text-only documentation edits so the docs align with the current
memoization behavior and return types.

In `@oshi-core-java25/src/test/java/oshi/ffm/GlobalMemoryFFMTest.java`:
- Around line 10-14: The test in GlobalMemoryFFMTest asserts that
memory.getAvailable() is greaterThan(0) which violates the GlobalMemory contract
allowing 0; update the assertion that references memory.getAvailable() (in the
test method that checks available memory) to accept zero by using a
greaterThanOrEqualTo(0) matcher (or an equivalent assertion allowing 0) so the
test passes on systems reporting 0 available bytes.

---

Nitpick comments:
In `@oshi-core/src/main/java/oshi/PlatformEnum.java`:
- Around line 119-149: Replace the duplicated platform-detection static block in
PlatformEnum by delegating to the canonical oshi.util.PlatformEnum: obtain the
current platform from oshi.util.PlatformEnum (via its getCurrentPlatform()
method), map its ordinal to this enum's values() to set CURRENT_PLATFORM, and
fall back to the existing detection logic only if the oshi.util.PlatformEnum
class or its method is unavailable (catch ClassNotFoundException/Throwable).
Update references to CURRENT_PLATFORM accordingly in the PlatformEnum class.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9554cb9f-ccbd-4646-ac03-fc0fefe910c0

📥 Commits

Reviewing files that changed from the base of the PR and between 99bdc66 and 2196390.

📒 Files selected for processing (70)
  • oshi-benchmark/dependency-reduced-pom.xml
  • oshi-common/src/main/java/oshi/hardware/CentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/GlobalMemory.java
  • oshi-common/src/main/java/oshi/hardware/HWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/HWPartition.java
  • oshi-common/src/main/java/oshi/hardware/HardwareAbstractionLayer.java
  • oshi-common/src/main/java/oshi/hardware/PhysicalMemory.java
  • oshi-common/src/main/java/oshi/package-info.java
  • oshi-common/src/main/java/oshi/software/os/OSProcess.java
  • oshi-common/src/main/java/oshi/software/os/OSThread.java
  • oshi-common/src/main/java/oshi/software/os/OperatingSystem.java
  • oshi-common/src/main/java/oshi/util/Constants.java
  • oshi-common/src/main/java/oshi/util/EdidUtil.java
  • oshi-common/src/main/java/oshi/util/ExecutingCommand.java
  • oshi-common/src/main/java/oshi/util/FileSystemUtil.java
  • oshi-common/src/main/java/oshi/util/FileUtil.java
  • oshi-common/src/main/java/oshi/util/FormatUtil.java
  • oshi-common/src/main/java/oshi/util/GlobalConfig.java
  • oshi-common/src/main/java/oshi/util/Memoizer.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/main/java/oshi/util/PlatformEnum.java
  • oshi-common/src/main/java/oshi/util/PrivilegedUtil.java
  • oshi-common/src/main/java/oshi/util/ProcUtil.java
  • oshi-common/src/main/java/oshi/util/SystemInfoHelper.java
  • oshi-common/src/main/java/oshi/util/UserGroupInfo.java
  • oshi-common/src/main/java/oshi/util/Util.java
  • oshi-common/src/main/java/oshi/util/package-info.java
  • oshi-common/src/main/java/oshi/util/tuples/Pair.java
  • oshi-common/src/main/java/oshi/util/tuples/Quartet.java
  • oshi-common/src/main/java/oshi/util/tuples/Quintet.java
  • oshi-common/src/main/java/oshi/util/tuples/Triplet.java
  • oshi-common/src/main/java/oshi/util/tuples/package-info.java
  • oshi-core-java11/pom.xml
  • oshi-core-java11/src/main/java/module-info.java
  • oshi-core-java11/src/test/java/module-info.test
  • oshi-core-java25/pom.xml
  • oshi-core-java25/src/main/java/module-info.java
  • oshi-core-java25/src/main/java/oshi/ffm/SystemInfo.java
  • oshi-core-java25/src/test/java/module-info.test
  • oshi-core-java25/src/test/java/oshi/ffm/GlobalMemoryFFMTest.java
  • oshi-core-java25/src/test/java/oshi/ffm/OperatingSystemFFMTest.java
  • oshi-core-java25/src/test/java/oshi/ffm/SystemInfoTest.java
  • oshi-core-java25/src/test/java/oshi/ffm/VirtualMemoryFFMTest.java
  • oshi-core-java25/src/test/java/oshi/hardware/GlobalMemoryFFMTest.java
  • oshi-core-java25/src/test/java/oshi/hardware/VirtualMemoryFFMTest.java
  • oshi-core-java25/src/test/java/oshi/software/os/OperatingSystemFFMTest.java
  • oshi-core/src/main/java/oshi/PlatformEnum.java
  • oshi-core/src/main/java/oshi/driver/linux/proc/Auxv.java
  • oshi-core/src/main/java/oshi/driver/unix/Who.java
  • oshi-core/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/package-info.java
  • oshi-core/src/main/java/oshi/jna/ByRef.java
  • oshi-core/src/main/java/oshi/jna/Struct.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/CoreGraphics.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/IOKit.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/SystemB.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/CLibrary.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/SolarisLibc.java
  • oshi-core/src/main/java/oshi/jna/platform/windows/PowrProf.java
  • oshi-core/src/main/java/oshi/jna/util/FileUtilJNA.java
  • oshi-core/src/main/java/oshi/jna/util/package-info.java
  • oshi-core/src/main/java/oshi/software/common/AbstractOperatingSystem.java
  • oshi-core/src/main/java/oshi/software/os/package-info.java
  • oshi-core/src/test/java/oshi/hardware/CentralProcessorTest.java
  • oshi-core/src/test/java/oshi/jna/util/FileUtilJNATest.java
  • oshi-core/src/test/java/oshi/software/os/FileSystemTest.java
  • oshi-core/src/test/java/oshi/util/ExecutingCommandTest.java
  • oshi-core/src/test/java/oshi/util/FileUtilTest.java
  • oshi-core/src/test/java/oshi/util/FstatUtilTest.java
  • oshi-core/src/test/java/oshi/util/ProcstatUtilTest.java
💤 Files with no reviewable changes (12)
  • oshi-common/src/main/java/oshi/util/PrivilegedUtil.java
  • oshi-common/src/main/java/oshi/util/Util.java
  • oshi-core/src/test/java/oshi/util/ProcstatUtilTest.java
  • oshi-core/src/test/java/oshi/util/FstatUtilTest.java
  • oshi-core-java11/pom.xml
  • oshi-common/src/main/java/oshi/package-info.java
  • oshi-core/src/test/java/oshi/util/ExecutingCommandTest.java
  • oshi-core/src/main/java/oshi/software/os/package-info.java
  • oshi-core-java25/src/test/java/oshi/hardware/VirtualMemoryFFMTest.java
  • oshi-core-java25/src/test/java/oshi/hardware/GlobalMemoryFFMTest.java
  • oshi-core/src/main/java/oshi/hardware/package-info.java
  • oshi-core-java25/src/test/java/oshi/software/os/OperatingSystemFFMTest.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, macos-latest
  • GitHub Check: Test JDK 11, ubuntu-latest
  • GitHub Check: Test JDK 25, windows-latest
  • GitHub Check: Test JDK 25, ubuntu-latest
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 11, windows-latest
  • GitHub Check: Test JDK 21, ubuntu-latest
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 11, macos-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (11)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java11/src/main/java/module-info.java:10-17
Timestamp: 2026-03-29T20:01:06.452Z
Learning: In the oshi project, `oshi-core-java25/src/main/java/module-info.java` intentionally does NOT export `oshi.util.platform.unix.freebsd`, `oshi.util.platform.unix.openbsd`, or `oshi.util.platform.unix.solaris`, because the FFM (Foreign Function & Memory) implementation only supports Windows, macOS, and Linux. This differs from `oshi-core-java11/src/main/java/module-info.java` which exports all Unix platform packages. The asymmetry is by design.
Learnt from: dbwiddis
Repo: oshi/oshi PR: 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.
📚 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/HWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/GlobalMemory.java
  • oshi-common/src/main/java/oshi/hardware/PhysicalMemory.java
  • oshi-common/src/main/java/oshi/util/Constants.java
  • oshi-common/src/main/java/oshi/util/FormatUtil.java
  • oshi-common/src/main/java/oshi/hardware/CentralProcessor.java
  • oshi-common/src/main/java/oshi/util/FileSystemUtil.java
  • oshi-common/src/main/java/oshi/util/EdidUtil.java
  • oshi-common/src/main/java/oshi/util/Memoizer.java
  • oshi-core-java11/src/test/java/module-info.test
  • oshi-common/src/main/java/oshi/util/PlatformEnum.java
  • oshi-common/src/main/java/oshi/software/os/OSThread.java
  • oshi-common/src/main/java/oshi/util/UserGroupInfo.java
  • oshi-core-java11/src/main/java/module-info.java
  • oshi-core-java25/src/main/java/oshi/ffm/SystemInfo.java
  • oshi-common/src/main/java/oshi/util/ExecutingCommand.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/CoreGraphics.java
  • oshi-core/src/main/java/oshi/driver/linux/proc/Auxv.java
  • oshi-common/src/main/java/oshi/software/os/OperatingSystem.java
  • oshi-core/src/main/java/oshi/jna/util/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/CLibrary.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/IOKit.java
  • oshi-core/src/test/java/oshi/software/os/FileSystemTest.java
  • oshi-core/src/main/java/oshi/jna/platform/windows/PowrProf.java
  • oshi-core/src/test/java/oshi/hardware/CentralProcessorTest.java
  • oshi-core/src/main/java/oshi/driver/unix/Who.java
  • oshi-core-java25/src/main/java/module-info.java
  • oshi-core-java25/pom.xml
  • oshi-core/src/main/java/oshi/jna/ByRef.java
  • oshi-core/src/main/java/oshi/software/common/AbstractOperatingSystem.java
  • oshi-core/src/main/java/oshi/jna/Struct.java
  • oshi-common/src/main/java/oshi/util/ProcUtil.java
  • oshi-core-java25/src/test/java/oshi/ffm/OperatingSystemFFMTest.java
  • oshi-core/src/main/java/oshi/PlatformEnum.java
  • oshi-core/src/test/java/oshi/util/FileUtilTest.java
  • oshi-core-java25/src/test/java/module-info.test
  • oshi-core/src/main/java/oshi/jna/platform/unix/SolarisLibc.java
  • oshi-common/src/main/java/oshi/util/SystemInfoHelper.java
  • oshi-core-java25/src/test/java/oshi/ffm/SystemInfoTest.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-common/src/main/java/oshi/hardware/HWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/GlobalMemory.java
  • oshi-common/src/main/java/oshi/hardware/PhysicalMemory.java
  • oshi-common/src/main/java/oshi/util/Constants.java
  • oshi-common/src/main/java/oshi/util/FormatUtil.java
  • oshi-common/src/main/java/oshi/hardware/CentralProcessor.java
  • oshi-common/src/main/java/oshi/util/FileSystemUtil.java
  • oshi-common/src/main/java/oshi/util/EdidUtil.java
  • oshi-common/src/main/java/oshi/util/Memoizer.java
  • oshi-core-java11/src/test/java/module-info.test
  • oshi-common/src/main/java/oshi/util/PlatformEnum.java
  • oshi-common/src/main/java/oshi/util/UserGroupInfo.java
  • oshi-core-java25/src/main/java/oshi/ffm/SystemInfo.java
  • oshi-common/src/main/java/oshi/util/ExecutingCommand.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/CoreGraphics.java
  • oshi-common/src/main/java/oshi/software/os/OperatingSystem.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/SystemB.java
  • oshi-core/src/main/java/oshi/jna/util/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/CLibrary.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/IOKit.java
  • oshi-core/src/test/java/oshi/software/os/FileSystemTest.java
  • oshi-core/src/main/java/oshi/jna/platform/windows/PowrProf.java
  • oshi-core/src/main/java/oshi/driver/unix/Who.java
  • oshi-core-java25/pom.xml
  • oshi-core/src/main/java/oshi/jna/ByRef.java
  • oshi-core/src/main/java/oshi/software/common/AbstractOperatingSystem.java
  • oshi-core/src/main/java/oshi/jna/Struct.java
  • oshi-common/src/main/java/oshi/util/ProcUtil.java
  • oshi-benchmark/dependency-reduced-pom.xml
  • oshi-core-java25/src/test/java/oshi/ffm/GlobalMemoryFFMTest.java
  • oshi-core-java25/src/test/java/oshi/ffm/OperatingSystemFFMTest.java
  • oshi-core/src/main/java/oshi/PlatformEnum.java
  • oshi-core/src/test/java/oshi/util/FileUtilTest.java
  • oshi-core-java25/src/test/java/module-info.test
  • oshi-core/src/main/java/oshi/jna/platform/unix/SolarisLibc.java
  • oshi-core-java25/src/test/java/oshi/ffm/SystemInfoTest.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-common/src/main/java/oshi/util/PlatformEnum.java
  • oshi-core-java25/src/main/java/oshi/ffm/SystemInfo.java
  • oshi-common/src/main/java/oshi/util/ExecutingCommand.java
  • oshi-core/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/CLibrary.java
  • oshi-core/src/test/java/oshi/hardware/CentralProcessorTest.java
  • oshi-core/src/main/java/oshi/driver/unix/Who.java
  • oshi-core/src/main/java/oshi/PlatformEnum.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/SolarisLibc.java
  • oshi-core-java25/src/test/java/oshi/ffm/SystemInfoTest.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-java11/src/main/java/module-info.java
  • oshi-core-java25/src/main/java/module-info.java
📚 Learning: 2026-04-06T21:48:11.921Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3122
File: oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.java:85-111
Timestamp: 2026-04-06T21:48:11.921Z
Learning: In `oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.java` (and `MacUsbDeviceFFM.java`), the `id = 0L` sentinel is intentional when `device.getParentEntry(IOSERVICE)` returns null. It acts as a catch-all controller group for devices whose controller cannot be identified (an edge case that "should never happen" given the IORegistry format). Do not flag this as a bug or suggest skipping such devices; the design intentionally avoids both silently dropping orphaned devices and placing them at the top level without a controller context.

Applied to files:

  • oshi-core/src/main/java/oshi/jna/platform/mac/CoreGraphics.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/IOKit.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/hardware/common/AbstractCentralProcessor.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/src/main/java/oshi/jna/platform/mac/SystemB.java
  • oshi-core/src/main/java/oshi/jna/platform/windows/PowrProf.java
  • oshi-core/src/main/java/oshi/jna/Struct.java
  • oshi-core/src/main/java/oshi/jna/util/FileUtilJNA.java
📚 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-core/src/main/java/oshi/jna/util/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/CLibrary.java
  • oshi-core/src/main/java/oshi/jna/platform/mac/IOKit.java
  • oshi-core/src/main/java/oshi/jna/ByRef.java
  • oshi-core/src/main/java/oshi/jna/Struct.java
  • oshi-core/src/main/java/oshi/jna/util/FileUtilJNA.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/SolarisLibc.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/jna/platform/windows/PowrProf.java
📚 Learning: 2026-04-03T18:43:51.290Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3112
File: oshi-core/src/main/java/oshi/PlatformEnum.java:99-100
Timestamp: 2026-04-03T18:43:51.290Z
Learning: In oshi/oshi PlatformEnum.java, the DragonFly BSD detection uses `osName.equalsIgnoreCase("dragonflybsd")` intentionally, mirroring the exact same check in JNA's `Platform.java` source. Java's `os.name` property on DragonFly BSD is "dragonflybsd" (no space), so `startsWith("DragonFly")` is NOT the correct pattern here. Do not suggest changing it to `startsWith`.

Applied to files:

  • oshi-core/src/main/java/oshi/PlatformEnum.java
🔇 Additional comments (53)
oshi-common/src/main/java/oshi/util/ProcUtil.java (1)

2-2: Header year-range update is correct and low-risk.

This change is metadata-only and does not affect behavior.

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

2-2: Copyright header update looks good.

Metadata-only change; no functional impact detected.

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

2-2: Copyright header update looks good.

Line 2 is a metadata-only year bump and is correct for this release cycle.

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

2-2: Copyright header update looks good.

No functional or API impact here; this is a clean metadata refresh.

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

2-2: Copyright header update looks good.

No functional impact; this is a clean metadata/year refresh.

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

2-2: Copyright header update looks good.

Metadata-only change; no functional impact detected.

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

2-2: Non-functional header/import update looks good.

These changes are metadata/import-only and do not alter behavior or public API semantics.

Also applies to: 9-10

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

2-2: LGTM! Routine copyright year update.

The copyright year range has been appropriately updated to reflect the current year.

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

2-2: Header update looks good.

Line 2 is a non-functional copyright year refresh only; no concerns.

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

2-2: Header update looks good.

Line 2 is a non-functional copyright year refresh only; no concerns.

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

2-2: Header update looks good.

Line 2 is a non-functional copyright year refresh only; no concerns.

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

17-17: LGTM!

The import reordering maintains alphabetical order and has no functional impact.

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

2-2: LGTM!

Copyright year updated appropriately to reflect 2026.

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

2-2: Header update looks good.

This is a clean, non-functional copyright refresh with no API or runtime impact.

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

2-2: No concerns with this change.

The update is documentation/header-only and does not affect functionality.

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

5-5: Package relocation is consistent with the refactor goal.

Moving PlatformEnum under oshi.util here is aligned with the JPMS split-package cleanup.

oshi-core/src/test/java/oshi/hardware/CentralProcessorTest.java (1)

27-27: Test import update is correct.

This keeps the test aligned with the new PlatformEnum package location.

oshi-core-java25/src/main/java/oshi/ffm/SystemInfo.java (1)

19-19: Looks good.

The import migration to oshi.util.PlatformEnum is consistent with the module restructuring.

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

30-30: Import migration is clean.

No functional concerns; this aligns with the centralized PlatformEnum move.

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

35-39: Platform detection swap is solid.

Replacing JNA Platform checks with PlatformEnum.getCurrentPlatform() here preserves behavior while keeping oshi-common JNA-free.

Also applies to: 118-119

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

73-74: AIX guard migration is correct.

Switching these checks to PlatformEnum keeps behavior intact and removes direct JNA platform dependency in this class.

Also applies to: 103-104

oshi-core/src/main/java/oshi/driver/unix/Who.java (1)

25-25: LGTM! Platform detection migrated from JNA to oshi.util.PlatformEnum.

The replacement of com.sun.jna.Platform.isLinux() with PlatformEnum.getCurrentPlatform() == PlatformEnum.LINUX correctly removes the JNA dependency while maintaining equivalent behavior. The PlatformEnum.getCurrentPlatform() returns a cached value computed from system properties during class loading, matching the same detection logic JNA used.

Also applies to: 60-60

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

14-15: LGTM! Import updated to new PlatformEnum location.

The import migration from oshi.PlatformEnum to oshi.util.PlatformEnum aligns with the PR's package restructuring. Test logic remains unchanged.

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

312-314: LGTM! Interface defaults stubbed appropriately for JNA-free oshi-common.

The default implementations now return false/empty collections, which is the correct approach for a JNA-free common module. The actual Unix-specific implementations are properly delegated to AbstractOperatingSystem (which overrides with UserGroupInfo.isElevated(), Who.queryWho(), and Xwininfo.queryXWindows()), and platform-specific classes like WindowsOperatingSystem and LinuxOperatingSystem further override as needed.

Also applies to: 346-348, 365-367

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

48-50: LGTM! Javadoc updated to remove implementation-specific class references.

The documentation changes appropriately decouple the API documentation from internal implementation details while still providing useful guidance to users.

Also applies to: 185-185

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

185-200: LGTM! Concrete implementations properly moved from interface defaults to abstract class.

The three methods (isElevated(), getSessions(), getDesktopWindows()) are correctly implemented by delegating to their respective helper classes. The comment on lines 197-198 clearly documents that the X11 implementation is the Unix default and is overridden on Windows and macOS. This completes the clean separation where OperatingSystem interface provides JNA-free stubs and AbstractOperatingSystem provides the actual Unix-like implementations.

oshi-core/src/main/java/oshi/PlatformEnum.java (1)

1-211: LGTM! Well-structured backward compatibility stub.

The deprecated oshi.PlatformEnum provides a clean migration path for existing users. All elements are properly marked @Deprecated with Javadoc pointing to oshi.util.PlatformEnum. The platform detection logic correctly mirrors the canonical implementation, including the intentional equalsIgnoreCase("dragonflybsd") check that matches JNA's behavior.

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

1-378: Well-structured test utility class.

The SystemInfoHelper class provides a clean, reusable set of methods for printing OSHI system information across test modules. The design with List<String> accumulation allows flexible output handling in tests.

oshi-core-java25/src/test/java/oshi/ffm/VirtualMemoryFFMTest.java (2)

23-37: LGTM! Test assertions are comprehensive and well-structured.

The test properly validates VirtualMemory invariants: non-negative values, swapUsed <= swapTotal, and virtualMax >= swapTotal. The @EnabledForJreRange(min = JRE.JAVA_25) annotation correctly restricts this FFM test to Java 25+.


25-25: > Likely an incorrect or invalid review comment.

oshi-core-java25/src/test/java/oshi/ffm/OperatingSystemFFMTest.java (1)

26-44: Platform gating and FFM OS assertions look good.

@EnabledForJreRange(min = JRE.JAVA_25) plus macOS-specific instanceof MacOperatingSystemFFM coverage is well-scoped and consistent with this module’s test intent.

oshi-core-java25/src/test/java/oshi/ffm/SystemInfoTest.java (1)

12-33: Refactor is clean and behavior-preserving.

The SystemInfoHelper static import migration and direct null assertions on Line 72 and Line 77 make the tests clearer while keeping intent unchanged.

Also applies to: 51-51, 72-77

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

21-21: requires transitive com.github.oshi.common is the correct JPMS boundary update.

This cleanly shifts shared API ownership to the common module and supports the split-package fix.

oshi-core-java25/pom.xml (3)

75-84: BND plugin override looks well-scoped for the java25 artifact.

The export/import instructions match the modular split and keep packaging intent explicit.


97-99: Migration TODO is clear and appropriately localized.


110-110: Javadoc sourcepath cleanup aligns with the oshi-common extraction.

Good removal of cross-module sourcepath duplication.

Also applies to: 122-122

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

29-33: JNA decoupling in oshi.util.FileUtil looks clean.

oshi-common stays dependency-light and aligned with the module split.

oshi-core/src/main/java/oshi/jna/util/FileUtilJNA.java (1)

33-70: Good extraction of JNA-specific buffer parsing and native-memory handling.

This keeps native concerns in core while preserving reuse of existing bounds-checked reads.

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

5-8: Package-level documentation is clear and aligned with the extraction.

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

25-25: opens oshi.jna.util for JUnit is the right test-access update.

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

51-52: Test module --add-opens for oshi.jna.util is correctly added.

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

6-6: Keeping oshi.jna.util in the java25 test opens is correct for the new test target.

oshi-core/src/test/java/oshi/util/FileUtilTest.java (1)

193-230: Good simplification of binary-buffer test coverage.

The fixed 18-byte payload and updated assertions keep this test focused on JNA-free FileUtil behavior, with native-width coverage cleanly moved to the dedicated JNA test.

oshi-core/src/test/java/oshi/jna/util/FileUtilJNATest.java (1)

22-46: Nice targeted JNA test coverage.

This validates both native-width decoding paths and end-of-buffer fallback behavior in one focused test.

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

65-68: CGRect.close() update looks correct.

Routing cleanup through FileUtilJNA.freeMemory(...) is consistent with the module split and preserves intent.

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

49-51: Consistent native-width parsing switch in queryAuxv().

Updating both key and value reads to FileUtilJNA keeps auxv decoding behavior aligned after the utility split.

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

63-66: Addrinfo.close() migration is clean.

The new FileUtilJNA.freeMemory(...) call matches the refactor direction and keeps ownership semantics unchanged.

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

35-118: Uniform close() migration across wrappers looks solid.

Nice consistent replacement to FileUtilJNA.freeMemory(...) across all ByRef closeable types.

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

147-150: SocketFdInfo.close() update is good.

Cleanup is now correctly routed through the JNA-specific utility.

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

75-78: Both SMC close-path updates look correct.

Good consistent move to FileUtilJNA.freeMemory(...) for JNA-owned structure cleanup.

Also applies to: 91-94

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

12-12: Good migration to JNA-local memory cleanup utility.

The import swap and all close() updates consistently route native pointer cleanup through FileUtilJNA.freeMemory(getPointer()), matching the module split intent without changing structure behavior.

Also applies to: 50-53, 85-88, 110-113, 124-127, 137-140, 149-152

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

15-15: Type-appropriate buffer decoding updates look correct.

Switching these fields to FileUtilJNA (Pointer, size_t, and NativeLong) is consistent and preserves parse flow while making the reads explicitly JNA/word-size aware.

Also applies to: 138-142, 156-157, 206-207, 286-300, 312-313

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

26-26: Consistent closeable-wrapper cleanup migration across all platforms.

All wrappers now use the same JNA-specific free path, which cleanly supports the extracted oshi-common boundary and keeps resource handling uniform.

Also applies to: 38-40, 49-51, 56-58, 63-65, 70-72, 77-79, 84-86, 91-93, 98-100, 109-111, 116-118, 123-125, 130-132, 137-139, 144-146, 151-153, 158-160, 165-167

Comment on lines +43 to +52
<transformer>
<mainClass>org.openjdk.jmh.Main</mainClass>
</transformer>
<transformer />
<transformer>
<resource>META-INF/BenchmarkList</resource>
</transformer>
<transformer>
<resource>META-INF/CompilerHints</resource>
</transformer>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

python - <<'PY'
import xml.etree.ElementTree as ET

NS = {"m": "http://maven.apache.org/POM/4.0.0"}

def show(path):
    root = ET.parse(path).getroot()
    print(f"\n== {path} ==")
    for plugin in root.findall(".//m:plugin", NS):
        aid = plugin.find("m:artifactId", NS)
        if aid is not None and aid.text == "maven-shade-plugin":
            transformers = plugin.findall(".//m:transformer", NS)
            for i, t in enumerate(transformers, 1):
                children = [c.tag.split('}', 1)[-1] for c in list(t)]
                print(f"{i}. implementation={t.attrib.get('implementation')!r}, children={children}")

show("oshi-benchmark/pom.xml")
show("oshi-benchmark/dependency-reduced-pom.xml")
PY

Repository: oshi/oshi

Length of output: 727


🏁 Script executed:

# Check if the file is tracked in Git and show its status
git ls-files --stage "oshi-benchmark/dependency-reduced-pom.xml"

Repository: oshi/oshi

Length of output: 144


🏁 Script executed:

# Get more context on this file - check when it was added and if it's auto-generated
git log --oneline --follow "oshi-benchmark/dependency-reduced-pom.xml" | head -20

Repository: oshi/oshi

Length of output: 137


🏁 Script executed:

# Check the pom.xml for shade plugin configuration to understand if reduced POM is expected
cat oshi-benchmark/pom.xml | grep -A 30 "maven-shade-plugin"

Repository: oshi/oshi

Length of output: 2021


🏁 Script executed:

# Check if there's a .gitignore entry for this file
cat oshi-benchmark/.gitignore 2>/dev/null || echo "No .gitignore in oshi-benchmark"

Repository: oshi/oshi

Length of output: 84


🏁 Script executed:

# Check if the reduced POM is referenced anywhere in build scripts or documentation
rg "dependency-reduced-pom" --type txt --type md --type xml

Repository: oshi/oshi

Length of output: 35


🏁 Script executed:

# Check the full extent of transformer element diff between the two files (visual confirmation)
head -60 oshi-benchmark/dependency-reduced-pom.xml | tail -20

Repository: oshi/oshi

Length of output: 1181


Restore explicit Shade transformer implementations in committed reduced POM.

Lines 43–52 lack implementation attributes on all <transformer> entries (and include one empty transformer). This commits a broken artifact that will fail JMH uberjar generation if consumed. The canonical pom.xml defines all four transformers with concrete implementations; the reduced POM strips them all.

Proposed fix
-                                <transformer>
+                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                     <mainClass>org.openjdk.jmh.Main</mainClass>
                                 </transformer>
-                                <transformer />
-                                <transformer>
+                                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
+                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                     <resource>META-INF/BenchmarkList</resource>
                                 </transformer>
-                                <transformer>
+                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                     <resource>META-INF/CompilerHints</resource>
                                 </transformer>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<transformer>
<mainClass>org.openjdk.jmh.Main</mainClass>
</transformer>
<transformer />
<transformer>
<resource>META-INF/BenchmarkList</resource>
</transformer>
<transformer>
<resource>META-INF/CompilerHints</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.openjdk.jmh.Main</mainClass>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/BenchmarkList</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/CompilerHints</resource>
</transformer>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-benchmark/dependency-reduced-pom.xml` around lines 43 - 52, The reduced
POM's <transformer> entries are missing their required implementation attributes
(and one is empty), which breaks JMH uberjar generation; restore the explicit
Shade transformer implementations used in the canonical POM by adding the
correct implementation values for the transformers that set <mainClass>
(org.openjdk.jmh.Main) and those that add resources META-INF/BenchmarkList and
META-INF/CompilerHints, and remove the empty <transformer/> entry so each
<transformer> block references a concrete implementation class as in the
original pom.

Comment on lines +302 to +304
FormatUtil.formatBytes(usable), FormatUtil.formatBytes(fs.getTotalSpace()), 100d * usable / total,
FormatUtil.formatValue(fs.getFreeInodes(), ""), FormatUtil.formatValue(fs.getTotalInodes(), ""),
100d * fs.getFreeInodes() / fs.getTotalInodes(), fs.getVolume(), fs.getLogicalVolume(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Potential division by zero when getTotalInodes() returns 0.

On certain file systems (e.g., FAT32, some network mounts), getTotalInodes() can return 0, causing the percentage calculation to produce NaN or Infinity in the output string.

Proposed fix
-                    100d * usable / total,
-                    FormatUtil.formatValue(fs.getFreeInodes(), ""), FormatUtil.formatValue(fs.getTotalInodes(), ""),
-                    100d * fs.getFreeInodes() / fs.getTotalInodes(), fs.getVolume(), fs.getLogicalVolume(),
+                    100d * usable / total,
+                    FormatUtil.formatValue(fs.getFreeInodes(), ""), FormatUtil.formatValue(fs.getTotalInodes(), ""),
+                    fs.getTotalInodes() > 0 ? 100d * fs.getFreeInodes() / fs.getTotalInodes() : 0d,
+                    fs.getVolume(), fs.getLogicalVolume(),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
FormatUtil.formatBytes(usable), FormatUtil.formatBytes(fs.getTotalSpace()), 100d * usable / total,
FormatUtil.formatValue(fs.getFreeInodes(), ""), FormatUtil.formatValue(fs.getTotalInodes(), ""),
100d * fs.getFreeInodes() / fs.getTotalInodes(), fs.getVolume(), fs.getLogicalVolume(),
FormatUtil.formatBytes(usable), FormatUtil.formatBytes(fs.getTotalSpace()), 100d * usable / total,
FormatUtil.formatValue(fs.getFreeInodes(), ""), FormatUtil.formatValue(fs.getTotalInodes(), ""),
fs.getTotalInodes() > 0 ? 100d * fs.getFreeInodes() / fs.getTotalInodes() : 0d, fs.getVolume(), fs.getLogicalVolume(),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-common/src/main/java/oshi/util/SystemInfoHelper.java` around lines 302 -
304, The inode percentage calculation can divide by zero when
fs.getTotalInodes() is 0; update the code in SystemInfoHelper where
FormatUtil.formatValue(fs.getFreeInodes(), "") and 100d * fs.getFreeInodes() /
fs.getTotalInodes() are used to compute a safe inode percentage (e.g., compute a
local double inodePercent = fs.getTotalInodes() == 0 ? 0d : 100d *
fs.getFreeInodes() / fs.getTotalInodes()) and pass
FormatUtil.formatValue(fs.getFreeInodes(), ""),
FormatUtil.formatValue(fs.getTotalInodes(), ""), and
FormatUtil.formatValue(inodePercent, "%") (or appropriate formatter) instead of
the raw division to avoid NaN/Infinity when getTotalInodes() returns 0.

Comment on lines +18 to 20
* Utility class to temporarily cache the userID and group maps in *nix, for parsing process ownership. Cache expires
* after one minute.
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix mismatched Javadocs in changed lines.

The class comment says cache expiry is one minute, but code memoizes for five minutes. Also, getUser returns a String, not a pair.

📝 Suggested doc fix
- * Utility class to temporarily cache the userID and group maps in *nix, for parsing process ownership. Cache expires
- * after one minute.
+ * Utility class to temporarily cache the userID and group maps in *nix, for parsing process ownership. Cache expires
+ * after five minutes.
@@
-     * `@return` a pair containing that user id as the first element and the user name as the second
+     * `@return` the user name corresponding to the user ID, or {`@link` Constants#UNKNOWN} if unavailable

Also applies to: 49-51

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-common/src/main/java/oshi/util/UserGroupInfo.java` around lines 18 - 20,
Update the mismatched Javadocs in class UserGroupInfo so the comments accurately
reflect the implementation: change the class-level and relevant method Javadoc
(including the Javadoc around lines 49-51) to state the actual cache expiry used
in the code (five minutes) instead of one minute, and correct the description
for getUser to indicate it returns a String username (not a pair). Reference the
UserGroupInfo class and the getUser method when making these text-only
documentation edits so the docs align with the current memoization behavior and
return types.

Comment on lines +10 to +14
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.Matchers.notNullValue;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

gm_file="$(fd '^GlobalMemory\.java$' | head -n1)"
echo "GlobalMemory definition: ${gm_file}"
sed -n '1,140p' "${gm_file}" | rg -n "getAvailable|Available number of bytes|getTotal"

echo
echo "Current assertion in GlobalMemoryFFMTest:"
rg -n --type=java -C2 'getAvailable\(\)|greaterThan\(0L\)|lessThan\(memory\.getTotal\(\)\)' oshi-core-java25/src/test/java/oshi/ffm/GlobalMemoryFFMTest.java

Repository: oshi/oshi

Length of output: 942


Relax the available memory assertion to allow zero bytes.

The assertion on line 44 requires getAvailable() > 0, but according to the GlobalMemory API contract, 0 is a valid value for available bytes. This can cause edge-case test failures on systems with no available memory.

Fix
 import static org.hamcrest.Matchers.greaterThan;
 import static org.hamcrest.Matchers.greaterThanOrEqualTo;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.lessThan;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
 import static org.hamcrest.Matchers.notNullValue;

And change the assertion to:

         assertThat("Available memory should be between 0 and total memory", memory.getAvailable(),
-                is(both(greaterThan(0L)).and(lessThan(memory.getTotal()))));
+                is(both(greaterThanOrEqualTo(0L)).and(lessThanOrEqualTo(memory.getTotal()))));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.hamcrest.Matchers.notNullValue;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-core-java25/src/test/java/oshi/ffm/GlobalMemoryFFMTest.java` around
lines 10 - 14, The test in GlobalMemoryFFMTest asserts that
memory.getAvailable() is greaterThan(0) which violates the GlobalMemory contract
allowing 0; update the assertion that references memory.getAvailable() (in the
test method that checks available memory) to accept zero by using a
greaterThanOrEqualTo(0) matcher (or an equivalent assertion allowing 0) so the
test passes on systems reporting 0 available bytes.

@codecov

codecov Bot commented Apr 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 8.70968% with 283 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.48%. Comparing base (99bdc66) to head (bde5be5).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...mmon/src/main/java/oshi/util/SystemInfoHelper.java 0.00% 250 Missing ⚠️
oshi-core/src/main/java/oshi/PlatformEnum.java 46.15% 22 Missing and 6 partials ⚠️
...mmon/src/main/java/oshi/util/ExecutingCommand.java 0.00% 0 Missing and 3 partials ⚠️
...-common/src/main/java/oshi/util/UserGroupInfo.java 0.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3132      +/-   ##
============================================
- Coverage     66.56%   61.48%   -5.09%     
- Complexity        0       12      +12     
============================================
  Files            37       39       +2     
  Lines          2034     2329     +295     
  Branches        340      407      +67     
============================================
+ Hits           1354     1432      +78     
- Misses          559      776     +217     
  Partials        121      121              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (3)
oshi-common/src/test/java/oshi/software/os/InternetProtocolStatsTest.java (2)

63-68: Add a negative-path enum parse test.

valueOf happy-path checks are useful; adding one invalid input assertion improves behavior coverage.

Suggested additional assertion
     void testTcpStateEnum() {
         assertThat(TcpState.valueOf("ESTABLISHED"), is(TcpState.ESTABLISHED));
         assertThat(TcpState.valueOf("CLOSED"), is(TcpState.CLOSED));
         assertThat(TcpState.valueOf("UNKNOWN"), is(TcpState.UNKNOWN));
+        org.junit.jupiter.api.Assertions.assertThrows(IllegalArgumentException.class,
+                () -> TcpState.valueOf("NOT_A_STATE"));
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-common/src/test/java/oshi/software/os/InternetProtocolStatsTest.java`
around lines 63 - 68, Add a negative-path assertion in the
InternetProtocolStatsTest.testTcpStateEnum to verify invalid enum parsing
throws: call TcpState.valueOf with a bogus name (e.g., "INVALID" or "FOOBAR")
and assert that it throws IllegalArgumentException (use your test framework's
assertThrows or equivalent) so the test covers the failure case of
TcpState.valueOf.

47-60: Strengthen IPConnection address assertions to validate contents, not just length.

Current checks would still pass if wrong bytes are returned with the same array size.

Suggested test hardening
-        assertThat(conn.getLocalAddress().length, is(4));
-        assertThat(conn.getForeignAddress().length, is(4));
+        org.junit.jupiter.api.Assertions.assertArrayEquals(new byte[] { 127, 0, 0, 1 }, conn.getLocalAddress());
+        org.junit.jupiter.api.Assertions.assertArrayEquals(new byte[] { 10, 0, 0, 1 }, conn.getForeignAddress());
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-common/src/test/java/oshi/software/os/InternetProtocolStatsTest.java`
around lines 47 - 60, The test testIPConnectionGetters currently only checks
address lengths; update it to assert the actual byte contents returned by
IPConnection.getLocalAddress() and IPConnection.getForeignAddress() match the
expected arrays (local and foreign) rather than just their lengths. Locate the
IPConnection instantiation and replace or augment the length assertions with
content checks (e.g., use Arrays.equals or a matcher such as equalTo on the byte
arrays) so the test verifies exact address bytes for local and foreign
addresses.
oshi-core-java25/pom.xml (1)

113-126: Minor: Double slash in module-path.

The configuration looks correct, but there's a double slash // in the path at line 121. While file systems normalize this and it won't cause issues, it appears to be a typo.

🔧 Suggested fix
-                            <additionalOption>${project.basedir}/../oshi-common/target//junit-platform/patched-test-runtime/</additionalOption>
+                            <additionalOption>${project.basedir}/../oshi-common/target/junit-platform/patched-test-runtime/</additionalOption>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-core-java25/pom.xml` around lines 113 - 126, The module-path value in
the junit-platform-maven-plugin configuration contains a typo with a double
slash in the additionalOption string for "--module-path" (the value under
<additionalOption>${project.basedir}/../oshi-common/target//junit-platform/patched-test-runtime/</additionalOption>);
fix it by removing the extra slash so the path is
"${project.basedir}/../oshi-common/target/junit-platform/patched-test-runtime/"
in the plugin's <javaOptions> configuration to keep the intended path
consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@oshi-common/src/test/java/oshi/software/os/InternetProtocolStatsTest.java`:
- Around line 63-68: Add a negative-path assertion in the
InternetProtocolStatsTest.testTcpStateEnum to verify invalid enum parsing
throws: call TcpState.valueOf with a bogus name (e.g., "INVALID" or "FOOBAR")
and assert that it throws IllegalArgumentException (use your test framework's
assertThrows or equivalent) so the test covers the failure case of
TcpState.valueOf.
- Around line 47-60: The test testIPConnectionGetters currently only checks
address lengths; update it to assert the actual byte contents returned by
IPConnection.getLocalAddress() and IPConnection.getForeignAddress() match the
expected arrays (local and foreign) rather than just their lengths. Locate the
IPConnection instantiation and replace or augment the length assertions with
content checks (e.g., use Arrays.equals or a matcher such as equalTo on the byte
arrays) so the test verifies exact address bytes for local and foreign
addresses.

In `@oshi-core-java25/pom.xml`:
- Around line 113-126: The module-path value in the junit-platform-maven-plugin
configuration contains a typo with a double slash in the additionalOption string
for "--module-path" (the value under
<additionalOption>${project.basedir}/../oshi-common/target//junit-platform/patched-test-runtime/</additionalOption>);
fix it by removing the extra slash so the path is
"${project.basedir}/../oshi-common/target/junit-platform/patched-test-runtime/"
in the plugin's <javaOptions> configuration to keep the intended path
consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3cc6f645-583e-4ae2-9f5e-654e6e9f38e7

📥 Commits

Reviewing files that changed from the base of the PR and between 2196390 and 27407a5.

📒 Files selected for processing (29)
  • .github/workflows/linux.yaml
  • .gitignore
  • config/import-control-test.xml
  • oshi-benchmark/pom.xml
  • oshi-benchmark/scripts/run-benchmarks.sh
  • oshi-common/pom.xml
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/test/java/module-info.test
  • oshi-common/src/test/java/oshi/hardware/CentralProcessorTest.java
  • oshi-common/src/test/java/oshi/hardware/GpuTicksTest.java
  • oshi-common/src/test/java/oshi/hardware/HWPartitionTest.java
  • oshi-common/src/test/java/oshi/hardware/HardwareAbstractionLayerTest.java
  • oshi-common/src/test/java/oshi/hardware/NetworkIFTest.java
  • oshi-common/src/test/java/oshi/hardware/PhysicalMemoryTest.java
  • oshi-common/src/test/java/oshi/software/os/ApplicationInfoTest.java
  • oshi-common/src/test/java/oshi/software/os/InternetProtocolStatsTest.java
  • oshi-common/src/test/java/oshi/software/os/OSDesktopWindowTest.java
  • oshi-common/src/test/java/oshi/software/os/OSProcessTest.java
  • oshi-common/src/test/java/oshi/software/os/OSServiceTest.java
  • oshi-common/src/test/java/oshi/software/os/OSSessionTest.java
  • oshi-common/src/test/java/oshi/software/os/OSThreadTest.java
  • oshi-common/src/test/java/oshi/software/os/OperatingSystemTest.java
  • oshi-core-java11/pom.xml
  • oshi-core-java11/src/main/java/module-info.java
  • oshi-core-java25/pom.xml
  • oshi-core-java25/src/test/java/module-info.test
  • oshi-demo/pom.xml
  • oshi-dist/pom.xml
  • pom.xml
✅ Files skipped from review due to trivial changes (6)
  • .gitignore
  • oshi-demo/pom.xml
  • oshi-common/src/test/java/oshi/hardware/GpuTicksTest.java
  • config/import-control-test.xml
  • oshi-common/src/test/java/oshi/hardware/PhysicalMemoryTest.java
  • oshi-common/src/test/java/oshi/software/os/OSServiceTest.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • oshi-core-java11/src/main/java/module-info.java
  • oshi-core-java11/pom.xml
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java11/src/main/java/module-info.java:10-17
Timestamp: 2026-03-29T20:01:06.452Z
Learning: In the oshi project, `oshi-core-java25/src/main/java/module-info.java` intentionally does NOT export `oshi.util.platform.unix.freebsd`, `oshi.util.platform.unix.openbsd`, or `oshi.util.platform.unix.solaris`, because the FFM (Foreign Function & Memory) implementation only supports Windows, macOS, and Linux. This differs from `oshi-core-java11/src/main/java/module-info.java` which exports all Unix platform packages. The asymmetry is by design.
Learnt from: dbwiddis
Repo: oshi/oshi PR: 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.
📚 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-dist/pom.xml
  • oshi-common/src/test/java/module-info.test
  • oshi-benchmark/pom.xml
  • oshi-common/src/main/java/module-info.java
  • oshi-core-java25/src/test/java/module-info.test
  • oshi-common/src/test/java/oshi/hardware/HardwareAbstractionLayerTest.java
  • oshi-benchmark/scripts/run-benchmarks.sh
  • oshi-core-java25/pom.xml
  • oshi-common/src/test/java/oshi/software/os/OperatingSystemTest.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-common/src/test/java/module-info.test
  • oshi-common/src/main/java/module-info.java
  • oshi-core-java25/src/test/java/module-info.test
  • oshi-core-java25/pom.xml
  • oshi-common/src/test/java/oshi/software/os/OperatingSystemTest.java
  • pom.xml
🔇 Additional comments (29)
oshi-common/src/test/java/oshi/software/os/ApplicationInfoTest.java (4)

19-29: Good constructor/getter verification.

This validates all core fields and confirms additionalInfo value access for a populated map.


31-35: Null-to-empty-map behavior is well covered.

Nice targeted test for the null additionalInfo contract.


37-47: equals/hashCode checks are solid.

Covers equality, inequality, self-comparison, null comparison, and hash consistency.


49-54: toString() expectations are validated appropriately.

Asserting key identifying fields in the output keeps this test useful without over-constraining formatting.

.github/workflows/linux.yaml (1)

62-63: Good sequencing for multi-module test stability.

Running install -DskipTests before test is a solid approach here; it ensures reactor artifacts are present in the local Maven repo before test execution.

oshi-common/src/test/java/oshi/software/os/OSSessionTest.java (1)

15-36: Good targeted coverage for OSSession constructor/getter and toString() branches.

These tests are focused, deterministic, and validate the key behavior paths (normal host rendering and no-login fallback) without brittle full-string coupling.

oshi-common/src/test/java/oshi/software/os/OSDesktopWindowTest.java (3)

17-18: Deterministic shared fixture is well-defined.

The static OSDesktopWindow setup is clear and stable for repeatable assertions across tests.


21-29: Getter coverage is complete and precise.

This validates all core fields (id, title, command, rectangle, owning PID, order, visibility) from the constructor contract.


32-37: toString() smoke test is appropriately scoped.

Checking key identifiers in the output gives useful regression protection without over-coupling to exact formatting.

oshi-common/src/test/java/oshi/software/os/InternetProtocolStatsTest.java (1)

20-44: Good baseline constructor/getter coverage for TcpStats and UdpStats.

These assertions are clear and validate the primary data-path behavior well.

oshi-common/src/test/java/oshi/hardware/HWPartitionTest.java (1)

15-43: Solid coverage for HWPartition constructor defaults and label handling.

The tests correctly validate both constructor paths and key toString() characteristics without over-constraining formatting.

oshi-common/src/test/java/oshi/software/os/OSThreadTest.java (1)

16-188: Good default-vs-override behavioral test pattern for OSThread.

This cleanly protects interface default contracts while confirming override behavior.

oshi-common/src/test/java/oshi/hardware/NetworkIFTest.java (1)

267-307: Nice validation of NetworkIF defaults plus enum mapping semantics.

The IfOperStatus.byValue(...) and default-method assertions provide useful regression protection.

oshi-common/src/test/java/oshi/hardware/HardwareAbstractionLayerTest.java (1)

159-185: Good contract tests for HAL default collection-return methods.

Verifying non-null empty defaults and overridden non-empty paths is exactly the right guardrail here.

oshi-common/src/test/java/oshi/software/os/OSProcessTest.java (1)

368-406: Strong targeted coverage for OSProcess default delegation and overrides.

This test set should catch regressions in default-memory/counter semantics effectively.

oshi-common/src/test/java/oshi/hardware/CentralProcessorTest.java (1)

24-130: Comprehensive unit coverage for CentralProcessor nested types and value semantics.

Constructor/getter checks plus equality/hashCode and enum-index assertions look well structured.

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

240-309: Excellent default-contract and override-path coverage for OperatingSystem.

The OSVersionInfo string-format assertions also add valuable regression safety.

oshi-dist/pom.xml (1)

59-59: LGTM!

Disabling the assembly execution by default (phase=none) aligns with the PR objective to avoid reactor directory resolution issues. The assembly can be explicitly invoked when needed (e.g., during release).

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

1-15: Well-structured module descriptor for oshi-common.

The module properly:

  • Exports the public API packages (oshi.hardware, oshi.software.os) and utility packages
  • Declares java.desktop as transitive (needed for AWT types in display APIs)
  • Keeps org.slf4j non-transitive (implementation detail)

This establishes com.github.oshi.common as a proper JNA-free JPMS module as intended by the PR.

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

1-9: LGTM!

The test module configuration correctly:

  • Opens oshi.hardware and oshi.software.os packages to JUnit Platform for reflective test access
  • Adds required test modules (org.hamcrest, org.slf4j.simple)
  • Grants read access to test dependencies including java.desktop (matching the transitive require)
pom.xml (2)

305-307: Reasonable addition for module flexibility.

Adding <failIfNoTests>false</failIfNoTests> allows the build to succeed when a module has no tests, which is appropriate given the new oshi-common module structure and the various test configurations across modules.


264-265: LGTM!

The argLine reformatting is whitespace-only and functionally equivalent.

oshi-common/pom.xml (1)

69-94: Correct multi-release module compilation pattern.

The two-phase compilation approach is the standard pattern for maintaining Java 8 bytecode compatibility while providing a proper JPMS module descriptor:

  • default-compile excludes module-info.java and uses inherited Java 8 settings
  • compile-module-info compiles only module-info.java with release=9

This ensures the module works both on the classpath (Java 8+) and module path (Java 9+).

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

6-14: LGTM!

The test configuration correctly:

  • Opens oshi.jna.util for JUnit Platform reflective access (matching the JNA utility extraction)
  • Adds com.github.oshi.common to the module graph
  • Grants com.github.oshi.common read access to test libraries, consistent with oshi-common's own test configuration
oshi-core-java25/pom.xml (2)

75-84: OSGi configuration correctly excludes oshi-common packages.

The explicit Export-Package list exports only implementation packages (oshi.ffm.*, oshi.jna.*, oshi.driver.*, etc.) while omitting packages now owned by oshi-common. This prevents OSGi split-package violations and aligns with the JPMS module structure.


97-99: Good documentation of future intent.

The TODO comment clearly documents that source copying from oshi-core is temporary until oshi-core-java25 fully replaces it. This helps maintainers understand the migration path.

oshi-benchmark/pom.xml (2)

21-24: LGTM!

The changes appropriately:

  • Skip tests for the benchmark module (JMH benchmarks aren't traditional tests)
  • Make shading opt-in via ${shade.phase} property (disabled by default with none)

This keeps normal builds fast while allowing explicit benchmark artifact creation when needed via -Dshade.phase=package.


64-64: Good pattern for conditional plugin execution.

Using a property for the phase makes the shade execution configurable without modifying the POM, which is cleaner than profile-based activation for this use case.

oshi-benchmark/scripts/run-benchmarks.sh (1)

31-32: Good update for module split compatibility and benchmark shading.

Line 31 correctly includes oshi-common in the pre-build set, and Line 32 explicitly forces shading at package time, which makes benchmark jar generation consistent with the new phase-controlled setup.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
oshi-common/src/test/java/oshi/software/os/OperatingSystemTest.java (1)

26-238: Consider reducing duplicated stub boilerplate.

MINIMAL and OVERRIDING duplicate many identical method bodies. Extracting a small base test stub (or builder/factory helper) would make future interface changes easier to maintain.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-common/src/test/java/oshi/software/os/OperatingSystemTest.java` around
lines 26 - 238, MINIMAL and OVERRIDING repeat many identical stub methods;
extract a common test stub to reduce duplication by adding a small base
implementation (e.g., class TestOperatingSystem implements OperatingSystem or a
factory method) that supplies the shared default implementations for methods
like getFileSystem, getInternetProtocolStats, getProcesses, getChildProcesses,
getDescendantProcesses, getProcessCount, getThreadCount, getBitness,
getSystemUptime, getSystemBootTime, getNetworkParams, getCurrentThread, etc.,
then redefine MINIMAL and OVERRIDING to extend/compose that base and only
override the differing methods (getFamily, getManufacturer, getVersionInfo,
getProcessId/getThreadId, and OVERRIDING-specific
isElevated/getServices/getSessions/getDesktopWindows/getInstalledApplications)
so future interface changes require edits in one place.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@oshi-common/src/test/java/oshi/software/os/OperatingSystemTest.java`:
- Line 25: Update the misleading comment in OperatingSystemTest: change the line
that says the minimal stub “returns a single fixed process for getProcess(pid)”
to accurately state that the minimal stub returns null for getProcess(pid) (or
otherwise reflects the actual behavior of the stub used in the test), ensuring
the comment references the getProcess(pid) behavior in the test class
OperatingSystemTest.

---

Nitpick comments:
In `@oshi-common/src/test/java/oshi/software/os/OperatingSystemTest.java`:
- Around line 26-238: MINIMAL and OVERRIDING repeat many identical stub methods;
extract a common test stub to reduce duplication by adding a small base
implementation (e.g., class TestOperatingSystem implements OperatingSystem or a
factory method) that supplies the shared default implementations for methods
like getFileSystem, getInternetProtocolStats, getProcesses, getChildProcesses,
getDescendantProcesses, getProcessCount, getThreadCount, getBitness,
getSystemUptime, getSystemBootTime, getNetworkParams, getCurrentThread, etc.,
then redefine MINIMAL and OVERRIDING to extend/compose that base and only
override the differing methods (getFamily, getManufacturer, getVersionInfo,
getProcessId/getThreadId, and OVERRIDING-specific
isElevated/getServices/getSessions/getDesktopWindows/getInstalledApplications)
so future interface changes require edits in one place.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 951a5f91-39ea-4246-a694-59d3c538db63

📥 Commits

Reviewing files that changed from the base of the PR and between 27407a5 and d02c788.

📒 Files selected for processing (29)
  • .github/workflows/linux.yaml
  • .gitignore
  • config/import-control-test.xml
  • oshi-benchmark/pom.xml
  • oshi-benchmark/scripts/run-benchmarks.sh
  • oshi-common/pom.xml
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/test/java/module-info.test
  • oshi-common/src/test/java/oshi/hardware/CentralProcessorTest.java
  • oshi-common/src/test/java/oshi/hardware/GpuTicksTest.java
  • oshi-common/src/test/java/oshi/hardware/HWPartitionTest.java
  • oshi-common/src/test/java/oshi/hardware/HardwareAbstractionLayerTest.java
  • oshi-common/src/test/java/oshi/hardware/NetworkIFTest.java
  • oshi-common/src/test/java/oshi/hardware/PhysicalMemoryTest.java
  • oshi-common/src/test/java/oshi/software/os/ApplicationInfoTest.java
  • oshi-common/src/test/java/oshi/software/os/InternetProtocolStatsTest.java
  • oshi-common/src/test/java/oshi/software/os/OSDesktopWindowTest.java
  • oshi-common/src/test/java/oshi/software/os/OSProcessTest.java
  • oshi-common/src/test/java/oshi/software/os/OSServiceTest.java
  • oshi-common/src/test/java/oshi/software/os/OSSessionTest.java
  • oshi-common/src/test/java/oshi/software/os/OSThreadTest.java
  • oshi-common/src/test/java/oshi/software/os/OperatingSystemTest.java
  • oshi-core-java11/pom.xml
  • oshi-core-java11/src/main/java/module-info.java
  • oshi-core-java25/pom.xml
  • oshi-core-java25/src/test/java/module-info.test
  • oshi-demo/pom.xml
  • oshi-dist/pom.xml
  • pom.xml
✅ Files skipped from review due to trivial changes (18)
  • oshi-dist/pom.xml
  • .github/workflows/linux.yaml
  • .gitignore
  • oshi-demo/pom.xml
  • config/import-control-test.xml
  • oshi-common/src/test/java/module-info.test
  • oshi-common/src/test/java/oshi/hardware/PhysicalMemoryTest.java
  • oshi-common/src/test/java/oshi/software/os/OSDesktopWindowTest.java
  • oshi-common/src/test/java/oshi/software/os/ApplicationInfoTest.java
  • oshi-common/src/test/java/oshi/hardware/HardwareAbstractionLayerTest.java
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/test/java/oshi/software/os/OSServiceTest.java
  • oshi-common/src/test/java/oshi/software/os/InternetProtocolStatsTest.java
  • oshi-common/src/test/java/oshi/hardware/HWPartitionTest.java
  • oshi-common/src/test/java/oshi/software/os/OSSessionTest.java
  • oshi-common/src/test/java/oshi/hardware/NetworkIFTest.java
  • oshi-core-java11/pom.xml
  • pom.xml
🚧 Files skipped from review as they are similar to previous changes (7)
  • oshi-common/pom.xml
  • oshi-core-java25/src/test/java/module-info.test
  • oshi-common/src/test/java/oshi/software/os/OSThreadTest.java
  • oshi-common/src/test/java/oshi/hardware/CentralProcessorTest.java
  • oshi-common/src/test/java/oshi/software/os/OSProcessTest.java
  • oshi-common/src/test/java/oshi/hardware/GpuTicksTest.java
  • oshi-benchmark/pom.xml
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java11/src/main/java/module-info.java:10-17
Timestamp: 2026-03-29T20:01:06.452Z
Learning: In the oshi project, `oshi-core-java25/src/main/java/module-info.java` intentionally does NOT export `oshi.util.platform.unix.freebsd`, `oshi.util.platform.unix.openbsd`, or `oshi.util.platform.unix.solaris`, because the FFM (Foreign Function & Memory) implementation only supports Windows, macOS, and Linux. This differs from `oshi-core-java11/src/main/java/module-info.java` which exports all Unix platform packages. The asymmetry is by design.
Learnt from: dbwiddis
Repo: oshi/oshi PR: 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.
📚 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-java11/src/main/java/module-info.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-core-java11/src/main/java/module-info.java
  • oshi-core-java25/pom.xml
  • oshi-common/src/test/java/oshi/software/os/OperatingSystemTest.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-java25/pom.xml
  • oshi-common/src/test/java/oshi/software/os/OperatingSystemTest.java
🔇 Additional comments (8)
oshi-benchmark/scripts/run-benchmarks.sh (1)

31-32: Good fix for benchmark bootstrap path.

Line 31 correctly includes oshi-common in the pre-build install set, and Line 32 correctly forces shade execution with -Dshade.phase=package, which aligns with the benchmark POM’s default shade.phase=none.

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

23-23: Transitive common-module dependency looks correct.

Line 23 correctly adds requires transitive com.github.oshi.common;, which preserves downstream visibility of API packages relocated to the common module.

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

240-309: Strong coverage of default vs override semantics.

These tests clearly lock in the intended contract for OperatingSystem default methods and OSVersionInfo string formatting/null-handling.

oshi-core-java25/pom.xml (5)

75-84: Bnd configuration correctly excludes oshi-common-owned packages.

The Export-Package directive properly exports only implementation packages (oshi.ffm.*, oshi.jna.*, oshi.driver.*, etc.) while omitting the public API packages now owned by oshi-common. The -split-package:=merge-first directive is appropriate for handling the migration period.

Consider adding a comment noting that -split-package:=merge-first can be removed once the module separation is complete and verified.


97-99: Good documentation of the transitional state.

The TODO comment clearly documents the intended future cleanup. Removing the oshi-common source addition aligns with the PR objective of establishing oshi-common as a proper JPMS dependency.


110-112: LGTM!

Removing oshi-common from the sourcepath is correct since it's now a separate module with its own Javadoc generation.


134-134: LGTM!

Consistent with the build section's Javadoc configuration.


113-123: JAVA executor is appropriate for modular testing.

Using executor=JAVA ensures tests run in a separate JVM process that properly respects JPMS module boundaries. The --show-version option aids in debugging CI failures. The plugin version is correctly managed in the parent POM's property definition.

- oshi-common: add module-info.java (compiled at release 9, main sources
  at release 8) exporting oshi.hardware, oshi.software.os, oshi.util,
  oshi.util.tuples, oshi.annotation*; requires transitive java.desktop
- oshi-common: add unit tests for all interfaces/classes in
oshi.hardware
  and oshi.software.os (70 tests)
- oshi-core-java11: switch from compiling oshi-common sources directly
to
  depending on oshi-common jar; update module-info.java to require
  transitive com.github.oshi.common; skip tests (tested in oshi-core)
- oshi-core-java25: add --add-modules com.github.oshi.common to
  module-info.test for junit-platform-maven-plugin runtime
- oshi-benchmark: bind shade to phase=none to avoid reactor directory
  resolution; skip tests; remove accidental junit-jupiter-engine dep;
  remove committed dependency-reduced-pom.xml
- oshi-demo: replace junit.platform.skip workaround with
maven.test.skip;
  remove junit-jupiter-engine workaround dependency
- oshi-dist: bind assembly to phase=none to avoid reactor directory
  resolution (same root cause as benchmark/shade)
- config/import-control-test.xml: allow java.awt.Rectangle and
  java.net.NetworkInterface by specific class (not whole package)
- .gitignore: add oshi-benchmark/dependency-reduced-pom.xml
@dbwiddis
dbwiddis merged commit 3c77525 into oshi:master Apr 9, 2026
14 of 15 checks passed
@dbwiddis
dbwiddis deleted the util-jna branch April 9, 2026 19:57
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