Skip to content

Move macOS Hardware superclasses to oshi-common - #3146

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:mac-hw-migrate
Apr 12, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:mac-hw-migrate

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Apr 12, 2026 •

Copy link
Copy Markdown
Member

Continues macOS migration to oshi-common by moving hardware superclasses and splitting classes with JNA/FFM variants.

Moved to oshi.hardware.common.platform.mac (existing superclasses)

Class Notes
MacGlobalMemory Replaced host_page_size() + private queryPageSize() with single protected abstract queryPageSize(), removing Native.getLastError() JNA dependency. Fixed page size fallback from 4098L to 4096L.
MacHardwareAbstractionLayer Removed getPrinters() (depended on UnixPrinter in oshi-core); moved to JNA subclass. FFM subclass already had its own override.
MacUsbDevice Clean move
MacVirtualMemory Clean move
MacLogicalVolumeGroup Clean move — pure Java, no JNA dependencies

Split into common superclass + JNA/FFM subclasses

Common base (oshi-common) JNA (oshi-core) FFM (oshi-core-java25)
MacBaseboard (new abstract — getters + memoized Supplier) MacBaseboardJNA (renamed — JNA queryPlatform()) MacBaseboardFFM (now extends common)
MacComputerSystem (new abstract — getters + memoized Supplier) MacComputerSystemJNA (renamed — JNA platformExpert(), factory methods) MacComputerSystemFFM (now extends common)
MacGraphicsCard (refactored — shared parsing via parseGraphicsCards() with factory + sysctl lambdas) MacGraphicsCardJNA (renamed — thin subclass) MacGraphicsCardFFM (now extends common, uses parseGraphicsCards)

JNA rename only

Old New Notes
MacSensors MacSensorsJNA Every method body differs between JNA/FFM (different SMC utilities) — no shared code to extract

Summary by CodeRabbit

  • Bug Fixes / Improvements

    • Improved macOS hardware detection and extensibility with clearer separation of common vs platform-specific logic.
    • More reliable memory page-size reporting with a defined 4096 fallback and improved error handling.
    • Enhanced GPU discovery and stats collection on macOS.
    • Restored printer reporting via the macOS implementation.
  • Documentation

    • Updated CHANGELOG for upcoming 6.12.0 with macOS refactor notes.
  • Chores

    • Adjusted style/check suppression settings for the reorg.

@coderabbitai

coderabbitai Bot commented Apr 12, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 69c396ee-b5c1-4b41-b2e8-7f4eb900beab

📥 Commits

Reviewing files that changed from the base of the PR and between 5659a7c and 64f9e45.

📒 Files selected for processing (26)
  • CHANGELOG.md
  • config/checkstyle-suppressions.xml
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxUsbDevice.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGlobalMemory.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGraphicsCard.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-common/src/main/java/oshi/hardware/common/platform/mac/MacUsbDevice.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacVirtualMemory.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacBaseboardFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacComputerSystemFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacBaseboardJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacComputerSystemJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacSensorsJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.java
  • oshi-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 (10)
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacSensorsJNA.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxUsbDevice.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryFFM.java
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardJNA.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceFFM.java
🚧 Files skipped from review as they are similar to previous changes (10)
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacUsbDevice.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacVirtualMemory.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacLogicalVolumeGroup.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryFFM.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacHardwareAbstractionLayer.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacComputerSystemFFM.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGlobalMemory.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacBaseboardJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacComputerSystemJNA.java
📜 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)
  • 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 11, macos-latest
  • GitHub Check: Test JDK 11, ubuntu-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Test JDK 25, macos-latest
🧰 Additional context used
🧠 Learnings (4)
📓 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-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/MacGlobalMemoryJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerJNA.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/MacBaseboardFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardFFM.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/MacBaseboardFFM.java
🔇 Additional comments (7)
oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacBaseboardFFM.java (1)

11-24: Clean superclass migration and hook override.

The switch to MacBaseboard plus overriding protected queryPlatform() is consistent with the new shared macOS abstraction and preserves expected baseboard field exposure through inherited memoized getters.

oshi-core/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryJNA.java (1)

44-53: LGTM! Safe fallback for page size query.

The refactored queryPageSize() correctly implements the abstract hook from the superclass. The 4096L fallback is appropriate (standard macOS page size) and safer than returning -1, which could cause incorrect memory calculations. Error logging with Native.getLastError() provides useful diagnostics.

oshi-core/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerJNA.java (1)

30-83: LGTM! Factory methods correctly wired to JNA implementations.

The factory methods properly delegate to the renamed JNA-specific classes (MacComputerSystemJNA, MacSensorsJNA, MacGraphicsCardJNA). The getPrinters() override correctly provides the implementation that was removed from the common superclass, maintaining the existing behavior via UnixPrinter.getPrinters().

oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardFFM.java (1)

19-32: LGTM! Clean delegation to shared parsing logic.

The FFM implementation correctly extends the common MacGraphicsCard base and delegates to parseGraphicsCards() with appropriate method references. The constructor reference MacGraphicsCardFFM::new matches the GraphicsCardFactory interface, and SysctlUtilFFM::sysctl matches the SysctlLong functional interface signature.

oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGraphicsCard.java (3)

22-28: LGTM! Well-structured base class for JNA/FFM implementations.

Making the class public abstract with protected constructor and constants appropriately enables subclassing by platform-specific implementations in both oshi-core (JNA) and oshi-core-java25 (FFM) modules.


30-71: LGTM! Clean factory-based parsing implementation.

The parseGraphicsCards() method correctly extracts shared parsing logic while allowing subclasses to provide their own card instantiation and sysctl implementations. The cardNum tracking correctly handles the streaming nature of system_profiler output where card boundaries are determined by encountering "chipset model" lines.


73-91: LGTM! Appropriate VRAM resolution and functional interfaces.

The resolveVram() helper correctly handles Apple Silicon unified memory by falling back to hw.memsize when no dedicated VRAM is reported. The functional interfaces provide clean abstraction points for JNA vs FFM sysctl implementations.


📝 Walkthrough

Walkthrough

Extracted macOS hardware superclass logic into oshi-common, converting several platform classes into abstract common templates with protected hooks (e.g., queryPlatform(), platformExpert(), queryPageSize()); JNA/FFM implementations now extend these common bases and provide platform-specific data and factories (notably for graphics card parsing).

Changes

Cohort / File(s) Summary
Changelog & Checkstyle
CHANGELOG.md, config/checkstyle-suppressions.xml
Updated changelog with macOS moves and removed a Checkstyle suppression for MacGlobalMemory.
Common macOS superclasses (oshi-common)
oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.java, .../MacComputerSystem.java, .../MacGraphicsCard.java
Added abstract common mac classes: memoized quartet hooks for identity (MacBaseboard, MacComputerSystem) and a factory/sysctl-driven GPU parsing helper in MacGraphicsCard.
Other common macOS classes (oshi-common)
oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGlobalMemory.java, .../MacHardwareAbstractionLayer.java, .../MacLogicalVolumeGroup.java, .../MacUsbDevice.java, .../MacVirtualMemory.java
Moved classes into oshi.hardware.common.platform.mac, widened visibility/made abstract where needed, introduced queryPageSize() abstract hook and small mapping/fallback behavior changes.
FFM implementations (oshi-core-java25)
oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacBaseboardFFM.java, .../MacComputerSystemFFM.java, .../MacGlobalMemoryFFM.java, .../MacGraphicsCardFFM.java, .../MacHardwareAbstractionLayerFFM.java, .../MacUsbDeviceFFM.java, .../MacVirtualMemoryFFM.java
Refactored FFM classes to extend new common abstracts, removed duplicated memoizers/overrides, renamed overrides from host_page_size()→queryPageSize(), and delegated GPU discovery to shared parser/factory.
JNA implementations (oshi-core)
oshi-core/src/main/java/oshi/hardware/platform/mac/MacBaseboardJNA.java, .../MacComputerSystemJNA.java, .../MacGlobalMemoryJNA.java, .../MacGraphicsCardJNA.java, .../MacHardwareAbstractionLayerJNA.java, .../MacSensorsJNA.java, .../MacUsbDeviceJNA.java, .../MacVirtualMemoryJNA.java
Renamed/added JNA-specific classes (*JNA) to extend common abstracts, moved platform-specific querying into protected hook overrides, added MacGraphicsCardJNA with factory-backed parsing, and adjusted imports/printer override.
Misc. platform doc tweak (linux)
oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxUsbDevice.java
Small Javadoc clarification in protected constructor; no behavioral changes.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐇 I hopped through code with a twitch and a twitch,

Pulled common threads, then stitched each switch,
JNA and FFM don new hats in a line,
Factories hum while sysctls refine,
A rabbit applauds this tidy design.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.84% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Move macOS Hardware superclasses to oshi-common' clearly and directly summarizes the main objective of the changeset: migrating macOS hardware superclasses from oshi-core to oshi-common.

✏️ 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.

@codecov

codecov Bot commented Apr 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.21%. Comparing base (be3f71c) to head (64f9e45).
⚠️ Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 | 🟡 Minor

Potential null passed to constructor when no physical volumes exist for a volume group.

If diskutil cs list output contains a logical volume group with logical volumes but no physical volumes listed, physicalVolumesMap.get(e.getKey()) will return null, which is then passed to the MacLogicalVolumeGroup constructor. Consider using getOrDefault for 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

📥 Commits

Reviewing files that changed from the base of the PR and between be3f71c and 989fdda.

📒 Files selected for processing (25)
  • CHANGELOG.md
  • config/checkstyle-suppressions.xml
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGlobalMemory.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGraphicsCard.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-common/src/main/java/oshi/hardware/common/platform/mac/MacUsbDevice.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacVirtualMemory.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacBaseboardFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacComputerSystemFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacBaseboardJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacComputerSystemJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacSensorsJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.java
  • oshi-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.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacLogicalVolumeGroup.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacVirtualMemory.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacComputerSystemFFM.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.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
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGlobalMemory.java
  • oshi-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.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryJNA.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacLogicalVolumeGroup.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacVirtualMemory.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacComputerSystemFFM.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacUsbDevice.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGlobalMemory.java
  • oshi-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.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacComputerSystemFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacBaseboardFFM.java
  • oshi-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.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryJNA.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacLogicalVolumeGroup.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacComputerSystemFFM.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacUsbDevice.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacBaseboardFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacComputerSystemJNA.java
  • oshi-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.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceFFM.java
  • oshi-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.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceFFM.java
  • oshi-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.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacSensorsJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacComputerSystemJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardJNA.java
  • oshi-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.md intentionally 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 MacSensorsJNA aligns with the PR's JNA/FFM naming convention. The static imports from SmcUtil improve 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 Quartet correctly caches the platform data once, and the @Immutable annotation is appropriate given the indefinite memoization. The abstract platformExpert() 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 MacComputerSystem pattern with memoized Quartet storage. The abstract queryPlatform() 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 the Quartet ordering 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 MacBaseboard contract. The fallback chain for model (board-id → model-number) and serialNumber (mlb-serial-number → IOPlatformSerialNumber) provides robust data retrieval. The Quartet ordering 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 GraphicsCardFactory and SysctlLong interfaces enable clean dependency injection, allowing JNA and FFM subclasses to provide their respective sysctl implementations while sharing the system_profiler parsing logic. The resolveVram fallback to hw.memsize for 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 MacGraphicsCard from oshi-common and delegates to parseGraphicsCards() with appropriate method references. The MacGraphicsCardFFM::new factory matches the GraphicsCardFactory interface signature, and SysctlUtilFFM::sysctl matches the SysctlLong functional 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 MacGraphicsCardJNA class correctly:

  • Extends the common MacGraphicsCard superclass
  • Uses JNA-specific utilities (SysctlUtil, MacGpuStats) rather than FFM variants
  • Delegates parsing to parseGraphicsCards() with appropriate method references

The implementation maintains consistency with MacGraphicsCardFFM while 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 MacHardwareAbstractionLayer to oshi.hardware.common.platform.mac. The class properly extends the abstract base and implements getPrinters() 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 relocated MacUsbDevice type.

The import change aligns with the migration of MacUsbDevice to oshi.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 MacVirtualMemory from the new common package location

No 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 relocated MacUsbDevice type.

The import change aligns with the migration of MacUsbDevice to oshi.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 MacVirtualMemory from the new common package location

No 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 provides UnixPrinter.getPrinters(), FFM subclass provides CupsPrinter.getPrinters())

The remaining getLogicalVolumeGroups() and getSoundCards() 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() to queryPageSize() and the fallback value change to 4096L correctly align with the documented contract in the abstract MacGlobalMemory superclass. 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 abstract class, protected constructor) 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.mac is consistent with the migration pattern, and the Javadoc update correctly references the fully qualified MacUsbDeviceJNA class 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 documented 4096L fallback. The error logging with Native.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 new getPrinters() 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 of 4096L cleanly defines the template method pattern. This also fixes the previous typo where the fallback was 4098L instead of the correct 4096L (standard page size). Both JNA and FFM implementations correctly adhere to this contract.

@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-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_size result. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 989fdda and 5659a7c.

📒 Files selected for processing (25)
  • CHANGELOG.md
  • config/checkstyle-suppressions.xml
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGlobalMemory.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGraphicsCard.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-common/src/main/java/oshi/hardware/common/platform/mac/MacUsbDevice.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacVirtualMemory.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacBaseboardFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacComputerSystemFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacBaseboardJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacComputerSystemJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacGraphicsCardJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacHardwareAbstractionLayerJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacSensorsJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.java
  • oshi-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.java
  • oshi-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.java
  • oshi-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.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java
  • oshi-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.java
  • oshi-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 MacComputerSystem and switching the baseboard factory to MacBaseboardJNA keeps 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 the oshi-core dependency into oshi-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 4096L fallback 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)
@dbwiddis
dbwiddis merged commit f661f3d into oshi:master Apr 12, 2026
15 of 16 checks passed
@dbwiddis
dbwiddis deleted the mac-hw-migrate branch April 12, 2026 16:28
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