Repository navigation
Extract oshi-common module and resolve JPMS split-package violations - #3132
Conversation
- 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
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (29)
✅ Files skipped from review due to trivial changes (20)
🚧 Files skipped from review as they are similar to previous changes (6)
📜 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)
🧰 Additional context used🧠 Learnings (3)📓 Common learnings📚 Learning: 2026-04-06T04:45:51.516ZApplied to files:
📚 Learning: 2026-03-29T20:01:06.452ZApplied to files:
🔇 Additional comments (11)
📝 WalkthroughWalkthroughExtracts 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
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
oshi-core/src/main/java/oshi/PlatformEnum.java (1)
119-149: Consider delegating tooshi.util.PlatformEnumto 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 ifoshi-commonisn'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
📒 Files selected for processing (70)
oshi-benchmark/dependency-reduced-pom.xmloshi-common/src/main/java/oshi/hardware/CentralProcessor.javaoshi-common/src/main/java/oshi/hardware/GlobalMemory.javaoshi-common/src/main/java/oshi/hardware/HWDiskStore.javaoshi-common/src/main/java/oshi/hardware/HWPartition.javaoshi-common/src/main/java/oshi/hardware/HardwareAbstractionLayer.javaoshi-common/src/main/java/oshi/hardware/PhysicalMemory.javaoshi-common/src/main/java/oshi/package-info.javaoshi-common/src/main/java/oshi/software/os/OSProcess.javaoshi-common/src/main/java/oshi/software/os/OSThread.javaoshi-common/src/main/java/oshi/software/os/OperatingSystem.javaoshi-common/src/main/java/oshi/util/Constants.javaoshi-common/src/main/java/oshi/util/EdidUtil.javaoshi-common/src/main/java/oshi/util/ExecutingCommand.javaoshi-common/src/main/java/oshi/util/FileSystemUtil.javaoshi-common/src/main/java/oshi/util/FileUtil.javaoshi-common/src/main/java/oshi/util/FormatUtil.javaoshi-common/src/main/java/oshi/util/GlobalConfig.javaoshi-common/src/main/java/oshi/util/Memoizer.javaoshi-common/src/main/java/oshi/util/ParseUtil.javaoshi-common/src/main/java/oshi/util/PlatformEnum.javaoshi-common/src/main/java/oshi/util/PrivilegedUtil.javaoshi-common/src/main/java/oshi/util/ProcUtil.javaoshi-common/src/main/java/oshi/util/SystemInfoHelper.javaoshi-common/src/main/java/oshi/util/UserGroupInfo.javaoshi-common/src/main/java/oshi/util/Util.javaoshi-common/src/main/java/oshi/util/package-info.javaoshi-common/src/main/java/oshi/util/tuples/Pair.javaoshi-common/src/main/java/oshi/util/tuples/Quartet.javaoshi-common/src/main/java/oshi/util/tuples/Quintet.javaoshi-common/src/main/java/oshi/util/tuples/Triplet.javaoshi-common/src/main/java/oshi/util/tuples/package-info.javaoshi-core-java11/pom.xmloshi-core-java11/src/main/java/module-info.javaoshi-core-java11/src/test/java/module-info.testoshi-core-java25/pom.xmloshi-core-java25/src/main/java/module-info.javaoshi-core-java25/src/main/java/oshi/ffm/SystemInfo.javaoshi-core-java25/src/test/java/module-info.testoshi-core-java25/src/test/java/oshi/ffm/GlobalMemoryFFMTest.javaoshi-core-java25/src/test/java/oshi/ffm/OperatingSystemFFMTest.javaoshi-core-java25/src/test/java/oshi/ffm/SystemInfoTest.javaoshi-core-java25/src/test/java/oshi/ffm/VirtualMemoryFFMTest.javaoshi-core-java25/src/test/java/oshi/hardware/GlobalMemoryFFMTest.javaoshi-core-java25/src/test/java/oshi/hardware/VirtualMemoryFFMTest.javaoshi-core-java25/src/test/java/oshi/software/os/OperatingSystemFFMTest.javaoshi-core/src/main/java/oshi/PlatformEnum.javaoshi-core/src/main/java/oshi/driver/linux/proc/Auxv.javaoshi-core/src/main/java/oshi/driver/unix/Who.javaoshi-core/src/main/java/oshi/hardware/common/AbstractCentralProcessor.javaoshi-core/src/main/java/oshi/hardware/package-info.javaoshi-core/src/main/java/oshi/jna/ByRef.javaoshi-core/src/main/java/oshi/jna/Struct.javaoshi-core/src/main/java/oshi/jna/platform/mac/CoreGraphics.javaoshi-core/src/main/java/oshi/jna/platform/mac/IOKit.javaoshi-core/src/main/java/oshi/jna/platform/mac/SystemB.javaoshi-core/src/main/java/oshi/jna/platform/unix/CLibrary.javaoshi-core/src/main/java/oshi/jna/platform/unix/SolarisLibc.javaoshi-core/src/main/java/oshi/jna/platform/windows/PowrProf.javaoshi-core/src/main/java/oshi/jna/util/FileUtilJNA.javaoshi-core/src/main/java/oshi/jna/util/package-info.javaoshi-core/src/main/java/oshi/software/common/AbstractOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/package-info.javaoshi-core/src/test/java/oshi/hardware/CentralProcessorTest.javaoshi-core/src/test/java/oshi/jna/util/FileUtilJNATest.javaoshi-core/src/test/java/oshi/software/os/FileSystemTest.javaoshi-core/src/test/java/oshi/util/ExecutingCommandTest.javaoshi-core/src/test/java/oshi/util/FileUtilTest.javaoshi-core/src/test/java/oshi/util/FstatUtilTest.javaoshi-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.javaoshi-common/src/main/java/oshi/hardware/GlobalMemory.javaoshi-common/src/main/java/oshi/hardware/PhysicalMemory.javaoshi-common/src/main/java/oshi/util/Constants.javaoshi-common/src/main/java/oshi/util/FormatUtil.javaoshi-common/src/main/java/oshi/hardware/CentralProcessor.javaoshi-common/src/main/java/oshi/util/FileSystemUtil.javaoshi-common/src/main/java/oshi/util/EdidUtil.javaoshi-common/src/main/java/oshi/util/Memoizer.javaoshi-core-java11/src/test/java/module-info.testoshi-common/src/main/java/oshi/util/PlatformEnum.javaoshi-common/src/main/java/oshi/software/os/OSThread.javaoshi-common/src/main/java/oshi/util/UserGroupInfo.javaoshi-core-java11/src/main/java/module-info.javaoshi-core-java25/src/main/java/oshi/ffm/SystemInfo.javaoshi-common/src/main/java/oshi/util/ExecutingCommand.javaoshi-core/src/main/java/oshi/jna/platform/mac/CoreGraphics.javaoshi-core/src/main/java/oshi/driver/linux/proc/Auxv.javaoshi-common/src/main/java/oshi/software/os/OperatingSystem.javaoshi-core/src/main/java/oshi/jna/util/package-info.javaoshi-core/src/main/java/oshi/jna/platform/unix/CLibrary.javaoshi-core/src/main/java/oshi/jna/platform/mac/IOKit.javaoshi-core/src/test/java/oshi/software/os/FileSystemTest.javaoshi-core/src/main/java/oshi/jna/platform/windows/PowrProf.javaoshi-core/src/test/java/oshi/hardware/CentralProcessorTest.javaoshi-core/src/main/java/oshi/driver/unix/Who.javaoshi-core-java25/src/main/java/module-info.javaoshi-core-java25/pom.xmloshi-core/src/main/java/oshi/jna/ByRef.javaoshi-core/src/main/java/oshi/software/common/AbstractOperatingSystem.javaoshi-core/src/main/java/oshi/jna/Struct.javaoshi-common/src/main/java/oshi/util/ProcUtil.javaoshi-core-java25/src/test/java/oshi/ffm/OperatingSystemFFMTest.javaoshi-core/src/main/java/oshi/PlatformEnum.javaoshi-core/src/test/java/oshi/util/FileUtilTest.javaoshi-core-java25/src/test/java/module-info.testoshi-core/src/main/java/oshi/jna/platform/unix/SolarisLibc.javaoshi-common/src/main/java/oshi/util/SystemInfoHelper.javaoshi-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.javaoshi-common/src/main/java/oshi/hardware/GlobalMemory.javaoshi-common/src/main/java/oshi/hardware/PhysicalMemory.javaoshi-common/src/main/java/oshi/util/Constants.javaoshi-common/src/main/java/oshi/util/FormatUtil.javaoshi-common/src/main/java/oshi/hardware/CentralProcessor.javaoshi-common/src/main/java/oshi/util/FileSystemUtil.javaoshi-common/src/main/java/oshi/util/EdidUtil.javaoshi-common/src/main/java/oshi/util/Memoizer.javaoshi-core-java11/src/test/java/module-info.testoshi-common/src/main/java/oshi/util/PlatformEnum.javaoshi-common/src/main/java/oshi/util/UserGroupInfo.javaoshi-core-java25/src/main/java/oshi/ffm/SystemInfo.javaoshi-common/src/main/java/oshi/util/ExecutingCommand.javaoshi-core/src/main/java/oshi/jna/platform/mac/CoreGraphics.javaoshi-common/src/main/java/oshi/software/os/OperatingSystem.javaoshi-core/src/main/java/oshi/jna/platform/mac/SystemB.javaoshi-core/src/main/java/oshi/jna/util/package-info.javaoshi-core/src/main/java/oshi/jna/platform/unix/CLibrary.javaoshi-core/src/main/java/oshi/jna/platform/mac/IOKit.javaoshi-core/src/test/java/oshi/software/os/FileSystemTest.javaoshi-core/src/main/java/oshi/jna/platform/windows/PowrProf.javaoshi-core/src/main/java/oshi/driver/unix/Who.javaoshi-core-java25/pom.xmloshi-core/src/main/java/oshi/jna/ByRef.javaoshi-core/src/main/java/oshi/software/common/AbstractOperatingSystem.javaoshi-core/src/main/java/oshi/jna/Struct.javaoshi-common/src/main/java/oshi/util/ProcUtil.javaoshi-benchmark/dependency-reduced-pom.xmloshi-core-java25/src/test/java/oshi/ffm/GlobalMemoryFFMTest.javaoshi-core-java25/src/test/java/oshi/ffm/OperatingSystemFFMTest.javaoshi-core/src/main/java/oshi/PlatformEnum.javaoshi-core/src/test/java/oshi/util/FileUtilTest.javaoshi-core-java25/src/test/java/module-info.testoshi-core/src/main/java/oshi/jna/platform/unix/SolarisLibc.javaoshi-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.javaoshi-core-java25/src/main/java/oshi/ffm/SystemInfo.javaoshi-common/src/main/java/oshi/util/ExecutingCommand.javaoshi-core/src/main/java/oshi/hardware/common/AbstractCentralProcessor.javaoshi-core/src/main/java/oshi/jna/platform/unix/CLibrary.javaoshi-core/src/test/java/oshi/hardware/CentralProcessorTest.javaoshi-core/src/main/java/oshi/driver/unix/Who.javaoshi-core/src/main/java/oshi/PlatformEnum.javaoshi-core/src/main/java/oshi/jna/platform/unix/SolarisLibc.javaoshi-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.javaoshi-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.javaoshi-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.javaoshi-core/src/main/java/oshi/jna/platform/windows/PowrProf.javaoshi-core/src/main/java/oshi/jna/Struct.javaoshi-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.javaoshi-core/src/main/java/oshi/jna/platform/unix/CLibrary.javaoshi-core/src/main/java/oshi/jna/platform/mac/IOKit.javaoshi-core/src/main/java/oshi/jna/ByRef.javaoshi-core/src/main/java/oshi/jna/Struct.javaoshi-core/src/main/java/oshi/jna/util/FileUtilJNA.javaoshi-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
PlatformEnumunderoshi.utilhere 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
PlatformEnumpackage location.oshi-core-java25/src/main/java/oshi/ffm/SystemInfo.java (1)
19-19: Looks good.The import migration to
oshi.util.PlatformEnumis 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
PlatformEnummove.oshi-common/src/main/java/oshi/util/ExecutingCommand.java (1)
35-39: Platform detection swap is solid.Replacing JNA
Platformchecks withPlatformEnum.getCurrentPlatform()here preserves behavior while keepingoshi-commonJNA-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
PlatformEnumkeeps 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()withPlatformEnum.getCurrentPlatform() == PlatformEnum.LINUXcorrectly removes the JNA dependency while maintaining equivalent behavior. ThePlatformEnum.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.PlatformEnumtooshi.util.PlatformEnumaligns 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 toAbstractOperatingSystem(which overrides withUserGroupInfo.isElevated(),Who.queryWho(), andXwininfo.queryXWindows()), and platform-specific classes likeWindowsOperatingSystemandLinuxOperatingSystemfurther 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 whereOperatingSysteminterface provides JNA-free stubs andAbstractOperatingSystemprovides 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.PlatformEnumprovides a clean migration path for existing users. All elements are properly marked@Deprecatedwith Javadoc pointing tooshi.util.PlatformEnum. The platform detection logic correctly mirrors the canonical implementation, including the intentionalequalsIgnoreCase("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
SystemInfoHelperclass provides a clean, reusable set of methods for printing OSHI system information across test modules. The design withList<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, andvirtualMax >= 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-specificinstanceof MacOperatingSystemFFMcoverage 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
SystemInfoHelperstatic 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.commonis 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 theoshi-commonextraction.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 inoshi.util.FileUtillooks clean.
oshi-commonstays 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.utilfor JUnit is the right test-access update.oshi-core-java11/src/test/java/module-info.test (1)
51-52: Test module--add-opensforoshi.jna.utilis correctly added.oshi-core-java25/src/test/java/module-info.test (1)
6-6: Keepingoshi.jna.utilin 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
FileUtilbehavior, 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 inqueryAuxv().Updating both key and value reads to
FileUtilJNAkeeps 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: Uniformclose()migration across wrappers looks solid.Nice consistent replacement to
FileUtilJNA.freeMemory(...)across allByRefcloseable 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 throughFileUtilJNA.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, andNativeLong) 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-commonboundary 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
| <transformer> | ||
| <mainClass>org.openjdk.jmh.Main</mainClass> | ||
| </transformer> | ||
| <transformer /> | ||
| <transformer> | ||
| <resource>META-INF/BenchmarkList</resource> | ||
| </transformer> | ||
| <transformer> | ||
| <resource>META-INF/CompilerHints</resource> | ||
| </transformer> |
There was a problem hiding this comment.
🧩 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")
PYRepository: 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 -20Repository: 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 xmlRepository: 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 -20Repository: 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.
| <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.
| 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(), |
There was a problem hiding this comment.
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.
| 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.
| * Utility class to temporarily cache the userID and group maps in *nix, for parsing process ownership. Cache expires | ||
| * after one minute. | ||
| */ |
There was a problem hiding this comment.
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 unavailableAlso 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.
| 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; |
There was a problem hiding this comment.
🧩 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.javaRepository: 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.
| 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 Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (3)
oshi-common/src/test/java/oshi/software/os/InternetProtocolStatsTest.java (2)
63-68: Add a negative-path enum parse test.
valueOfhappy-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: StrengthenIPConnectionaddress 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
📒 Files selected for processing (29)
.github/workflows/linux.yaml.gitignoreconfig/import-control-test.xmloshi-benchmark/pom.xmloshi-benchmark/scripts/run-benchmarks.shoshi-common/pom.xmloshi-common/src/main/java/module-info.javaoshi-common/src/test/java/module-info.testoshi-common/src/test/java/oshi/hardware/CentralProcessorTest.javaoshi-common/src/test/java/oshi/hardware/GpuTicksTest.javaoshi-common/src/test/java/oshi/hardware/HWPartitionTest.javaoshi-common/src/test/java/oshi/hardware/HardwareAbstractionLayerTest.javaoshi-common/src/test/java/oshi/hardware/NetworkIFTest.javaoshi-common/src/test/java/oshi/hardware/PhysicalMemoryTest.javaoshi-common/src/test/java/oshi/software/os/ApplicationInfoTest.javaoshi-common/src/test/java/oshi/software/os/InternetProtocolStatsTest.javaoshi-common/src/test/java/oshi/software/os/OSDesktopWindowTest.javaoshi-common/src/test/java/oshi/software/os/OSProcessTest.javaoshi-common/src/test/java/oshi/software/os/OSServiceTest.javaoshi-common/src/test/java/oshi/software/os/OSSessionTest.javaoshi-common/src/test/java/oshi/software/os/OSThreadTest.javaoshi-common/src/test/java/oshi/software/os/OperatingSystemTest.javaoshi-core-java11/pom.xmloshi-core-java11/src/main/java/module-info.javaoshi-core-java25/pom.xmloshi-core-java25/src/test/java/module-info.testoshi-demo/pom.xmloshi-dist/pom.xmlpom.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.xmloshi-common/src/test/java/module-info.testoshi-benchmark/pom.xmloshi-common/src/main/java/module-info.javaoshi-core-java25/src/test/java/module-info.testoshi-common/src/test/java/oshi/hardware/HardwareAbstractionLayerTest.javaoshi-benchmark/scripts/run-benchmarks.shoshi-core-java25/pom.xmloshi-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.testoshi-common/src/main/java/module-info.javaoshi-core-java25/src/test/java/module-info.testoshi-core-java25/pom.xmloshi-common/src/test/java/oshi/software/os/OperatingSystemTest.javapom.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
additionalInfovalue access for a populated map.
31-35: Null-to-empty-map behavior is well covered.Nice targeted test for the null
additionalInfocontract.
37-47:equals/hashCodechecks 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 -DskipTestsbeforetestis 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 forOSSessionconstructor/getter andtoString()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
OSDesktopWindowsetup 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 forTcpStatsandUdpStats.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 forHWPartitionconstructor 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 forOSThread.This cleanly protects interface default contracts while confirming override behavior.
oshi-common/src/test/java/oshi/hardware/NetworkIFTest.java (1)
267-307: Nice validation ofNetworkIFdefaults 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 forOSProcessdefault 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 forCentralProcessornested 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 forOperatingSystem.The
OSVersionInfostring-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.desktopas transitive (needed for AWT types in display APIs)- Keeps
org.slf4jnon-transitive (implementation detail)This establishes
com.github.oshi.commonas 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.hardwareandoshi.software.ospackages 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 newoshi-commonmodule 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-compileexcludesmodule-info.javaand uses inherited Java 8 settingscompile-module-infocompiles onlymodule-info.javawithrelease=9This 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.utilfor JUnit Platform reflective access (matching the JNA utility extraction)- Adds
com.github.oshi.commonto the module graph- Grants
com.github.oshi.commonread access to test libraries, consistent withoshi-common's own test configurationoshi-core-java25/pom.xml (2)
75-84: OSGi configuration correctly excludes oshi-common packages.The explicit
Export-Packagelist exports only implementation packages (oshi.ffm.*,oshi.jna.*,oshi.driver.*, etc.) while omitting packages now owned byoshi-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-coreis temporary untiloshi-core-java25fully 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 withnone)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-commonin 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.
There was a problem hiding this comment.
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.
MINIMALandOVERRIDINGduplicate 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
📒 Files selected for processing (29)
.github/workflows/linux.yaml.gitignoreconfig/import-control-test.xmloshi-benchmark/pom.xmloshi-benchmark/scripts/run-benchmarks.shoshi-common/pom.xmloshi-common/src/main/java/module-info.javaoshi-common/src/test/java/module-info.testoshi-common/src/test/java/oshi/hardware/CentralProcessorTest.javaoshi-common/src/test/java/oshi/hardware/GpuTicksTest.javaoshi-common/src/test/java/oshi/hardware/HWPartitionTest.javaoshi-common/src/test/java/oshi/hardware/HardwareAbstractionLayerTest.javaoshi-common/src/test/java/oshi/hardware/NetworkIFTest.javaoshi-common/src/test/java/oshi/hardware/PhysicalMemoryTest.javaoshi-common/src/test/java/oshi/software/os/ApplicationInfoTest.javaoshi-common/src/test/java/oshi/software/os/InternetProtocolStatsTest.javaoshi-common/src/test/java/oshi/software/os/OSDesktopWindowTest.javaoshi-common/src/test/java/oshi/software/os/OSProcessTest.javaoshi-common/src/test/java/oshi/software/os/OSServiceTest.javaoshi-common/src/test/java/oshi/software/os/OSSessionTest.javaoshi-common/src/test/java/oshi/software/os/OSThreadTest.javaoshi-common/src/test/java/oshi/software/os/OperatingSystemTest.javaoshi-core-java11/pom.xmloshi-core-java11/src/main/java/module-info.javaoshi-core-java25/pom.xmloshi-core-java25/src/test/java/module-info.testoshi-demo/pom.xmloshi-dist/pom.xmlpom.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.javaoshi-core-java25/pom.xmloshi-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.xmloshi-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-commonin the pre-build install set, and Line 32 correctly forces shade execution with-Dshade.phase=package, which aligns with the benchmark POM’s defaultshade.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
OperatingSystemdefault methods andOSVersionInfostring formatting/null-handling.oshi-core-java25/pom.xml (5)
75-84: Bnd configuration correctly excludes oshi-common-owned packages.The
Export-Packagedirective properly exports only implementation packages (oshi.ffm.*,oshi.jna.*,oshi.driver.*, etc.) while omitting the public API packages now owned byoshi-common. The-split-package:=merge-firstdirective is appropriate for handling the migration period.Consider adding a comment noting that
-split-package:=merge-firstcan 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-commonsource addition aligns with the PR objective of establishing oshi-common as a proper JPMS dependency.
110-112: LGTM!Removing
oshi-commonfrom 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=JAVAensures tests run in a separate JVM process that properly respects JPMS module boundaries. The--show-versionoption 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
Fixes
LayerInstantiationException/ResolutionExceptionerrors inoshi-core-java11andoshi-core-java25caused by JPMS split-package violations — multiple named modules exporting the same package. Establishesoshi-commonas a proper JNA-free JPMS module.Root Causes
oshi.util.tupleswere split acrosscom.github.oshiandcom.github.oshi.commonjarspom.xmlbnd configExport-Package: oshi.*;-noimport:=truephysically inlined alloshi.*dependency classes fromoshi-commonintooshi-core-java25's jar, causingoshi.util.tuplesetc. to appear in both named modules at runtimeoshi-core-java11compiledoshi-commonsources directly into itself but also declaredoshi-commonas a Maven dependency, putting the same packages into two named modules at runtimeChanges
oshi-common
oshi-common:CentralProcessor,GlobalMemory,HardwareAbstractionLayer,HWDiskStore,HWPartition,PhysicalMemory,OperatingSystem,OSProcess,OSThreadoshi-common:Constants,FileUtil,FormatUtil,GlobalConfig,Memoizer,ParseUtil,PrivilegedUtil,Util,UserGroupInfo,ExecutingCommand,oshi.util.tuplesEdidUtil,FileSystemUtil,ProcUtilfromoshi-coretooshi-commonPlatformEnumfromoshipackage tooshi.utilpackage (permanent home — avoids split withoshipackage owned byoshi-core)SystemInfoHelperto main sources — static print helpers extracted fromSystemInfoTest, available tooshi-core-java25tests without test-jar complexityforbiddenapisconfirms zero native (JNA/FFM) violations across all 80 classesoshi-core
FileUtilbuffer methods (readNativeLongFromBuffer,readSizeTFromBuffer,readPointerFromBuffer,freeMemory) into newoshi.jna.util.FileUtilJNA; update all callersPlatform.isAIX/isLinux/isWindows/isSolarisJNA calls withPlatformEnumequivalents inUserGroupInfo,Who,ExecutingCommandOperatingSystemdefault method bodies (isElevated,getSessions,getDesktopWindows) toAbstractOperatingSystemoverridesoshi.PlatformEnumdelegating tooshi.util.PlatformEnumfor backward compatibilitypackage-info.javaduplicates foroshi.hardwareandoshi.software.osFileUtilTest: JNA buffer read tests moved toFileUtilJNATestoshi-core-java11
oshi-commonas a Maven dependency — its sources are compiled directly into this module, so having it as a separate jar on the module path caused theResolutionException--add-opens com.github.oshi/oshi.jna.util=org.junit.platform.commonstomodule-info.testforFileUtilJNATestoshi-core-java25
oshi-common-owned packages from the jarmodule-info.java: remove exports ofoshi-common-owned packages, addrequires transitive com.github.oshi.commonoshi.hardware/oshi.software.ospackages tooshi.ffmas standalone testsmodule-info.testto only openoshi.ffmandoshi.jna.utilNotes
oshi-coreintentionally retains the original bnd config — it bundles alloshi.*packages for backward compatibility with non-modular consumersoshi-core-java11is a to-be-removed module but must be maintained until the next major versionSummary by CodeRabbit
New Features
Bug Fixes
Chores
Tests