Repository navigation
Move macOS OperatingSystem tree to oshi-common - #3145
Conversation
📝 WalkthroughWalkthroughThe PR extracts macOS filesystem/file-store behavior into new common base classes under Changes
Sequence Diagram(s)sequenceDiagram
participant OS as MacOperatingSystemJNA
participant FS as MacFileSystemJNA
participant Store as MacOSFileStoreJNA
participant Repo as OSFileStore (system query)
OS->>FS: getFileSystem()
FS->>Repo: enumerate system file stores
Repo-->>FS: list of OSFileStore
FS->>Store: instantiate MacOSFileStoreJNA(...) for each entry
Store->>FS: updateAttributes() (calls FS.getFileStoreMatching)
FS->>Repo: getFileStoreMatching(name, local)
Repo-->>FS: matching OSFileStore
FS-->>Store: matched OSFileStore
Store->>Store: updateFrom(matched OSFileStore)
Store-->>OS: updated file-store instances returned to OS
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 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 #3145 +/- ##
============================================
+ 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.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
oshi-core-java25/src/main/java/oshi/software/os/mac/MacOSFileStoreFFM.java (1)
24-32:⚠️ Potential issue | 🟠 MajorPreserve the
updateAttributes()fail-closed contract here.This override now lets FFM/native failures escape instead of returning
false, which changes the behavior callers expect fromupdateAttributes(). Wrap the body incatch (Throwable)and returnfalsewithout logging.Suggested fix
`@Override` public boolean updateAttributes() { - for (OSFileStore fileStore : MacFileSystemFFM.getFileStoreMatching(getName(), isLocal())) { - if (getVolume().equals(fileStore.getVolume()) && getMount().equals(fileStore.getMount())) { - updateFrom(fileStore); - return true; + try { + for (OSFileStore fileStore : MacFileSystemFFM.getFileStoreMatching(getName(), isLocal())) { + if (getVolume().equals(fileStore.getVolume()) && getMount().equals(fileStore.getMount())) { + updateFrom(fileStore); + return true; + } } + return false; + } catch (Throwable e) { + return false; } - return false; }Based on learnings: in OSHI’s Java FFM/API implementation classes,
updateAttributes()intentionally catchesThrowableand returnsfalsewithout logging.🤖 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/software/os/mac/MacOSFileStoreFFM.java` around lines 24 - 32, The override in MacOSFileStoreFFM.updateAttributes() must preserve the fail-closed contract: wrap the existing logic (the for-loop that iterates over MacFileSystemFFM.getFileStoreMatching(getName(), isLocal()), compares getVolume()/getMount(), and calls updateFrom(fileStore)) in a try block and add a catch (Throwable) that simply returns false (no logging or rethrowing); keep the method returning true on successful update and false otherwise.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@oshi-common/src/main/java/oshi/software/common/os/mac/MacFileSystem.java`:
- Line 38: The LOCAL_DISK pattern in MacFileSystem currently only matches
single-digit device names and misses real macOS names; update the Pattern
referenced by LOCAL_DISK in class MacFileSystem to match one-or-more digits and
optional slice/partition suffix (e.g., allow /dev/disk10 and /dev/disk0s2) so
local volumes are detected correctly; replace the existing
Pattern.compile("/dev/disk\\d") with a regex that uses \\d+ and an optional
(s\\d+)? suffix.
---
Outside diff comments:
In `@oshi-core-java25/src/main/java/oshi/software/os/mac/MacOSFileStoreFFM.java`:
- Around line 24-32: The override in MacOSFileStoreFFM.updateAttributes() must
preserve the fail-closed contract: wrap the existing logic (the for-loop that
iterates over MacFileSystemFFM.getFileStoreMatching(getName(), isLocal()),
compares getVolume()/getMount(), and calls updateFrom(fileStore)) in a try block
and add a catch (Throwable) that simply returns false (no logging or
rethrowing); keep the method returning true on successful update and false
otherwise.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 21f4af46-9263-43f6-a5b4-06d2349e80c6
📒 Files selected for processing (14)
config/checkstyle-suppressions.xmloshi-common/src/main/java/oshi/software/common/os/mac/MacFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/mac/MacInstalledApps.javaoshi-common/src/main/java/oshi/software/common/os/mac/MacOSFileStore.javaoshi-common/src/main/java/oshi/software/common/os/mac/MacOperatingSystem.javaoshi-core-java25/src/main/java/oshi/software/os/mac/MacFileSystemFFM.javaoshi-core-java25/src/main/java/oshi/software/os/mac/MacOSFileStoreFFM.javaoshi-core-java25/src/main/java/oshi/software/os/mac/MacOperatingSystemFFM.javaoshi-core/src/main/java/oshi/software/os/mac/MacFileSystemJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacNetworkParamsJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacOSFileStoreJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacOSProcessJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacOperatingSystemJNA.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: Codacy Static Code Analysis
- GitHub Check: Analyze (java)
- GitHub Check: Test JDK 25, windows-latest
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Test JDK 11, 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: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
🧰 Additional context used
🧠 Learnings (7)
📓 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-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/software/os/mac/MacOperatingSystemFFM.javaoshi-core-java25/src/main/java/oshi/software/os/mac/MacFileSystemFFM.javaoshi-common/src/main/java/oshi/software/common/os/mac/MacInstalledApps.javaoshi-core/src/main/java/oshi/software/os/mac/MacNetworkParamsJNA.javaoshi-common/src/main/java/oshi/software/common/os/mac/MacOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/mac/MacOperatingSystemJNA.java
📚 Learning: 2026-04-06T04:45:51.516Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:51.516Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.
Applied to files:
oshi-core-java25/src/main/java/oshi/software/os/mac/MacOperatingSystemFFM.javaoshi-common/src/main/java/oshi/software/common/os/mac/MacInstalledApps.javaoshi-common/src/main/java/oshi/software/common/os/mac/MacOperatingSystem.javaoshi-common/src/main/java/oshi/software/common/os/mac/MacOSFileStore.javaoshi-common/src/main/java/oshi/software/common/os/mac/MacFileSystem.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/software/os/mac/MacOperatingSystemFFM.javaoshi-core-java25/src/main/java/oshi/software/os/mac/MacFileSystemFFM.javaoshi-core-java25/src/main/java/oshi/software/os/mac/MacOSFileStoreFFM.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/software/os/mac/MacFileSystemFFM.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/software/os/mac/MacNetworkParamsJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacOSProcessJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacOperatingSystemJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacOSFileStoreJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacFileSystemJNA.java
📚 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-core/src/main/java/oshi/software/os/mac/MacOSFileStoreJNA.javaoshi-common/src/main/java/oshi/software/common/os/mac/MacOSFileStore.java
🔇 Additional comments (13)
config/checkstyle-suppressions.xml (1)
41-41: Suppression range update is consistent with the moved field block.
This looks correct and keeps the existing intent intact after line shifts.oshi-common/src/main/java/oshi/software/common/os/mac/MacInstalledApps.java (1)
5-11: Package migration and import adjustments look clean.
No behavioral risk in this segment; the move aligns with the common macOS refactor.oshi-common/src/main/java/oshi/software/common/os/mac/MacOperatingSystem.java (1)
45-45: Logger target fix is correct.
Switching toMacOperatingSystem.classresolves the previous class-reference mismatch in logs.oshi-core-java25/src/main/java/oshi/software/os/mac/MacOperatingSystemFFM.java (1)
33-33: Superclass import update is correct for the migration.
MacOperatingSystemFFMnow resolves to the shared common base as intended.oshi-core/src/main/java/oshi/software/os/mac/MacNetworkParamsJNA.java (1)
28-33: JNA rename wiring is consistent.
Class name and logger target are aligned, reducing future confusion in logs and type references.oshi-core/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsJNA.java (1)
57-71: Type rename propagation is complete in this segment.
Constructor and memoized supplier references correctly point toMacInternetProtocolStatsJNA.oshi-common/src/main/java/oshi/software/common/os/mac/MacFileSystem.java (1)
23-35: Shared constant/config extraction looks solid.
Centralizing FS include/exclude config and mount-option mapping in this base class is a good consolidation step for JNA/FFM parity.Also applies to: 64-87
oshi-core-java25/src/main/java/oshi/software/os/mac/MacFileSystemFFM.java (1)
41-41: Import update is correct for shared base adoption.
MacFileSystemFFMnow cleanly extends the common macOS filesystem base.oshi-common/src/main/java/oshi/software/common/os/mac/MacOSFileStore.java (1)
15-95: Nice shared-base extraction.Pulling the common macOS file-store state and the
updateFrom(...)helper into one base class keeps the JNA and FFM implementations thinner without changing where the matching logic lives.oshi-core/src/main/java/oshi/software/os/mac/MacOSProcessJNA.java (1)
48-61: Rename and constructor wiring look consistent.The common
MacOperatingSystemimport, logger target, class rename, and constructor signature all line up with the updated factory path.Also applies to: 142-148
oshi-core/src/main/java/oshi/software/os/mac/MacOperatingSystemJNA.java (1)
69-75: Factory updates are internally consistent.
getFileSystem(),getInternetProtocolStats(),getProcess(), andgetNetworkParams()all now resolve to the renamed JNA implementations, and theMacOSProcessJNAconstructor call matches the new base-type signature.Also applies to: 111-149
oshi-core/src/main/java/oshi/software/os/mac/MacOSFileStoreJNA.java (1)
15-33: Good split between shared state and JNA-specific lookup.Keeping the match logic here and centralizing the field-copying in
updateFrom(...)makes the move tooshi-commonnicely contained.oshi-core/src/main/java/oshi/software/os/mac/MacFileSystemJNA.java (1)
34-48: The filesystem refactor hangs together cleanly.Extending the shared
MacFileSystembase and emittingMacOSFileStoreJNAinstances keeps the JNA-specific enumeration logic intact while deduplicating the shared macOS constants and config.Also applies to: 162-164
…nd MacOSFileStore; add JNA suffix to remaining classes (#3145)
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-core-java25/src/main/java/oshi/software/os/mac/MacOSFileStoreFFM.java (1)
24-33:⚠️ Potential issue | 🟠 MajorRestore
Throwableguard inupdateAttributes()to keep failure signaling contract.
updateAttributes()currently lets runtime failures propagate. Per the FFM pattern in this codebase, it should returnfalseon any failure and avoid logging from this path.Proposed patch
`@Override` public boolean updateAttributes() { - for (OSFileStore fileStore : MacFileSystemFFM.getFileStoreMatching(getName(), isLocal())) { - if (getVolume().equals(fileStore.getVolume()) && getMount().equals(fileStore.getMount())) { - updateFrom(fileStore); - return true; + try { + for (OSFileStore fileStore : MacFileSystemFFM.getFileStoreMatching(getName(), isLocal())) { + if (getVolume().equals(fileStore.getVolume()) && getMount().equals(fileStore.getMount())) { + updateFrom(fileStore); + return true; + } } + } catch (Throwable t) { // intentional: API contract is boolean failure signaling + return false; } return false; }Based on learnings: in OSHI Java FFM
updateAttributes()implementations, preservecatch Throwableand returnfalsewithout logging.🤖 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/software/os/mac/MacOSFileStoreFFM.java` around lines 24 - 33, The updateAttributes() method should preserve the FFM failure-contract by wrapping the existing logic in a try/catch Throwable that returns false on any error and does not log; specifically, in MacOSFileStoreFFM.updateAttributes() wrap the loop that iterates over MacFileSystemFFM.getFileStoreMatching(getName(), isLocal()) and compares getVolume() and getMount(), calling updateFrom(fileStore) and returning true on match, with a try block and add a catch(Throwable t) { return false; } so any runtime/checked errors simply cause updateAttributes() to return false without emitting logs.
🧹 Nitpick comments (1)
oshi-common/src/main/java/oshi/software/common/os/mac/MacFileSystem.java (1)
64-87: Consider making OPTIONS_MAP unmodifiable for thread-safety.While the map is only populated in the static initializer and never modified afterward, wrapping it in
Collections.unmodifiableMap()would make the immutability explicit and prevent accidental modification by subclasses, which better aligns with the@ThreadSafeannotation.♻️ Proposed fix
- protected static final Map<Integer, String> OPTIONS_MAP = new HashMap<>(); - static { - OPTIONS_MAP.put(MNT_SYNCHRONOUS, "synchronous"); - OPTIONS_MAP.put(MNT_NOEXEC, "noexec"); - OPTIONS_MAP.put(MNT_NOSUID, "nosuid"); - OPTIONS_MAP.put(MNT_NODEV, "nodev"); - OPTIONS_MAP.put(MNT_UNION, "union"); - OPTIONS_MAP.put(MNT_ASYNC, "asynchronous"); - OPTIONS_MAP.put(MNT_CPROTECT, "content-protection"); - OPTIONS_MAP.put(MNT_EXPORTED, "exported"); - OPTIONS_MAP.put(MNT_QUARANTINE, "quarantined"); - OPTIONS_MAP.put(MNT_LOCAL, "local"); - OPTIONS_MAP.put(MNT_QUOTA, "quotas"); - OPTIONS_MAP.put(MNT_ROOTFS, "rootfs"); - OPTIONS_MAP.put(MNT_DOVOLFS, "volfs"); - OPTIONS_MAP.put(MNT_DONTBROWSE, "nobrowse"); - OPTIONS_MAP.put(MNT_IGNORE_OWNERSHIP, "noowners"); - OPTIONS_MAP.put(MNT_AUTOMOUNTED, "automounted"); - OPTIONS_MAP.put(MNT_JOURNALED, "journaled"); - OPTIONS_MAP.put(MNT_NOUSERXATTR, "nouserxattr"); - OPTIONS_MAP.put(MNT_DEFWRITE, "defwrite"); - OPTIONS_MAP.put(MNT_MULTILABEL, "multilabel"); - OPTIONS_MAP.put(MNT_NOATIME, "noatime"); - } + protected static final Map<Integer, String> OPTIONS_MAP; + static { + Map<Integer, String> map = new HashMap<>(); + map.put(MNT_SYNCHRONOUS, "synchronous"); + map.put(MNT_NOEXEC, "noexec"); + map.put(MNT_NOSUID, "nosuid"); + map.put(MNT_NODEV, "nodev"); + map.put(MNT_UNION, "union"); + map.put(MNT_ASYNC, "asynchronous"); + map.put(MNT_CPROTECT, "content-protection"); + map.put(MNT_EXPORTED, "exported"); + map.put(MNT_QUARANTINE, "quarantined"); + map.put(MNT_LOCAL, "local"); + map.put(MNT_QUOTA, "quotas"); + map.put(MNT_ROOTFS, "rootfs"); + map.put(MNT_DOVOLFS, "volfs"); + map.put(MNT_DONTBROWSE, "nobrowse"); + map.put(MNT_IGNORE_OWNERSHIP, "noowners"); + map.put(MNT_AUTOMOUNTED, "automounted"); + map.put(MNT_JOURNALED, "journaled"); + map.put(MNT_NOUSERXATTR, "nouserxattr"); + map.put(MNT_DEFWRITE, "defwrite"); + map.put(MNT_MULTILABEL, "multilabel"); + map.put(MNT_NOATIME, "noatime"); + OPTIONS_MAP = Collections.unmodifiableMap(map); + }Add the import:
import java.util.Collections;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/main/java/oshi/software/common/os/mac/MacFileSystem.java` around lines 64 - 87, Make OPTIONS_MAP truly immutable by replacing the mutable HashMap with an unmodifiable map: after populating the current static HashMap in the static initializer for class MacFileSystem, wrap it with Collections.unmodifiableMap(...) and assign that back to OPTIONS_MAP (and add the import for java.util.Collections); this makes the static OPTIONS_MAP constant read-only and protects against accidental modification by subclasses or other code.
🤖 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-core-java25/src/main/java/oshi/software/os/mac/MacOSFileStoreFFM.java`:
- Around line 24-33: The updateAttributes() method should preserve the FFM
failure-contract by wrapping the existing logic in a try/catch Throwable that
returns false on any error and does not log; specifically, in
MacOSFileStoreFFM.updateAttributes() wrap the loop that iterates over
MacFileSystemFFM.getFileStoreMatching(getName(), isLocal()) and compares
getVolume() and getMount(), calling updateFrom(fileStore) and returning true on
match, with a try block and add a catch(Throwable t) { return false; } so any
runtime/checked errors simply cause updateAttributes() to return false without
emitting logs.
---
Nitpick comments:
In `@oshi-common/src/main/java/oshi/software/common/os/mac/MacFileSystem.java`:
- Around line 64-87: Make OPTIONS_MAP truly immutable by replacing the mutable
HashMap with an unmodifiable map: after populating the current static HashMap in
the static initializer for class MacFileSystem, wrap it with
Collections.unmodifiableMap(...) and assign that back to OPTIONS_MAP (and add
the import for java.util.Collections); this makes the static OPTIONS_MAP
constant read-only and protects against accidental modification by subclasses or
other code.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4485170d-5eb9-45c3-ab01-1ef985da51b8
📒 Files selected for processing (14)
config/checkstyle-suppressions.xmloshi-common/src/main/java/oshi/software/common/os/mac/MacFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/mac/MacInstalledApps.javaoshi-common/src/main/java/oshi/software/common/os/mac/MacOSFileStore.javaoshi-common/src/main/java/oshi/software/common/os/mac/MacOperatingSystem.javaoshi-core-java25/src/main/java/oshi/software/os/mac/MacFileSystemFFM.javaoshi-core-java25/src/main/java/oshi/software/os/mac/MacOSFileStoreFFM.javaoshi-core-java25/src/main/java/oshi/software/os/mac/MacOperatingSystemFFM.javaoshi-core/src/main/java/oshi/software/os/mac/MacFileSystemJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacNetworkParamsJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacOSFileStoreJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacOSProcessJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacOperatingSystemJNA.java
✅ Files skipped from review due to trivial changes (5)
- config/checkstyle-suppressions.xml
- oshi-core-java25/src/main/java/oshi/software/os/mac/MacFileSystemFFM.java
- oshi-core-java25/src/main/java/oshi/software/os/mac/MacOperatingSystemFFM.java
- oshi-common/src/main/java/oshi/software/common/os/mac/MacInstalledApps.java
- oshi-core/src/main/java/oshi/software/os/mac/MacOperatingSystemJNA.java
🚧 Files skipped from review as they are similar to previous changes (6)
- oshi-common/src/main/java/oshi/software/common/os/mac/MacOperatingSystem.java
- oshi-core/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsJNA.java
- oshi-core/src/main/java/oshi/software/os/mac/MacOSProcessJNA.java
- oshi-core/src/main/java/oshi/software/os/mac/MacNetworkParamsJNA.java
- oshi-core/src/main/java/oshi/software/os/mac/MacOSFileStoreJNA.java
- oshi-common/src/main/java/oshi/software/common/os/mac/MacOSFileStore.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: Codacy Static Code Analysis
- GitHub Check: Test JDK 11, macos-latest
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 25, macos-latest
- GitHub Check: Test JDK 25, windows-latest
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Test JDK 11, windows-latest
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Analyze (java)
🧰 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.
📚 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/software/os/mac/MacOSFileStoreFFM.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/software/os/mac/MacFileSystemJNA.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/software/common/os/mac/MacFileSystem.java
🔇 Additional comments (4)
oshi-core-java25/src/main/java/oshi/software/os/mac/MacOSFileStoreFFM.java (1)
8-21: Nice consolidation onto the common macOS file-store base.This inheritance + constructor delegation cleanup is consistent with the JNA/FFM split and removes duplicated state/getter logic cleanly.
oshi-common/src/main/java/oshi/software/common/os/mac/MacFileSystem.java (1)
1-38: Clean extraction of common macOS filesystem constants and configuration.The structure is well-organized with config keys, PathMatcher filters, and the LOCAL_DISK pattern properly extracted to the common base class. The eagerly-loaded PathMatcher fields align with how FileSystemUtil is designed to be used.
oshi-core/src/main/java/oshi/software/os/mac/MacFileSystemJNA.java (2)
34-48: Refactoring looks correct.The class now properly extends the common
MacFileSystembase and the logger correctly referencesMacFileSystemJNA.class, fixing the bug mentioned in the PR objectives where it previously referenced the wrong class.
55-56: Consistent naming with the JNA suffix convention.The comment update and
MacOSFileStoreJNAinstantiation correctly reflect the renamed classes in this PR.Also applies to: 162-164
Continues the macOS oshi-common migration from #3144 by moving the entire
MacOperatingSystemclass tree and adding JNA suffixes to all remaining JNA-only classes for naming consistency.Moved to oshi-common (
oshi.software.common.os.mac)MacInstalledAppsMacOperatingSystemMacOperatingSystemJNA.class, nowMacOperatingSystem.classMacFileSystemOPTIONS_MAPMacOSFileStoreupdateFrom()helperSplit into JNA/FFM pairs
MacFileSystemMacFileSystemJNA(new name)MacFileSystemFFM(now extends common base)MacOSFileStoreMacOSFileStoreJNA(new name)MacOSFileStoreFFM(now extends common base, deduplicated)JNA suffix renames (oshi-core)
MacOSProcessMacOSProcessJNAMacInternetProtocolStatsMacInternetProtocolStatsJNAMacNetworkParamsMacNetworkParamsJNAOther changes
MacOperatingSystem.javaMacOperatingSystemJNASummary by CodeRabbit
Refactor
Chores