Repository navigation
Move macOS Hardware superclasses to oshi-common - #3146
Conversation
|
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 (26)
💤 Files with no reviewable changes (1)
✅ Files skipped from review due to trivial changes (10)
🚧 Files skipped from review as they are similar to previous changes (10)
📜 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). (8)
🧰 Additional context used🧠 Learnings (4)📓 Common learnings📚 Learning: 2026-04-06T04:45:47.644ZApplied to files:
📚 Learning: 2026-04-03T02:07:47.621ZApplied to files:
📚 Learning: 2026-04-06T21:48:11.921ZApplied to files:
🔇 Additional comments (7)
📝 WalkthroughWalkthroughExtracted macOS hardware superclass logic into Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3146 +/- ##
============================================
+ Coverage 61.91% 62.21% +0.30%
Complexity 12 12
============================================
Files 39 39
Lines 2329 2329
Branches 407 407
============================================
+ Hits 1442 1449 +7
+ Misses 777 770 -7
Partials 110 110 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacLogicalVolumeGroup.java (1)
69-71:⚠️ Potential issue | 🟡 MinorPotential null passed to constructor when no physical volumes exist for a volume group.
If
diskutil cs listoutput contains a logical volume group with logical volumes but no physical volumes listed,physicalVolumesMap.get(e.getKey())will returnnull, which is then passed to theMacLogicalVolumeGroupconstructor. Consider usinggetOrDefaultfor defensive handling:🛡️ Suggested fix
return logicalVolumesMap.entrySet().stream() - .map(e -> new MacLogicalVolumeGroup(e.getKey(), e.getValue(), physicalVolumesMap.get(e.getKey()))) + .map(e -> new MacLogicalVolumeGroup(e.getKey(), e.getValue(), + physicalVolumesMap.getOrDefault(e.getKey(), Collections.emptySet()))) .collect(Collectors.toList());🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacLogicalVolumeGroup.java` around lines 69 - 71, The stream mapping can pass a null physical volume list into the MacLogicalVolumeGroup constructor when a group has logical volumes but no physical volumes; change the mapping to use physicalVolumesMap.getOrDefault(e.getKey(), Collections.emptyList()) (or another appropriate non-null default) so that physicalVolumesMap lookup never returns null for MacLogicalVolumeGroup construction; update the lambda that references logicalVolumesMap.entrySet().stream() and the call to new MacLogicalVolumeGroup(...) accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In
`@oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacLogicalVolumeGroup.java`:
- Around line 69-71: The stream mapping can pass a null physical volume list
into the MacLogicalVolumeGroup constructor when a group has logical volumes but
no physical volumes; change the mapping to use
physicalVolumesMap.getOrDefault(e.getKey(), Collections.emptyList()) (or another
appropriate non-null default) so that physicalVolumesMap lookup never returns
null for MacLogicalVolumeGroup construction; update the lambda that references
logicalVolumesMap.entrySet().stream() and the call to new
MacLogicalVolumeGroup(...) accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d740db57-8949-4e5a-85ec-70cfa7337f4f
📒 Files selected for processing (25)
CHANGELOG.mdconfig/checkstyle-suppressions.xmloshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGlobalMemory.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGraphicsCard.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacHardwareAbstractionLayer.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacLogicalVolumeGroup.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacUsbDevice.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacVirtualMemory.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacBaseboardFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacComputerSystemFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryFFM.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacBaseboardJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacComputerSystemJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacSensorsJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryJNA.java
💤 Files with no reviewable changes (1)
- config/checkstyle-suppressions.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). (9)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Analyze (java)
- GitHub Check: Test JDK 11, windows-latest
- GitHub Check: Test JDK 25, windows-latest
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 11, macos-latest
- GitHub Check: Test JDK 25, macos-latest
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
🧰 Additional context used
🧠 Learnings (13)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:51.516Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.
📚 Learning: 2026-04-06T04:45:51.516Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:51.516Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.
Applied to files:
oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerFFM.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacLogicalVolumeGroup.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacVirtualMemory.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacComputerSystemFFM.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacUsbDevice.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacHardwareAbstractionLayer.javaCHANGELOG.mdoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGlobalMemory.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGraphicsCard.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/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerFFM.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryJNA.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacLogicalVolumeGroup.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacVirtualMemory.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacComputerSystemFFM.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacUsbDevice.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGlobalMemory.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacComputerSystemJNA.java
📚 Learning: 2026-04-03T02:07:47.621Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3110
File: oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHWDiskStoreFFM.java:119-121
Timestamp: 2026-04-03T02:07:47.621Z
Learning: In OSHI’s Java FFM/API implementation classes (e.g., *FFM.java) that implement/override `updateAttributes()`, preserve the intentional failure-handling pattern: catch `Throwable` and return `false` without logging. `updateAttributes()` is a public API whose contract is to signal failure via the boolean return value, and callers rely on that return value (so emitting logs from this path is not desired and should not be introduced during review unless the method contract changes).
Applied to files:
oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacComputerSystemFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacBaseboardFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryFFM.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-java25/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerFFM.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryJNA.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacLogicalVolumeGroup.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacComputerSystemFFM.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacUsbDevice.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacBaseboardFFM.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacComputerSystemJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacBaseboardJNA.java
📚 Learning: 2026-04-06T21:48:09.616Z
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:09.616Z
Learning: In `oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.java` and `MacUsbDeviceFFM.java`, treat `id = 0L` as an intentional sentinel when `device.getParentEntry(IOSERVICE)` returns null. This catch-all value groups devices whose controller cannot be identified (even though that edge case is expected not to occur). Do not review it as a bug, do not suggest skipping those devices, and do not propose moving them to the top level without controller context—this design explicitly avoids silently dropping orphaned devices and preserves controller-grouping behavior.
Applied to files:
oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.java
📚 Learning: 2026-04-06T22:30:07.083Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3122
File: oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.java:215-234
Timestamp: 2026-04-06T22:30:07.083Z
Learning: In `oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.java`, the `found` flag in `getControllerIdByLocation` is intentionally set to `true` as soon as either `vendor-id` or `device-id` is found in a matching service's parent. This is a deliberate design choice: a partial match (one of the two IDs) is preferred over continuing to iterate, because iterating further risks pairing IDs from two different and potentially mismatched services. Do not flag this as a bug or suggest splitting into separate `foundVendor`/`foundProduct` flags.
Applied to files:
oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceFFM.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacUsbDevice.java
📚 Learning: 2026-04-05T15:37:17.867Z
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:17.867Z
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-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceFFM.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacUsbDevice.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/platform/mac/MacUsbDeviceJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacSensorsJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacComputerSystemJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacBaseboardJNA.java
📚 Learning: 2026-04-05T16:15:06.124Z
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:06.124Z
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/common/platform/mac/MacLogicalVolumeGroup.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-common/src/main/java/oshi/hardware/common/platform/mac/MacUsbDevice.java
📚 Learning: 2026-04-08T17:30:11.929Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3127
File: CHANGELOG.md:3-3
Timestamp: 2026-04-08T17:30:11.929Z
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
📚 Learning: 2026-04-03T02:07:49.467Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3110
File: oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHWDiskStoreFFM.java:119-121
Timestamp: 2026-04-03T02:07:49.467Z
Learning: In `oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHWDiskStoreFFM.java` (and similar FFM/API implementations in OSHI), the `updateAttributes()` method intentionally uses `catch (Throwable e) { return false; }` without logging. This is by design: `updateAttributes()` is a public API method whose contract is to return `false` on failure; callers consume the boolean and would never see log output, so adding a log statement is not desired.
Applied to files:
oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGlobalMemory.java
🔇 Additional comments (23)
CHANGELOG.md (1)
21-22: Looks good — changelog entries are accurate and consistent with section style.
Both additions clearly document scope and follow existing formatting conventions.Based on learnings:
CHANGELOG.mdintentionally uses#for release headers and#####for subsection headers.oshi-core/src/main/java/oshi/hardware/platform/mac/MacSensorsJNA.java (1)
7-86: LGTM!The class rename to
MacSensorsJNAaligns with the PR's JNA/FFM naming convention. The static imports fromSmcUtilimprove readability, and the SMC connection handling with try-finally blocks ensures proper resource cleanup.oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java (1)
1-45: LGTM!Clean implementation of the template method pattern. The memoized
Quartetcorrectly caches the platform data once, and the@Immutableannotation is appropriate given the indefinite memoization. The abstractplatformExpert()method provides a clear contract for JNA/FFM subclasses.oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.java (1)
1-44: LGTM!Mirrors the
MacComputerSystempattern with memoizedQuartetstorage. The abstractqueryPlatform()contract is clear, and the getter implementations correctly map quartet elements (A→manufacturer, B→model, C→version, D→serialNumber) matching both JNA and FFM subclass implementations.oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacBaseboardFFM.java (1)
11-62: LGTM!The refactoring correctly delegates memoization to the superclass while providing the FFM-specific
queryPlatform()implementation. The byte array to String conversion with.trim().replace("\0", "")correctly handles null-terminated C strings, and theQuartetordering matches the superclass contract.oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacComputerSystemFFM.java (1)
13-60: LGTM!The refactoring aligns with the PR's architecture. The
platformExpert()override provides FFM-specific IOKit access while leveraging the superclass for memoization and getter implementations. Factory methods correctly return FFM subclasses (MacFirmwareFFM,MacBaseboardFFM).oshi-core/src/main/java/oshi/hardware/platform/mac/MacBaseboardJNA.java (1)
14-64: LGTM!The JNA implementation correctly fulfills the
MacBaseboardcontract. The fallback chain formodel(board-id → model-number) andserialNumber(mlb-serial-number → IOPlatformSerialNumber) provides robust data retrieval. TheQuartetordering matches the superclass getter expectations.oshi-core/src/main/java/oshi/hardware/platform/mac/MacComputerSystemJNA.java (1)
16-61: LGTM!The refactoring correctly delegates caching to the superclass while implementing JNA-specific IOKit access. The
platformExpert()method provides the quartet data, and factory methods correctly return JNA subclasses (MacFirmware,MacBaseboardJNA).oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGraphicsCard.java (1)
5-92: LGTM!Excellent refactoring using the factory pattern with functional interfaces. The
GraphicsCardFactoryandSysctlLonginterfaces enable clean dependency injection, allowing JNA and FFM subclasses to provide their respectivesysctlimplementations while sharing thesystem_profilerparsing logic. TheresolveVramfallback tohw.memsizefor Apple Silicon correctly handles shared memory architecture.oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardFFM.java (1)
11-12: LGTM! Clean refactoring to delegate parsing logic to the common superclass.The class correctly extends
MacGraphicsCardfromoshi-commonand delegates toparseGraphicsCards()with appropriate method references. TheMacGraphicsCardFFM::newfactory matches theGraphicsCardFactoryinterface signature, andSysctlUtilFFM::sysctlmatches theSysctlLongfunctional interface.Also applies to: 19-19, 30-31
oshi-core/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardJNA.java (1)
1-33: LGTM! Well-structured JNA implementation mirroring the FFM variant.The new
MacGraphicsCardJNAclass correctly:
- Extends the common
MacGraphicsCardsuperclass- Uses JNA-specific utilities (
SysctlUtil,MacGpuStats) rather than FFM variants- Delegates parsing to
parseGraphicsCards()with appropriate method referencesThe implementation maintains consistency with
MacGraphicsCardFFMwhile using the JNA stack.oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerFFM.java (1)
15-15: LGTM! Import updates align with the package restructuring.The import changes correctly reflect the move of
MacHardwareAbstractionLayertooshi.hardware.common.platform.mac. The class properly extends the abstract base and implementsgetPrinters()locally (since it was removed from the superclass as per the PR objectives).Also applies to: 22-22
oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.java (1)
25-25: LGTM! Import updated to reference the relocatedMacUsbDevicetype.The import change aligns with the migration of
MacUsbDevicetooshi.hardware.common.platform.mac. No functional changes in this file.oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryFFM.java (1)
2-2: LGTM! Import reorganization and copyright update.The changes correctly:
- Update the copyright year range
- Reorganize imports with static imports grouped at the top
- Add the import for
MacVirtualMemoryfrom the new common package locationNo functional changes to the swap/VM stat query logic.
Also applies to: 7-21
oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceFFM.java (1)
29-29: LGTM! Import updated for the relocatedMacUsbDevicetype.The import change aligns with the migration of
MacUsbDevicetooshi.hardware.common.platform.mac. No functional changes in this file.oshi-core/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryJNA.java (1)
2-2: LGTM! Import reorganization and copyright update.The changes correctly:
- Update the copyright year range
- Reorganize imports (JNA import moved after SLF4J)
- Add the import for
MacVirtualMemoryfrom the new common package locationNo functional changes to the swap/VM stat query logic.
Also applies to: 9-13
oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacHardwareAbstractionLayer.java (1)
5-5: LGTM! Abstract base class properly restructured for oshi-common.The changes correctly:
- Move the package to
oshi.hardware.common.platform.mac- Make the class
abstract(appropriate since it's now a template requiring subclass implementation)- Remove
getPrinters()(JNA subclass providesUnixPrinter.getPrinters(), FFM subclass providesCupsPrinter.getPrinters())The remaining
getLogicalVolumeGroups()andgetSoundCards()methods are pure Java implementations suitable for sharing across JNA/FFM variants.Also applies to: 18-18
oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryFFM.java (1)
54-67: LGTM!The method rename from
host_page_size()toqueryPageSize()and the fallback value change to4096Lcorrectly align with the documented contract in the abstractMacGlobalMemorysuperclass. The error logging before returning the fallback provides useful diagnostic information.oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacVirtualMemory.java (1)
20-35: LGTM!The visibility changes (
public abstractclass,protectedconstructor) correctly establish the template method pattern for FFM/JNA subclasses to extend from different packages. The abstract method declarations at lines 67-69 properly define the extension points.oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacUsbDevice.java (1)
5-5: LGTM!Package relocation to
oshi.hardware.common.platform.macis consistent with the migration pattern, and the Javadoc update correctly references the fully qualifiedMacUsbDeviceJNAclass name.oshi-core/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryJNA.java (1)
44-53: LGTM!The
queryPageSize()implementation correctly follows the abstract contract: attempts native call, logs error with JNA error code on failure, and returns the documented4096Lfallback. The error logging withNative.getLastError()is particularly useful for debugging native call failures.oshi-core/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerJNA.java (1)
30-33: LGTM!Factory methods correctly return JNA-backed implementations (
MacComputerSystemJNA,MacSensorsJNA), and the newgetPrinters()override properly restores the printer functionality that was removed from the common superclass.oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGlobalMemory.java (1)
121-127: LGTM!The abstract
queryPageSize()method with documented fallback contract of4096Lcleanly defines the template method pattern. This also fixes the previous typo where the fallback was4098Linstead of the correct4096L(standard page size). Both JNA and FFM implementations correctly adhere to this contract.
989fdda to
5659a7c
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryFFM.java (1)
55-66: Include the Mach status code in the failure log.Line 65 logs a generic failure, but Line 58 already has the non-zero
host_page_sizeresult. Including that code would make page-size lookup failures easier to diagnose without changing behavior.♻️ Possible tweak
`@Override` protected long queryPageSize() { + int result = -1; try (Arena arena = Arena.ofConfined()) { MemorySegment pageSize = arena.allocate(JAVA_LONG); - int result = MacSystemFunctions.host_page_size(mach_host_self(), pageSize); + result = MacSystemFunctions.host_page_size(mach_host_self(), pageSize); if (result == 0) { return pageSize.get(JAVA_LONG, 0); } } catch (Throwable t) { // IGNORED } - LOG.error("Failed to get host page size."); + LOG.error("Failed to get host page size. kern_return_t={}", result); return 4096L; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryFFM.java` around lines 55 - 66, In queryPageSize(), when MacSystemFunctions.host_page_size returns a non-zero result, include that Mach status code in the failure log; update the LOG.error call (in method queryPageSize) to log the integer variable result (and optional context like "host_page_size returned") so failures show the Mach status code while preserving the existing return behavior.
🤖 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-java25/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryFFM.java`:
- Around line 55-66: In queryPageSize(), when MacSystemFunctions.host_page_size
returns a non-zero result, include that Mach status code in the failure log;
update the LOG.error call (in method queryPageSize) to log the integer variable
result (and optional context like "host_page_size returned") so failures show
the Mach status code while preserving the existing return behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4189fe3e-b8b2-4d04-ac2d-8dc299bda9b8
📒 Files selected for processing (25)
CHANGELOG.mdconfig/checkstyle-suppressions.xmloshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGlobalMemory.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGraphicsCard.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacHardwareAbstractionLayer.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacLogicalVolumeGroup.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacUsbDevice.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacVirtualMemory.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacBaseboardFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacComputerSystemFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryFFM.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacBaseboardJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacComputerSystemJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacSensorsJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryJNA.java
💤 Files with no reviewable changes (1)
- config/checkstyle-suppressions.xml
✅ Files skipped from review due to trivial changes (8)
- oshi-core/src/main/java/oshi/hardware/platform/mac/MacSensorsJNA.java
- oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.java
- oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceFFM.java
- oshi-core/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryJNA.java
- oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryFFM.java
- CHANGELOG.md
- oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerFFM.java
- oshi-core/src/main/java/oshi/hardware/platform/mac/MacBaseboardJNA.java
🚧 Files skipped from review as they are similar to previous changes (9)
- oshi-core/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryJNA.java
- oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacVirtualMemory.java
- oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacUsbDevice.java
- oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacHardwareAbstractionLayer.java
- oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacLogicalVolumeGroup.java
- oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacBaseboardFFM.java
- oshi-core/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardJNA.java
- oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacComputerSystemFFM.java
- oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGraphicsCard.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). (9)
- GitHub Check: Test JDK 25, windows-latest
- GitHub Check: Test JDK 11, macos-latest
- GitHub Check: Test JDK 25, macos-latest
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Test JDK 11, windows-latest
- GitHub Check: Analyze (java)
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Codacy Static Code Analysis
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:51.516Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.
Learnt from: dbwiddis
Repo: oshi/oshi PR: 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.
📚 Learning: 2026-04-03T02:07:47.621Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3110
File: oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHWDiskStoreFFM.java:119-121
Timestamp: 2026-04-03T02:07:47.621Z
Learning: In OSHI’s Java FFM/API implementation classes (e.g., *FFM.java) that implement/override `updateAttributes()`, preserve the intentional failure-handling pattern: catch `Throwable` and return `false` without logging. `updateAttributes()` is a public API whose contract is to signal failure via the boolean return value, and callers rely on that return value (so emitting logs from this path is not desired and should not be introduced during review unless the method contract changes).
Applied to files:
oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryFFM.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/platform/mac/MacHardwareAbstractionLayerJNA.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacComputerSystemJNA.java
📚 Learning: 2026-04-06T04:45:51.516Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:51.516Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.
Applied to files:
oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGlobalMemory.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/common/platform/mac/MacGlobalMemory.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacComputerSystemJNA.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/hardware/platform/mac/MacComputerSystemJNA.java
🔇 Additional comments (7)
oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.java (1)
19-43: Shared baseboard memoization is wired cleanly.Pulling the quartet lookup and getter delegation into one abstract superclass keeps the JNA/FFM variants thin without changing the observable behavior of the getters.
oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java (1)
19-45: The common identity lookup extraction looks solid.The memoized
platformExpert()hook and the A/B/C/D mapping line up cleanly with the subclass contract, so this removes duplication without changing the getter semantics.oshi-core/src/main/java/oshi/hardware/platform/mac/MacComputerSystemJNA.java (2)
16-35: The JNA subclass wiring matches the new split.Extending the common
MacComputerSystemand switching the baseboard factory toMacBaseboardJNAkeeps the concrete JNA path consistent after the extraction.
37-60:platformExpert()preserves the old behavior.The new protected override still applies the same defaults and release path, so moving memoization into the common superclass stays low-risk here.
oshi-core/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerJNA.java (2)
21-23: The HAL factory updates are consistent with the class split.The JNA implementation now points at the renamed JNA concrete types and the new graphics entry point, which keeps backend selection explicit after the superclass move.
Also applies to: 30-48, 75-78
80-82: Good catch restoring printers on the JNA path.Keeping
getPrinters()in the JNA subclass preserves the macOS behavior without reintroducing theoshi-coredependency intooshi-common.oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGlobalMemory.java (1)
121-127: Nice contract extraction for page-size lookup.Centralizing the
4096Lfallback contract here keeps the common layer JNA-free while still giving each backend a clear failure contract.
MacComputerSystem, and MacGraphicsCard; add JNA suffix to MacSensors (#3146)
5659a7c to
64f9e45
Compare
Continues macOS migration to
oshi-commonby moving hardware superclasses and splitting classes with JNA/FFM variants.Moved to
oshi.hardware.common.platform.mac(existing superclasses)MacGlobalMemoryhost_page_size()+ privatequeryPageSize()with singleprotected abstract queryPageSize(), removingNative.getLastError()JNA dependency. Fixed page size fallback from4098Lto4096L.MacHardwareAbstractionLayergetPrinters()(depended onUnixPrinterin oshi-core); moved to JNA subclass. FFM subclass already had its own override.MacUsbDeviceMacVirtualMemoryMacLogicalVolumeGroupSplit into common superclass + JNA/FFM subclasses
MacBaseboard(new abstract — getters + memoized Supplier)MacBaseboardJNA(renamed — JNAqueryPlatform())MacBaseboardFFM(now extends common)MacComputerSystem(new abstract — getters + memoized Supplier)MacComputerSystemJNA(renamed — JNAplatformExpert(), factory methods)MacComputerSystemFFM(now extends common)MacGraphicsCard(refactored — shared parsing viaparseGraphicsCards()with factory + sysctl lambdas)MacGraphicsCardJNA(renamed — thin subclass)MacGraphicsCardFFM(now extends common, usesparseGraphicsCards)JNA rename only
MacSensorsMacSensorsJNASummary by CodeRabbit
Bug Fixes / Improvements
Documentation
Chores