Repository navigation
Extract Solaris hardware common abstract bases (JNA/FFM parity, part 2) - #3368
Conversation
The common abstract SolarisGlobalMemory base already exists; the JNA concrete shared its simple name and used a fully-qualified extends. Rename it to SolarisGlobalMemoryJNA (matching the AIX convention) and switch the FFM concrete to an import so neither needs the fully-qualified name.
Move the disk enumeration (getDisks/createStore, which call the common iostat/lshal/prtvtoc drivers) and the updateAttributes field assignment into an abstract SolarisHWDiskStore base in oshi-common. The enumeration builds each store through a factory so it is shared rather than duplicated; the kstat per-disk I/O read is fetched by the subclasses into a DiskStats POJO. SolarisHWDiskStoreJNA keeps the Kstat2 dual-path; the FFM concrete uses the legacy kstat chain only.
Move the interface enumeration (getNetworks, via a factory) and the updateAttributes field assignment into an abstract SolarisNetworkIF base in oshi-common; subclasses fetch the kstat stats into an IfStats POJO. SolarisNetworkIFJNA keeps the Kstat2 dual-path; the FFM concrete uses the legacy kstat chain only.
Move the command-based logic into an abstract SolarisCentralProcessor base in oshi-common: NUMA mapping, processor-ID feature flags, the dmesg physical-processor parsing (via an abstract queryLogicalProcessors hook), the averaged tick rollup, and the kstat -p context-switch/interrupt fallbacks. The kstat-chain queries stay in the subclasses; SolarisCentralProcessorJNA overrides queryContextSwitches/queryInterrupts to add the Kstat2 path and delegates to super for the command fallback.
Rename SolarisHardwareAbstractionLayer to SolarisHardwareAbstractionLayerJNA to pair with the FFM HAL (matching the AIX convention; the HAL itself stays split, as on AIX) and point its factories at the renamed JNA components. Update the JNA SystemInfo reference and suppress VisibilityModifier on the new SolarisHWDiskStore/SolarisNetworkIF public stats POJOs.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 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). (15)
📝 WalkthroughWalkthroughThis PR refactors Solaris hardware support in OSHI by introducing a shared abstraction layer. Three new abstract base classes ( ChangesSolaris HAL Abstraction and Implementations
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 Additional details and impacted files@@ Coverage Diff @@
## master #3368 +/- ##
============================================
+ Coverage 75.09% 75.13% +0.03%
Complexity 76 76
============================================
Files 561 564 +3
Lines 22416 22374 -42
Branches 3701 3681 -20
============================================
- Hits 16834 16810 -24
+ Misses 3508 3496 -12
+ Partials 2074 2068 -6
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:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisCentralProcessor.java (1)
31-34: ⚡ Quick winAvoid mutating the subclass-returned list directly.
initProcessorCounts()currently mutates the list returned byqueryLogicalProcessors(). Since the abstract contract allows anyListimplementation, this can fail with immutable lists at runtime. Copy into a mutable list before fallback insertion.Proposed fix
- List<LogicalProcessor> logProcs = queryLogicalProcessors(); + List<LogicalProcessor> logProcs = new java.util.ArrayList<>(queryLogicalProcessors()); if (logProcs.isEmpty()) { logProcs.add(new LogicalProcessor(0, 0, 0)); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisCentralProcessor.java` around lines 31 - 34, The code mutates the List returned by queryLogicalProcessors() which may be immutable; in initProcessorCounts() first copy the result into a mutable list (e.g., new ArrayList<>(queryLogicalProcessors())) and operate on that copy, then perform the empty-check and add the fallback LogicalProcessor(0,0,0) to the mutable copy; ensure any subsequent uses reference this mutable list rather than the original returned list.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisCentralProcessor.java`:
- Around line 31-34: The code mutates the List returned by
queryLogicalProcessors() which may be immutable; in initProcessorCounts() first
copy the result into a mutable list (e.g., new
ArrayList<>(queryLogicalProcessors())) and operate on that copy, then perform
the empty-check and add the fallback LogicalProcessor(0,0,0) to the mutable
copy; ensure any subsequent uses reference this mutable list rather than the
original returned list.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 4550d937-b130-4139-9383-0d669e7dcca0
📒 Files selected for processing (16)
config/checkstyle-suppressions.xmloshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisHWDiskStore.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisNetworkIF.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessorFFM.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/unix/solaris/SolarisGlobalMemoryFFM.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/unix/solaris/SolarisHWDiskStoreFFM.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/unix/solaris/SolarisNetworkIFFFM.javaoshi-core/src/main/java/oshi/SystemInfo.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessorJNA.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisGlobalMemoryJNA.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisHWDiskStore.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisHWDiskStoreJNA.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisHardwareAbstractionLayerJNA.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisNetworkIF.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisNetworkIFJNA.java
💤 Files with no reviewable changes (2)
- oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisHWDiskStore.java
- oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisNetworkIF.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). (14)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 26, macos-latest
- GitHub Check: JMH Benchmarks, ubuntu-latest
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: JMH Benchmarks, windows-latest
- GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
- GitHub Check: Test JDK 26, windows-latest
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Analyze (java)
- GitHub Check: JMH Benchmarks, macos-latest
- GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
- GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
🧰 Additional context used
🧠 Learnings (3)
📚 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/unix/solaris/SolarisHWDiskStoreJNA.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisGlobalMemoryJNA.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisHardwareAbstractionLayerJNA.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisNetworkIFJNA.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessorJNA.java
📚 Learning: 2026-04-12T19:22:09.716Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:22:09.716Z
Learning: When reviewing OSHI hardware platform code that uses or implements `CentralProcessor`/`PhysicalProcessor.getEfficiency()`, remember the API’s counterintuitive semantics: a *higher* efficiency-class value indicates *greater performance* (lower efficiency). P-cores/“performance cores” should therefore have higher values (e.g., 1) than E-cores/“efficiency cores” (e.g., 0), as documented in the `CentralProcessor` Javadoc. Do not flag code as incorrect solely because ARM_P_CORES or Intel P-cores are assigned higher efficiency values.
Applied to files:
oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisNetworkIF.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisHWDiskStore.java
📚 Learning: 2026-04-12T19:34:56.879Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:34:56.879Z
Learning: In OSHI’s Java platform implementations, `PhysicalProcessor.getEfficiency()` / `EfficiencyClass` follow the same convention as Windows `PROCESSOR_RELATIONSHIP.EfficiencyClass`: a *higher* numeric efficiency class value represents *greater performance* and *less efficiency* (typically P-cores higher than E-cores). When reviewing, do not treat cases where P-cores are assigned higher efficiency/class values as a bug—this is intentional cross-platform consistency.
Applied to files:
oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisCentralProcessor.java
🔇 Additional comments (14)
oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/solaris/SolarisGlobalMemoryFFM.java (1)
14-18: LGTM!oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessorFFM.java (1)
22-31: LGTM!Also applies to: 64-79
oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/solaris/SolarisHWDiskStoreFFM.java (1)
15-22: LGTM!Also applies to: 28-58
oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/solaris/SolarisNetworkIFFFM.java (1)
16-23: LGTM!Also applies to: 30-62
oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisCentralProcessor.java (1)
40-53: LGTM!Also applies to: 56-88, 102-145
config/checkstyle-suppressions.xml (1)
65-67: LGTM!oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessorJNA.java (1)
17-17: LGTM!Also applies to: 25-25, 28-28, 90-110, 119-119, 260-260, 279-279
oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisGlobalMemoryJNA.java (1)
14-14: LGTM!Also applies to: 17-21
oshi-core/src/main/java/oshi/SystemInfo.java (1)
20-20: LGTM!Also applies to: 157-157
oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisHWDiskStore.java (1)
1-115: LGTM!oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisNetworkIF.java (1)
1-97: LGTM!oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisHWDiskStoreJNA.java (1)
1-94: LGTM!oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisNetworkIFJNA.java (1)
1-90: LGTM!oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisHardwareAbstractionLayerJNA.java (1)
31-75: LGTM!
initProcessorCounts() appends a fallback LogicalProcessor when the subclass returns an empty list, so copy the result into a mutable ArrayList rather than assuming the abstract queryLogicalProcessors() returned a mutable one.
Part 2 of 2 of the Solaris JNA/FFM parity cleanup, following #3367 (which did the
software.osclasses). This gives the Solarishardwareclasses the same common-base treatment, matching the AIX/FreeBSD structure. A small part 3 (PowerSource) remains — see below.What changed
SolarisHWDiskStorebase in oshi-common holding the disk enumeration (getDisks/createStore, which call the commoniostat/lshal/prtvtocdrivers) and theupdateAttributesfield assignment. The enumeration builds each store through a factory so it is single-sourced; the kstat per-disk I/O read is fetched by the subclasses into aDiskStatsPOJO.SolarisNetworkIFbase: sharedgetNetworksenumeration (via factory) andupdateAttributes, with anIfStatsPOJO for the kstat read.SolarisCentralProcessorbase: NUMA mapping, processor-ID feature flags,dmesgphysical-processor parsing (via an abstractqueryLogicalProcessorshook), the averaged tick rollup, and thekstat -pcontext-switch/interrupt fallbacks. The kstat-chain queries stay native in the subclasses.SolarisGlobalMemoryJNA(the common base already existed), dropping the fully-qualifiedextendson both sides.SolarisHardwareAbstractionLayerJNAto pair with the FFM HAL. As on AIX, the HAL itself stays split (it's a thin factory).Concrete
<Os>FooJNA(oshi-core) and<Os>FooFFM(oshi-core-ffm) subclasses extend each base, so the codebase follows one rulebook across platforms.Kstat2 stays JNA-only (intentional)
As in part 1:
HAS_KSTAT2and the Kstat2 dual-paths live in the JNA subclasses; FFM uses the legacy kstat chain only, since kstat2 exists only on the JDK 17-capped latest Solaris and illumos forked before it. The JNA CPU overridesqueryContextSwitches/queryInterruptsto add the Kstat2 path and delegates to the base for the shared command fallback.Not in this PR
PowerSource is deferred to a small follow-up — it's static-factory/value-object shaped (the JNA/FFM divergence is interleaved native kstat null-checks inside one static method), so the base+JNA/FFM instance pattern doesn't map cleanly. Left as
SolarisPowerSource/SolarisPowerSourceFFM.Full clean reactor build plus spotless/checkstyle/forbiddenapis/javadoc all pass locally.
Summary by CodeRabbit