Skip to content

Create oshi-common module; annotations and most API classes - #3130

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:oshi-common
Apr 9, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:oshi-common

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Apr 8, 2026 •

Copy link
Copy Markdown
Member

Introduces a new oshi-common Maven module containing only classes with zero native dependencies, making them available to future FFM-only consumers without pulling in JNA.

Changes

New module: oshi-common

  • No JNA or FFM dependencies — only slf4j-api and standard Java
  • Automatic-Module-Name: com.github.oshi.common
  • Added as first entry in the parent reactor (before oshi-core) and as a
    dependency of oshi-core, oshi-core-java11, and oshi-core-java25

Moved from oshi-core → oshi-common (no API changes)

  • oshi.PlatformEnum
  • oshi.annotation.SuppressForbidden
  • oshi.annotation.concurrent — GuardedBy, Immutable, NotThreadSafe, ThreadSafe
  • oshi.hardware interfaces — Baseboard, ComputerSystem, Display, Firmware,
    GraphicsCard, GpuStats, GpuTicks, LogicalVolumeGroup, NetworkIF,
    PowerSource, Printer, Sensors, SoundCard, UsbDevice, VirtualMemory
  • oshi.software.os interfaces/classes — ApplicationInfo, FileSystem,
    InternetProtocolStats, NetworkParams, OSDesktopWindow, OSFileStore,
    OSService, OSSession

Stayed in oshi-core (deferred — have JNA or cross-module deps)

  • CentralProcessor, HWDiskStore, GlobalMemory, HWPartition, PhysicalMemory,
    HardwareAbstractionLayer — util/JNA deps in default method implementations
  • OperatingSystem, OSProcess, OSThread — driver references or shared State enum

JPMS Split Module Challenge

  • oshi-core-java11 and oshi-core-java25 can't reference the same package as in oshi-common because they have module descriptors, so we can't (yet) use requires com.github.oshi.common. For now we are still just adding the source folders of these projects to a singular build. Once we complete migration, the java11 module will go away and the ffm module will no longer use oshi-core source. oshi-core is not modular so is free to use the same package.
  • To ensure the new dependency remains native-code free, added native-forbidden-apis.txt banning JNA, FFM, and native library loading
    from oshi-common; enforced via forbiddenapis plugin in oshi-common/pom.xml

Next step (next PR in the series):

  • Split JNA usages out of util classes and move the remaining API interfaces/classes and JNA-free utils

Summary by CodeRabbit

  • New Features

    • Added oshi-common: a new shared JAR module exposing common hardware/OS interfaces and annotations.
  • Chores

    • Registered the new module in the multi-module build and wired core modules to depend on it.
    • Included package-level documentation and extended build/javadoc/source settings.
    • Added forbidden-API rules to restrict native/FFM usage.
    • Updated copyright year ranges and CI checkout/install steps.
  • Bug Fixes

    • Corrected a typo in OS desktop window documentation.

@dbwiddis
dbwiddis requested a review from rohan-coder02 April 8, 2026 23:20
@coderabbitai

coderabbitai Bot commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Added a new oshi-common Maven module (JAR, Automatic-Module-Name) containing JNA-free common APIs, package-level Javadocs, and annotations; wired oshi-common into reactor and core modules, added forbidden-API rules preventing native/FFM/JNA usage in that module, updated CI checkout and build steps, and appended a CHANGELOG entry for PR #3130.

Changes

Cohort / File(s) Summary
Parent & modules
pom.xml, oshi-common/pom.xml, oshi-core/pom.xml, oshi-core-java11/pom.xml, oshi-core-java25/pom.xml, CHANGELOG.md
Added oshi-common module to reactor and created its POM (jar, Automatic-Module-Name). Core modules now depend on oshi-common. Parent POM updated (spotless excludes). CHANGELOG: single bullet for PR #3130.
New module sources & docs
oshi-common/src/main/java/oshi/package-info.java, oshi-common/src/main/java/oshi/hardware/package-info.java, oshi-common/src/main/java/oshi/software/os/package-info.java, oshi-common/src/main/java/.../*.java
Added package-level Javadocs and license headers; many files updated only to refresh copyright year ranges; OSDesktopWindow removed an unused JNA import and fixed a typo.
API Javadoc tweak
oshi-common/src/main/java/oshi/PlatformEnum.java
Clarified Javadoc for getName(int) / getValue(int) to document osType as an ordinal matching com.sun.jna.Platform.getOSType(); no code changes.
Build/javadoc wiring
oshi-core-java11/pom.xml, oshi-core-java25/pom.xml, oshi-core/pom.xml
Added ${oshi.common.basedir} property, added oshi-common dependency, included oshi-common/src/main/java in additional sources and javadoc sourcepath.
Forbidden APIs config
config/native-forbidden-apis.txt
New forbidden-APIs rule set blocking com.sun.jna.**, java.lang.foreign.**, and native loading calls from oshi-common.
FFM import minor
oshi-core-java25/src/main/java/oshi/ffm/mac/MacSystem.java
Reordered static import of groupElement; no behavioral change.
CI workflows
.github/workflows/linux.yaml, .github/workflows/pr.yaml
Lint jobs changed to checkout full history (fetch-depth: 0) and added ./mvnw install -DskipTests -q step; forbiddenapis invocation adjusted.
Formatting config
pom.xml (parent) spotless blocks
Added excludes to avoid formatting files under **/target/**.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰
I hopped a module, neat and small,
Shared bits nibble-free for all,
Docs and rules in tidy rows,
No native crumbs where common code goes,
A carrot stash for builds that call! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly reflects the main objective: creating the oshi-common module with annotations and API classes moved from oshi-core.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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: 3

🤖 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/main/java/oshi/hardware/package-info.java`:
- Around line 2-7: Update the package-info header to match the new module name
and current year: in package-info.java change the copyright year range from
"2016-2022" to "2016-2026" (or current year) and change the Javadoc tag
"[oshi-core API]" to "[oshi-common API]" so the module name matches the file
location; keep the rest of the descriptive sentence intact (CPU, Memory,
Display, Disks, Network Interfaces, Power Sources, Sensors, and USB Devices) and
leave the SPDX line unchanged.

In `@oshi-common/src/main/java/oshi/package-info.java`:
- Around line 6-7: Update the package Javadoc in package-info.java to remove the
word “implementation” and rephrase the description to reflect that oshi-common
provides shared API/common contracts (e.g., “Provides a cross-platform common
API to retrieve Operating System and Hardware information…”), ensuring the rest
of the examples (OS version, memory, CPU, disk, devices, sensors) remain
unchanged.

In `@oshi-common/src/main/java/oshi/software/os/package-info.java`:
- Around line 2-7: Update the package Javadoc and header to reflect the module
name and current year range: change the copyright line in package-info.java from
"2016-2022" to "2016-2026" and replace the Javadoc phrase "[oshi-core API]" with
"[oshi-common API]". Ensure the rest of the descriptive text ("Provides
cross-platform implementation to retrieve OS, FileSystem, and Process
information") remains unchanged and keep the SPDX-License-Identifier intact.
🪄 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: cf761d66-a8ee-4e82-9be4-1abf12fe8fbe

📥 Commits

Reviewing files that changed from the base of the PR and between 849b7a3 and eb5b0fa.

📒 Files selected for processing (41)
  • CHANGELOG.md
  • oshi-common/pom.xml
  • oshi-common/src/main/java/oshi/PlatformEnum.java
  • oshi-common/src/main/java/oshi/annotation/SuppressForbidden.java
  • oshi-common/src/main/java/oshi/annotation/concurrent/GuardedBy.java
  • oshi-common/src/main/java/oshi/annotation/concurrent/Immutable.java
  • oshi-common/src/main/java/oshi/annotation/concurrent/NotThreadSafe.java
  • oshi-common/src/main/java/oshi/annotation/concurrent/ThreadSafe.java
  • oshi-common/src/main/java/oshi/annotation/concurrent/package-info.java
  • oshi-common/src/main/java/oshi/annotation/package-info.java
  • oshi-common/src/main/java/oshi/hardware/Baseboard.java
  • oshi-common/src/main/java/oshi/hardware/ComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/Display.java
  • oshi-common/src/main/java/oshi/hardware/Firmware.java
  • oshi-common/src/main/java/oshi/hardware/GpuStats.java
  • oshi-common/src/main/java/oshi/hardware/GpuTicks.java
  • oshi-common/src/main/java/oshi/hardware/GraphicsCard.java
  • oshi-common/src/main/java/oshi/hardware/LogicalVolumeGroup.java
  • oshi-common/src/main/java/oshi/hardware/NetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/PowerSource.java
  • oshi-common/src/main/java/oshi/hardware/Printer.java
  • oshi-common/src/main/java/oshi/hardware/Sensors.java
  • oshi-common/src/main/java/oshi/hardware/SoundCard.java
  • oshi-common/src/main/java/oshi/hardware/UsbDevice.java
  • oshi-common/src/main/java/oshi/hardware/VirtualMemory.java
  • oshi-common/src/main/java/oshi/hardware/package-info.java
  • oshi-common/src/main/java/oshi/package-info.java
  • oshi-common/src/main/java/oshi/software/os/ApplicationInfo.java
  • oshi-common/src/main/java/oshi/software/os/FileSystem.java
  • oshi-common/src/main/java/oshi/software/os/InternetProtocolStats.java
  • oshi-common/src/main/java/oshi/software/os/NetworkParams.java
  • oshi-common/src/main/java/oshi/software/os/OSDesktopWindow.java
  • oshi-common/src/main/java/oshi/software/os/OSFileStore.java
  • oshi-common/src/main/java/oshi/software/os/OSService.java
  • oshi-common/src/main/java/oshi/software/os/OSSession.java
  • oshi-common/src/main/java/oshi/software/os/package-info.java
  • oshi-core-java11/pom.xml
  • oshi-core-java25/pom.xml
  • oshi-core-java25/src/main/java/oshi/ffm/mac/MacSystem.java
  • oshi-core/pom.xml
  • 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). (6)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, macos-latest
  • GitHub Check: Test JDK 25, windows-latest
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 11, macos-latest
  • GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (9)
📓 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:47.644Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3112
File: oshi-core/src/main/java/oshi/PlatformEnum.java:63-66
Timestamp: 2026-04-03T18:44:46.910Z
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.
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:43.357Z
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.
📚 Learning: 2026-04-05T15:37:16.042Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxUsbDeviceFFM.java:59-65
Timestamp: 2026-04-05T15:37:16.042Z
Learning: In OSHI's Linux USB device implementations (LinuxUsbDeviceFFM, and the JNA equivalent), when `getUsbDevices(boolean tree)` is called with `tree=false`, the returned flat list intentionally **includes** controller nodes — it does not exclude them. The existing Javadoc that says "returns a flat list excluding controllers" is incorrect. Do not flag the implementation for including controllers in flat mode; instead, flag only the Javadoc if it claims controllers are excluded.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/UsbDevice.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, 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/UsbDevice.java
  • oshi-common/src/main/java/oshi/software/os/FileSystem.java
  • oshi-common/src/main/java/oshi/software/os/NetworkParams.java
  • oshi-common/src/main/java/oshi/hardware/LogicalVolumeGroup.java
  • oshi-common/src/main/java/oshi/software/os/ApplicationInfo.java
  • oshi-common/src/main/java/oshi/hardware/Display.java
  • oshi-common/src/main/java/oshi/hardware/Firmware.java
  • oshi-common/src/main/java/oshi/hardware/SoundCard.java
  • oshi-common/src/main/java/oshi/software/os/OSService.java
  • oshi-common/src/main/java/oshi/hardware/ComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/Baseboard.java
  • oshi-common/src/main/java/oshi/hardware/VirtualMemory.java
  • oshi-common/src/main/java/oshi/hardware/PowerSource.java
  • oshi-common/src/main/java/oshi/software/os/InternetProtocolStats.java
  • oshi-common/src/main/java/oshi/annotation/SuppressForbidden.java
  • oshi-core-java11/pom.xml
  • oshi-common/src/main/java/oshi/hardware/NetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/Sensors.java
  • oshi-common/src/main/java/oshi/software/os/OSSession.java
  • oshi-common/src/main/java/oshi/package-info.java
  • oshi-common/src/main/java/oshi/hardware/package-info.java
  • oshi-common/src/main/java/oshi/software/os/package-info.java
  • oshi-common/src/main/java/oshi/PlatformEnum.java
  • oshi-common/src/main/java/oshi/software/os/OSDesktopWindow.java
  • oshi-core-java25/pom.xml
  • CHANGELOG.md
  • oshi-core/pom.xml
  • oshi-common/pom.xml
📚 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/UsbDevice.java
  • oshi-common/src/main/java/oshi/software/os/FileSystem.java
  • oshi-common/src/main/java/oshi/software/os/NetworkParams.java
  • oshi-common/src/main/java/oshi/hardware/LogicalVolumeGroup.java
  • oshi-common/src/main/java/oshi/software/os/ApplicationInfo.java
  • oshi-common/src/main/java/oshi/hardware/Display.java
  • oshi-common/src/main/java/oshi/hardware/Firmware.java
  • oshi-common/src/main/java/oshi/hardware/SoundCard.java
  • oshi-common/src/main/java/oshi/software/os/OSService.java
  • oshi-common/src/main/java/oshi/hardware/ComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/Baseboard.java
  • oshi-common/src/main/java/oshi/hardware/VirtualMemory.java
  • oshi-common/src/main/java/oshi/hardware/PowerSource.java
  • oshi-common/src/main/java/oshi/software/os/InternetProtocolStats.java
  • oshi-common/src/main/java/oshi/annotation/SuppressForbidden.java
  • oshi-core-java11/pom.xml
  • oshi-common/src/main/java/oshi/hardware/NetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/Sensors.java
  • oshi-common/src/main/java/oshi/software/os/OSSession.java
  • oshi-common/src/main/java/oshi/package-info.java
  • oshi-common/src/main/java/oshi/hardware/package-info.java
  • oshi-common/src/main/java/oshi/software/os/package-info.java
  • oshi-core-java25/pom.xml
  • CHANGELOG.md
  • oshi-core/pom.xml
  • oshi-common/pom.xml
  • pom.xml
📚 Learning: 2026-04-05T16:15:03.230Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxLogicalVolumeGroupJNA.java:95-97
Timestamp: 2026-04-05T16:15:03.230Z
Learning: In `LinuxLogicalVolumeGroupJNA.getLogicalVolumeGroups()` (oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxLogicalVolumeGroupJNA.java), `physicalVolumesMap.get(e.getKey())` in the final stream mapping cannot return null: both `logicalVolumesMap` and `physicalVolumesMap` are populated via `computeIfAbsent` inside the same conditional block (`!Util.isBlank(vgName) && !Util.isBlank(lvName)`), so every VG key in `logicalVolumesMap` is guaranteed to have a corresponding entry in `physicalVolumesMap`. Do not flag this `.get()` call as a potential null-return issue. The FFM version uses `getOrDefault` as extra defensiveness, not because null is possible here.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/LogicalVolumeGroup.java
📚 Learning: 2026-04-08T00:58:07.212Z
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:07.212Z
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-common/src/main/java/oshi/hardware/PowerSource.java
  • oshi-common/src/main/java/oshi/hardware/package-info.java
📚 Learning: 2026-04-03T18:43:50.370Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3112
File: oshi-core/src/main/java/oshi/PlatformEnum.java:99-100
Timestamp: 2026-04-03T18:43:50.370Z
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-common/src/main/java/oshi/software/os/package-info.java
  • oshi-common/src/main/java/oshi/PlatformEnum.java
📚 Learning: 2026-04-03T18:44:46.910Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3112
File: oshi-core/src/main/java/oshi/PlatformEnum.java:63-66
Timestamp: 2026-04-03T18:44:46.910Z
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/PlatformEnum.java
📚 Learning: 2026-04-08T17:30:08.833Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3127
File: CHANGELOG.md:3-3
Timestamp: 2026-04-08T17:30:08.833Z
Learning: In the oshi/oshi repository's `CHANGELOG.md`, the standard layout uses `#` (h1) for release version headers and `#####` (h5) for subsection headers such as "New Features" and "Bug fixes / Improvements". This intentional heading level skip is the project's established convention and should not be flagged as a markdownlint MD001 violation.

Applied to files:

  • CHANGELOG.md
🔇 Additional comments (32)
oshi-common/src/main/java/oshi/software/os/FileSystem.java (1)

2-2: Header year update looks good.

This is a non-functional metadata update and does not affect API behavior or compatibility.

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

2-2: Header year-range update looks good.

Non-functional metadata change only; no API/behavior impact.

oshi-common/src/main/java/oshi/annotation/concurrent/Immutable.java (1)

2-2: LGTM! Copyright year updated appropriately.

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

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

2-2: LGTM! Copyright year updated.

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

oshi-common/src/main/java/oshi/annotation/concurrent/NotThreadSafe.java (1)

2-2: Header-only change looks good.

Copyright year update is non-functional and safe.

oshi-common/src/main/java/oshi/annotation/SuppressForbidden.java (1)

2-2: LGTM — non-functional metadata update only.

No functional/API changes introduced.

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

2-2: Looks good — documentation header refresh only.

No code-path, contract, or API surface changes.

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

2-2: Approved.

This is a harmless copyright-year update.

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

2-2: LGTM.

Header year bump only; no implementation/API risk.

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

2-2: No concerns here.

Change is documentation metadata only.

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

2-2: Approved — safe header update.

No logic or API changes detected.

oshi-common/src/main/java/oshi/annotation/concurrent/GuardedBy.java (1)

2-2: Looks good.

Header year-range update is clean and non-breaking.

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

2-2: Header-only change looks good.

Line 2 is a non-functional copyright update and aligns with the module migration work.

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

2-2: No issues here.

Line 2 is a metadata/header update only.

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

2-2: LGTM.

Line 2 is a straightforward non-functional header refresh.

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

2-2: Looks good.

Line 2 is a harmless header update.

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

2-2: Header update is fine.

Line 2 is non-functional and consistent.


39-40: Javadoc adjustment is appropriate.

Line 39 improves wording and keeps the Windows handle guidance usable without introducing a code dependency in this class.

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

2-2: All good on this segment.

Line 2 is a non-functional header refresh only.

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

2-2: Header update looks good.

No functional or API-impacting change here; this is a clean metadata-only update.

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

2-2: LGTM on header-year update.

Purely non-functional change.

oshi-common/src/main/java/oshi/annotation/concurrent/ThreadSafe.java (1)

2-2: Looks good.

Header-only update with no code impact.

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

2-2: Header update is clean.

No behavioral change introduced.

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

2-2: No concerns on this change.

Metadata-only update, functionally safe.

CHANGELOG.md (1)

4-4: Changelog entry is accurate and well-formatted.

This clearly captures the module split intent and matches the existing release-note style.

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

43-47: Dependency addition looks correct.

Adding com.github.oshi:oshi-common here is the right wiring for the new shared JNA-free API module.

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

7-7: Import reorder is fine.

No functional change introduced.

pom.xml (1)

45-45: Reactor ordering is correct for the new shared module.

Adding oshi-common at Line 45 before oshi-core aligns build order with the new dependency flow.

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

28-32: Dependency wiring to oshi-common looks correct.

This addition matches the API extraction and keeps oshi-core-java25 aligned with the new module layout.

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

122-126: Javadoc clarification is accurate and useful.

The updated wording clearly documents the ordinal contract against Platform.getOSType() return values.

Also applies to: 133-137

oshi-core/pom.xml (1)

34-38: oshi-core dependency on oshi-common is correctly added.

This is the expected linkage for moved public API types and keeps module boundaries consistent.

oshi-common/pom.xml (1)

1-59: New oshi-common module POM is well-structured.

Artifact metadata, minimal dependencies, and Automatic-Module-Name are set appropriately for the extracted common API module.

@dbwiddis
dbwiddis force-pushed the oshi-common branch 2 times, most recently from 6d8a337 to 508d1db Compare April 9, 2026 01:14
@codecov

codecov Bot commented Apr 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.50%. Comparing base (e1554d7) to head (99194ad).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3130      +/-   ##
==========================================
+ Coverage   66.32%   67.50%   +1.17%     
==========================================
  Files          37       37              
  Lines        2034     2034              
  Branches      340      340              
==========================================
+ Hits         1349     1373      +24     
+ Misses        567      541      -26     
- Partials      118      120       +2     

☔ 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.

interfaces

- New oshi-common Maven module with no JNA/FFM dependencies (JDK 8
compatible)
- Moved annotations (SuppressForbidden, concurrent) and JNA-free
hardware/OS
  interfaces from oshi-core to oshi-common
- oshi-core, oshi-core-java11, oshi-core-java25 depend on oshi-common
- oshi-core-java11 and oshi-core-java25 patch in oshi-common sources via
  build-helper-maven-plugin to avoid JPMS split-package issues
(temporary,
  remove once FFM transition is complete)
- Added native-forbidden-apis.txt banning JNA, FFM, and native library
loading
  from oshi-common; enforced via forbiddenapis plugin in
oshi-common/pom.xml
- Spotless target/ exclusion added to prevent stale jacoco.xml failures

@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 (1)
oshi-core-java11/pom.xml (1)

127-127: Consider adding a TODO comment for consistency with oshi-core-java25.

The oshi-core-java25/pom.xml includes a clarifying comment explaining this dual-inclusion pattern is temporary:

<!-- TODO: Remove oshi-core and oshi-common source paths once FFM transition is complete -->

Adding a similar comment here would help future maintainers understand this is intentional for JPMS constraints and not permanent.

📝 Suggested documentation addition
                         <configuration>
                             <sources>
+                                <!-- Copy source files from oshi-core and oshi-common -->
+                                <!-- TODO: Remove oshi-core and oshi-common source paths once FFM transition is complete -->
                                 <source>${oshi.core.basedir}/src/main/java</source>
                                 <source>${oshi.common.basedir}/src/main/java</source>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-core-java11/pom.xml` at line 127, Add a TODO comment adjacent to the
<source>${oshi.common.basedir}/src/main/java</source> entry in the pom.xml
mirroring the note in oshi-core-java25 (e.g., "TODO: Remove oshi-core and
oshi-common source paths once FFM transition is complete") so maintainers know
this dual-inclusion is intentional and temporary due to JPMS/FFM constraints;
update the pom.xml near that <source> element (and any sibling <source> entries)
to include the clarifying comment.
🤖 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-core-java11/pom.xml`:
- Line 127: Add a TODO comment adjacent to the
<source>${oshi.common.basedir}/src/main/java</source> entry in the pom.xml
mirroring the note in oshi-core-java25 (e.g., "TODO: Remove oshi-core and
oshi-common source paths once FFM transition is complete") so maintainers know
this dual-inclusion is intentional and temporary due to JPMS/FFM constraints;
update the pom.xml near that <source> element (and any sibling <source> entries)
to include the clarifying comment.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2832edfc-b3a7-42aa-903a-40c79a1f0622

📥 Commits

Reviewing files that changed from the base of the PR and between 88402fd and 99194ad.

📒 Files selected for processing (44)
  • .github/workflows/linux.yaml
  • .github/workflows/pr.yaml
  • CHANGELOG.md
  • config/native-forbidden-apis.txt
  • oshi-common/pom.xml
  • oshi-common/src/main/java/oshi/PlatformEnum.java
  • oshi-common/src/main/java/oshi/annotation/SuppressForbidden.java
  • oshi-common/src/main/java/oshi/annotation/concurrent/GuardedBy.java
  • oshi-common/src/main/java/oshi/annotation/concurrent/Immutable.java
  • oshi-common/src/main/java/oshi/annotation/concurrent/NotThreadSafe.java
  • oshi-common/src/main/java/oshi/annotation/concurrent/ThreadSafe.java
  • oshi-common/src/main/java/oshi/annotation/concurrent/package-info.java
  • oshi-common/src/main/java/oshi/annotation/package-info.java
  • oshi-common/src/main/java/oshi/hardware/Baseboard.java
  • oshi-common/src/main/java/oshi/hardware/ComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/Display.java
  • oshi-common/src/main/java/oshi/hardware/Firmware.java
  • oshi-common/src/main/java/oshi/hardware/GpuStats.java
  • oshi-common/src/main/java/oshi/hardware/GpuTicks.java
  • oshi-common/src/main/java/oshi/hardware/GraphicsCard.java
  • oshi-common/src/main/java/oshi/hardware/LogicalVolumeGroup.java
  • oshi-common/src/main/java/oshi/hardware/NetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/PowerSource.java
  • oshi-common/src/main/java/oshi/hardware/Printer.java
  • oshi-common/src/main/java/oshi/hardware/Sensors.java
  • oshi-common/src/main/java/oshi/hardware/SoundCard.java
  • oshi-common/src/main/java/oshi/hardware/UsbDevice.java
  • oshi-common/src/main/java/oshi/hardware/VirtualMemory.java
  • oshi-common/src/main/java/oshi/hardware/package-info.java
  • oshi-common/src/main/java/oshi/package-info.java
  • oshi-common/src/main/java/oshi/software/os/ApplicationInfo.java
  • oshi-common/src/main/java/oshi/software/os/FileSystem.java
  • oshi-common/src/main/java/oshi/software/os/InternetProtocolStats.java
  • oshi-common/src/main/java/oshi/software/os/NetworkParams.java
  • oshi-common/src/main/java/oshi/software/os/OSDesktopWindow.java
  • oshi-common/src/main/java/oshi/software/os/OSFileStore.java
  • oshi-common/src/main/java/oshi/software/os/OSService.java
  • oshi-common/src/main/java/oshi/software/os/OSSession.java
  • oshi-common/src/main/java/oshi/software/os/package-info.java
  • oshi-core-java11/pom.xml
  • oshi-core-java25/pom.xml
  • oshi-core-java25/src/main/java/oshi/ffm/mac/MacSystem.java
  • oshi-core/pom.xml
  • pom.xml
✅ Files skipped from review due to trivial changes (32)
  • oshi-common/src/main/java/oshi/hardware/Display.java
  • oshi-common/src/main/java/oshi/annotation/concurrent/Immutable.java
  • oshi-common/src/main/java/oshi/hardware/NetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/ComputerSystem.java
  • oshi-common/src/main/java/oshi/annotation/concurrent/NotThreadSafe.java
  • oshi-common/src/main/java/oshi/hardware/PowerSource.java
  • oshi-common/src/main/java/oshi/hardware/Firmware.java
  • oshi-common/src/main/java/oshi/software/os/FileSystem.java
  • oshi-common/src/main/java/oshi/hardware/Sensors.java
  • oshi-common/src/main/java/oshi/annotation/concurrent/GuardedBy.java
  • oshi-common/src/main/java/oshi/annotation/concurrent/ThreadSafe.java
  • oshi-common/src/main/java/oshi/hardware/UsbDevice.java
  • oshi-common/src/main/java/oshi/software/os/NetworkParams.java
  • oshi-common/src/main/java/oshi/software/os/ApplicationInfo.java
  • oshi-common/src/main/java/oshi/software/os/OSSession.java
  • oshi-common/src/main/java/oshi/annotation/SuppressForbidden.java
  • oshi-common/src/main/java/oshi/hardware/VirtualMemory.java
  • oshi-common/src/main/java/oshi/software/os/OSService.java
  • oshi-common/src/main/java/oshi/hardware/Baseboard.java
  • oshi-common/src/main/java/oshi/software/os/InternetProtocolStats.java
  • oshi-core-java25/src/main/java/oshi/ffm/mac/MacSystem.java
  • oshi-common/src/main/java/oshi/hardware/SoundCard.java
  • oshi-common/src/main/java/oshi/hardware/package-info.java
  • oshi-common/src/main/java/oshi/software/os/OSDesktopWindow.java
  • oshi-common/src/main/java/oshi/package-info.java
  • oshi-core/pom.xml
  • oshi-common/src/main/java/oshi/hardware/LogicalVolumeGroup.java
  • oshi-common/src/main/java/oshi/software/os/package-info.java
  • CHANGELOG.md
  • config/native-forbidden-apis.txt
  • oshi-common/pom.xml
  • oshi-common/src/main/java/oshi/PlatformEnum.java
🚧 Files skipped from review as they are similar to previous changes (3)
  • .github/workflows/pr.yaml
  • .github/workflows/linux.yaml
  • oshi-core-java25/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). (8)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, windows-latest
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 25, macos-latest
  • GitHub Check: Test JDK 11, 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-java11/pom.xml
  • pom.xml
📚 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-java11/pom.xml
  • pom.xml
🔇 Additional comments (6)
oshi-core-java11/pom.xml (4)

20-20: LGTM!

Property definition follows the established pattern from oshi.core.basedir.


44-48: LGTM!

Dependency declaration is correct and follows the same pattern used in oshi-core/pom.xml.


150-150: LGTM!

The javadoc sourcepath correctly includes all three source directories needed for complete documentation generation.


162-162: LGTM!

Reporting configuration mirrors the build configuration, maintaining consistency.

pom.xml (2)

45-45: LGTM!

Correctly positions oshi-common as the first module in the reactor, ensuring it builds before dependent modules (oshi-core, etc.).


475-491: LGTM!

Adding **/target/** excludes to both format blocks prevents spotless from attempting to format generated/build artifacts, which is the correct behavior.

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