Repository navigation
Make the Solaris nullability contracts honest - #3633
Conversation
Eighth step of draining oshi-core and oshi-core-ffm. Covers the kstat utilities and the Solaris hardware and file-system components in both implementations. Most of it follows from one contract. kstat_lookup treats a null module or name as a wildcard - KstatChain.lookup and lookupAll document each argument as "or null to ignore" and both bodies test for it - but the parameters were declared non-null, so every caller passing a wildcard reported a violation. Annotating the two methods in each twin resolved the bulk. The stats queries report "no kstat entry for this disk or interface" with null, which their abstract declarations in oshi-common already document, as does the Solaris power source's manufacture date. Two deliberate differences worth recording: - The FFM lookup returns MemorySegment.NULL rather than Java null on a miss. That is what its javadoc promises and what all six of its callers test with address() != 0L, so the FFM twin keeps its own sentinel rather than adopting the JNA twin's null. A MemorySegment has a natural null object; a JNA Structure does not, which is why the two differ. - ForeignFunctions' logging helpers take @nullable Object... args. A log argument that is null formats as "null", which is exactly what these call sites want when reporting which wildcard lookup failed. 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 (11)
📜 Recent review details⏰ Context from checks skipped due to timeout. (4)
🧰 Additional context used📓 Path-based instructions (4)**/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{java,xml,md}📄 CodeRabbit inference engine (AGENTS.md)
Files:
oshi-core-ffm/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
oshi-common/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (9)📚 Learning: 2026-04-06T04:45:47.644ZApplied to files:
📚 Learning: 2026-07-06T19:25:59.225ZApplied to files:
📚 Learning: 2026-07-30T00:35:22.638ZApplied 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-08-02T23:56:23.866ZApplied to files:
📚 Learning: 2026-04-12T19:22:09.716ZApplied to files:
🔇 Additional comments (11)
📝 WalkthroughWalkthroughThe PR adds JSpecify ChangesSolaris nullability contracts
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This PR clarifies Solaris nullability contracts without changing runtime behavior, and the stated validation is green; no actionable merge-blocking risk remains beyond 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✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3633 +/- ##
============================================
- Coverage 79.98% 79.93% -0.05%
+ Complexity 3863 199 -3664
============================================
Files 697 697
Lines 24275 24275
Branches 4006 4006
============================================
- Hits 19417 19405 -12
- Misses 2719 2729 +10
- Partials 2139 2141 +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:
|
Eighth step of draining
oshi-coreandoshi-core-ffm. Covers the kstat utilities and the Solarishardware and file-system components in both implementations. Reactor findings 94 → 67.
One contract does most of the work
kstat_lookuptreats a null module or name as a wildcard.KstatChain.lookupandlookupAlldocument each argument as "or null to ignore" and both bodies test for it — but the parameters were
declared non-null, so every caller passing a wildcard reported a violation. Annotating those two
methods in each twin resolved the bulk of the 32 findings.
The stats queries report "no kstat entry for this disk or interface" with null, which their abstract
declarations in
oshi-commonalready document, as does the Solaris power source's manufacture date.Two deliberate twin differences, recorded rather than papered over
lookupkeepsMemorySegment.NULLas its miss sentinel rather than adopting the JNAtwin's Java null. That is what its javadoc promises and what all six of its callers test with
address() != 0L. I annotated the return@Nullablefirst and backed it out: unlikeIOKitUtilFFM.getBSDNameMatchingDictin Make the macOS native utilities' nullability contracts honest #3631 — where the javadoc promised null and the JNA twindelivered it — this FFM contract is internally consistent. A
MemorySegmenthas a natural nullobject; a JNA
Structuredoes not, which is why the two representations differ.ForeignFunctions' logging helpers take@Nullable Object... args. A null log argument formatsas
"null", which is exactly what these call sites want when reporting which wildcard lookupfailed. This one reaches beyond Solaris.
No behavior change
No CHANGELOG entry. Verified by diffing against master and cancelling every line whose only
difference is an annotation: all eleven files have zero residue.
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. This is Solaris code, so nothing here is verified beyond compilation and the
OpenIndiana CI job.
Part of #3593.
Summary by CodeRabbit