Repository navigation
Make the macOS hardware and operating-system layers' nullability contracts honest - #3632
Conversation
…racts honest Seventh step of draining oshi-core and oshi-core-ffm, and the last macOS group. Covers the hardware components and the operating-system layer in both implementations, including the MacGpuStats twins deferred from #3626. As with the macOS utilities, most of this is declarations catching up with documentation. The IO registry views report an absent parent, an exhausted iterator or a card with no accelerator entry by returning null, and each already said so - MacGpuStats.queryPerfStats even carries a paragraph explaining why null and an empty map are different answers there, because getTemperature latches a card as having no sensor only when the dictionary was present. The display synthesis, the medium-type traversal and the localized display name report failure the same way, as does getProcess for a process that is not running, which OperatingSystem has always declared @nullable. Two contracts were stated in a way the analyzer reads differently from a reader: - IOKitProvider.withMatchingService returns null when no service matches, whatever T is, and its extractor may itself report an absent property with null. Declaring <T extends @nullable Object> T said neither; it is now <T> @nullable T taking a Function<RegistryEntry, @nullable T>. - RegistryEntry.lookupControllerVidPid returns a two-element array whose elements may each be absent - @nullable String[] - not a nullable array. MacCentralProcessor.platformExpert tested its result with Util.isBlank, which the analyzer cannot see through; the explicit null-or-empty check is the same test it performs. Part of #3593.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (23)
📜 Recent review details⏰ Context from checks skipped due to timeout. (1)
🧰 Additional context used📓 Path-based instructions (4)**/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
oshi-core-ffm/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{java,xml,md}📄 CodeRabbit inference engine (AGENTS.md)
Files:
oshi-common/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (11)📚 Learning: 2026-07-06T19:25:59.225ZApplied to files:
📚 Learning: 2026-07-30T00:35:22.638ZApplied to files:
📚 Learning: 2026-08-02T23:56:23.866ZApplied to files:
📚 Learning: 2026-08-03T00:46:14.953ZApplied to files:
📚 Learning: 2026-08-15T14:25:48.170ZApplied to files:
📚 Learning: 2026-08-15T15:43:29.296ZApplied to files:
📚 Learning: 2026-08-15T15:59:20.875ZApplied to files:
📚 Learning: 2026-04-12T19:22:09.716ZApplied to files:
📚 Learning: 2026-04-06T04:45:47.644ZApplied to files:
📚 Learning: 2026-04-12T19:34:56.879ZApplied to files:
📚 Learning: 2026-04-06T21:48:09.616ZApplied to files:
🔇 Additional comments (23)
📝 WalkthroughWalkthroughThis change adds JSpecify nullability annotations across macOS common, FFM, and JNA implementations. It also preserves whitespace-only manufacturer values and separates nullable USB controller VID/PID validation. ChangesmacOS nullability updates
Estimated code review effort: 2 (Simple) | ~15 minutes Merge Risk: ⚪ Minimal · up to This PR aligns macOS nullability declarations with existing behavior and makes equivalent defensive checks without changing runtime behavior; no actionable merge-blocking risk remains after normal checks and review. Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (28.57%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #3632 +/- ##
============================================
- Coverage 80.02% 79.98% -0.05%
+ Complexity 3871 199 -3672
============================================
Files 697 697
Lines 24273 24275 +2
Branches 4006 4006
============================================
- Hits 19425 19416 -9
- Misses 2713 2722 +9
- Partials 2135 2137 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@CodeRabbit review |
✅ Action performedReview finished.
|
Seventh step of draining
oshi-coreandoshi-core-ffm, and the last macOS group. Covers thehardware components and the operating-system layer in both implementations, including the
MacGpuStatstwins deferred from #3626. Reactor findings 147 → 94.Mostly declarations catching up with documentation
The IO registry views report an absent parent, an exhausted iterator, or a card with no accelerator
entry by returning null, and each already said so.
MacGpuStats.queryPerfStatseven carries aparagraph explaining why null and an empty map are different answers there —
getTemperaturelatches a card as having no sensor only when the dictionary was present and the key was absent,
never when the dictionary itself was missing, which can be transient. The display synthesis, the
medium-type traversal and the localized display name report failure the same way, as does
getProcessfor a process that is not running, whichOperatingSystemhas always declared@Nullable.Two contracts the analyzer read differently from a reader
IOKitProvider.withMatchingServicereturns null when no service matches, whateverTis,and its extractor may itself report an absent property with null.
<T extends @Nullable Object> Tsaid neither of those things; it is now
<T> @Nullable Ttaking aFunction<RegistryEntry, @Nullable T>.RegistryEntry.lookupControllerVidPidreturns a two-element array whose elements may each beabsent —
@Nullable String[], notString @Nullable []. The javadoc says "either element may benull"; the first annotation I wrote said the array itself could be null, and NullAway caught it.MacCentralProcessor.platformExperttested its result withUtil.isBlank, which the analyzer cannotsee through; the explicit null-or-empty check is the same test that method performs.
Verified at runtime on both backends
Run end to end on an M2 Max after the change:
Apple M2 Max, vendor=Apple (0x106b), vRam=68719476736on both. The USB tree exerciseslookupControllerVidPidand the registry iterator, which are precisely what this PR re-declares, sothose paths are executed rather than merely compiled.
No behavior change
No CHANGELOG entry. Verified by diffing against master and cancelling every line whose only
difference is an annotation: 19 of the 23 files have no residue, and the rest is the
isBlankrewrite above, two array elements read into locals because NullAway does not refine array elements,
and one signature rewrapped across lines.
Full gate on macOS:
spotless:apply sortpom:sort spotless:check checkstyle:check install forbiddenapis:check javadoc:javadocplus-Perror-prone clean install. All modules green, 1561tests, 0 failures.
Part of #3593.
Summary by CodeRabbit
Bug Fixes
Refactor