Repository navigation
Move abstract implementations, drivers, and tests to oshi-common - #3133
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughModule exports extended and several Unix driver classes moved into Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
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 #3133 +/- ##
============================================
+ Coverage 60.88% 61.61% +0.72%
Complexity 12 12
============================================
Files 39 39
Lines 2329 2329
Branches 407 407
============================================
+ Hits 1418 1435 +17
+ Misses 791 775 -16
+ Partials 120 119 -1 ☔ 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-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java (1)
315-317:⚠️ Potential issue | 🟡 MinorUse
hwcap != 0instead ofhwcap > 0to correctly handle unsigned AT_HWCAP values.On 32-bit systems,
FileUtil.readIntFromBuffer()reads a signed 32-bit integer and promotes it tolongwith sign-extension. Unsigned AT_HWCAP values with the high bit set (e.g.,0x80000000+) would become negative longs and be rejected by thehwcap > 0check, even though they represent valid hardware capabilities. Since the javadoc states "0 if unavailable," the correct guard ishwcap != 0to distinguish available capabilities (any non-zero value) from unavailable ones.🤖 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/AbstractCentralProcessor.java` around lines 315 - 317, In AbstractCentralProcessor, replace the conditional check "if (hwcap > 0)" with "if (hwcap != 0)" so that unsigned AT_HWCAP values read via FileUtil.readIntFromBuffer() (promoted to long) are treated as available when non-zero; update the branch that ORs into processorIdBytes (the processorIdBytes |= hwcap << 32; block) to run whenever hwcap != 0 instead of only when hwcap > 0.
🧹 Nitpick comments (6)
oshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.java (1)
60-64: StrengthentoString()test to catch formatting regressions.Substring checks can pass even if indentation/order formatting breaks. Consider asserting the full expected string for stronger protection.
Suggested test tightening
String s = parent.toString(); - assertThat(s, containsString("Hub")); - assertThat(s, containsString("Mouse")); - assertThat(s, containsString("Logitech")); - assertThat(s, containsString("SN1")); + assertThat(s, is(" Hub\n |-- Mouse (Logitech) [s/n: SN1]"));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.java` around lines 60 - 64, The current test in AbstractUsbDeviceTest uses loose substring checks on parent.toString(); tighten it by asserting the exact expected string returned by parent.toString() (replace the containsString assertions with a single equality/assertThat(s, is(expected)) check) so formatting, whitespace and ordering regressions are caught; construct the expected string literal to match the exact output produced by the toString() implementation of the parent object and use that in the assertion.oshi-common/src/test/java/oshi/hardware/common/AbstractDisplayTest.java (1)
31-36: Minor style inconsistency: consider using static import fornotNullValue().Line 35 uses a fully qualified reference
org.hamcrest.Matchers.notNullValue()while other matchers in this file are statically imported (Line 8:is). Consider addingnotNullValueto the static imports for consistency.♻️ Suggested fix
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue;- assertThat(display.toString(), is(org.hamcrest.Matchers.notNullValue())); + assertThat(display.toString(), is(notNullValue()));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/test/java/oshi/hardware/common/AbstractDisplayTest.java` around lines 31 - 36, The test method testToString in AbstractDisplayTest uses a fully qualified org.hamcrest.Matchers.notNullValue() while other matchers (like is) are statically imported; update the imports to add a static import for notNullValue and replace the fully qualified call with notNullValue() in the testToString method so the style matches the existing static import usage for matchers and keeps the assertion consistent with other tests.oshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.java (2)
87-94: Make the test double internally consistent for safer reuse.At Line 87–Line 94,
getProcess()always returningnullandgetProcessCount()always returning0conflicts withqueryAllProcesses()at Line 62–Line 64. This can hide issues if this stub is reused in future tests.Suggested consistency fix
`@Override` public OSProcess getProcess(int pid) { - return null; + return allProcesses.stream().filter(p -> p.getProcessID() == pid).findFirst().orElse(null); } `@Override` public int getProcessCount() { - return 0; + return allProcesses.size(); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.java` around lines 87 - 94, The test double is inconsistent: queryAllProcesses() returns processes but getProcess(int pid) returns null and getProcessCount() returns 0, which can mask bugs when reused; update the test stub so getProcess(int pid) looks up and returns the matching OSProcess from the same collection used by queryAllProcesses() and make getProcessCount() return the collection's size (e.g., size of the list/map used by queryAllProcesses()), ensuring all three methods (queryAllProcesses(), getProcess(int), getProcessCount()) operate on the same backing data.
195-197: Strengthen descendants assertion to check membership.At Line 196,
hasSize(4)alone could pass with an incorrect set of PIDs. Consider asserting exact expected descendants.Suggested assertion hardening
+import static org.hamcrest.Matchers.containsInAnyOrder; @@ Set<Integer> descendants = AbstractOperatingSystem.getChildrenOrDescendants(parentPidMap, 1, true); assertThat(descendants, hasSize(4)); + assertThat(descendants, containsInAnyOrder(1, 2, 3, 4));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.java` around lines 195 - 197, The test currently only checks size for the returned set from AbstractOperatingSystem.getChildrenOrDescendants (variable descendants) which can hide incorrect PID contents; update the assertion to verify exact membership instead of just size—e.g., construct the expected Set<Integer> of descendant PIDs and assert equality (or use a containsInAnyOrder-style matcher) against descendants to ensure the exact PIDs returned by getChildrenOrDescendants are correct.oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java (2)
134-143: Consider asserting full ordered cache sequence, not just first entry.At Line 142, validating only index 0 catches partial regressions. An exact sequence assertion (levels/types/sizes) would better lock behavior.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java` around lines 134 - 143, The test testOrderedProcCaches currently only asserts the first cache level; update it to assert the full ordered sequence returned by AbstractCentralProcessor.orderedProcCaches so regressions in ordering or cache attributes are caught. Construct an expected List<ProcessorCache> (or assert individual elements in order) with the exact level/type/size values you expect (matching the three ProcessorCache instances used in the test) and replace/add assertions to compare the entire ordered list (e.g., assert equality/hasItemsInOrder) against orderedProcCaches result; reference the test method testOrderedProcCaches, the ProcessorCache instances created in the test, and AbstractCentralProcessor.orderedProcCaches when making the change.
119-123: Strengthen the no-HWCAP processor ID assertion.At Line 121–Line 123, asserting non-null + length is useful, but a malformed non-hex string of length 16 would still pass. Consider also asserting it parses as unsigned hex.
Suggested test hardening
import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; @@ void testCreateProcessorIDNoHwcap() { String id = AbstractCentralProcessor.createProcessorID("1", "2", "3", new String[] { "fpu", "sse" }); assertThat(id, is(notNullValue())); assertThat(id.length(), is(16)); + assertDoesNotThrow(() -> Long.parseUnsignedLong(id, 16)); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java` around lines 119 - 123, The test testCreateProcessorIDNoHwcap should not only check non-null and length but also verify the string is valid hex: update the assertion for AbstractCentralProcessor.createProcessorID(...) to parse the returned id as an unsigned hex value (e.g., call Long.parseUnsignedLong(id, 16) or new BigInteger(id, 16)) and assert that parsing succeeds (no exception), ensuring the 16-character value is valid hexadecimal rather than just having the right length.
🤖 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/util/driver/unix/NetStat.java`:
- Around line 228-229: In NetStat.java update the switch-case string literal
typo: replace the incorrect case label "woth no checksum" with "with no
checksum" inside the switch that updates datagramsReceivedErrors (the case
handling that calls ParseUtil.parseLongOrDefault and increments
datagramsReceivedErrors); ensure only the string literal is changed so the case
matches the expected netstat output pattern used alongside "with bad checksum"
and "with bad data length field".
---
Outside diff comments:
In
`@oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java`:
- Around line 315-317: In AbstractCentralProcessor, replace the conditional
check "if (hwcap > 0)" with "if (hwcap != 0)" so that unsigned AT_HWCAP values
read via FileUtil.readIntFromBuffer() (promoted to long) are treated as
available when non-zero; update the branch that ORs into processorIdBytes (the
processorIdBytes |= hwcap << 32; block) to run whenever hwcap != 0 instead of
only when hwcap > 0.
---
Nitpick comments:
In
`@oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java`:
- Around line 134-143: The test testOrderedProcCaches currently only asserts the
first cache level; update it to assert the full ordered sequence returned by
AbstractCentralProcessor.orderedProcCaches so regressions in ordering or cache
attributes are caught. Construct an expected List<ProcessorCache> (or assert
individual elements in order) with the exact level/type/size values you expect
(matching the three ProcessorCache instances used in the test) and replace/add
assertions to compare the entire ordered list (e.g., assert
equality/hasItemsInOrder) against orderedProcCaches result; reference the test
method testOrderedProcCaches, the ProcessorCache instances created in the test,
and AbstractCentralProcessor.orderedProcCaches when making the change.
- Around line 119-123: The test testCreateProcessorIDNoHwcap should not only
check non-null and length but also verify the string is valid hex: update the
assertion for AbstractCentralProcessor.createProcessorID(...) to parse the
returned id as an unsigned hex value (e.g., call Long.parseUnsignedLong(id, 16)
or new BigInteger(id, 16)) and assert that parsing succeeds (no exception),
ensuring the 16-character value is valid hexadecimal rather than just having the
right length.
In `@oshi-common/src/test/java/oshi/hardware/common/AbstractDisplayTest.java`:
- Around line 31-36: The test method testToString in AbstractDisplayTest uses a
fully qualified org.hamcrest.Matchers.notNullValue() while other matchers (like
is) are statically imported; update the imports to add a static import for
notNullValue and replace the fully qualified call with notNullValue() in the
testToString method so the style matches the existing static import usage for
matchers and keeps the assertion consistent with other tests.
In `@oshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.java`:
- Around line 60-64: The current test in AbstractUsbDeviceTest uses loose
substring checks on parent.toString(); tighten it by asserting the exact
expected string returned by parent.toString() (replace the containsString
assertions with a single equality/assertThat(s, is(expected)) check) so
formatting, whitespace and ordering regressions are caught; construct the
expected string literal to match the exact output produced by the toString()
implementation of the parent object and use that in the assertion.
In
`@oshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.java`:
- Around line 87-94: The test double is inconsistent: queryAllProcesses()
returns processes but getProcess(int pid) returns null and getProcessCount()
returns 0, which can mask bugs when reused; update the test stub so
getProcess(int pid) looks up and returns the matching OSProcess from the same
collection used by queryAllProcesses() and make getProcessCount() return the
collection's size (e.g., size of the list/map used by queryAllProcesses()),
ensuring all three methods (queryAllProcesses(), getProcess(int),
getProcessCount()) operate on the same backing data.
- Around line 195-197: The test currently only checks size for the returned set
from AbstractOperatingSystem.getChildrenOrDescendants (variable descendants)
which can hide incorrect PID contents; update the assertion to verify exact
membership instead of just size—e.g., construct the expected Set<Integer> of
descendant PIDs and assert equality (or use a containsInAnyOrder-style matcher)
against descendants to ensure the exact PIDs returned by
getChildrenOrDescendants are correct.
🪄 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: c898bd3a-c8e5-4d3d-b66d-3aec5af8535a
📒 Files selected for processing (64)
oshi-common/src/main/java/module-info.javaoshi-common/src/main/java/oshi/hardware/common/AbstractBaseboard.javaoshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/AbstractComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/AbstractDisplay.javaoshi-common/src/main/java/oshi/hardware/common/AbstractFirmware.javaoshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.javaoshi-common/src/main/java/oshi/hardware/common/AbstractGraphicsCard.javaoshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.javaoshi-common/src/main/java/oshi/hardware/common/AbstractHardwareAbstractionLayer.javaoshi-common/src/main/java/oshi/hardware/common/AbstractLogicalVolumeGroup.javaoshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.javaoshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.javaoshi-common/src/main/java/oshi/hardware/common/AbstractPrinter.javaoshi-common/src/main/java/oshi/hardware/common/AbstractSensors.javaoshi-common/src/main/java/oshi/hardware/common/AbstractSoundCard.javaoshi-common/src/main/java/oshi/hardware/common/AbstractUsbDevice.javaoshi-common/src/main/java/oshi/hardware/common/AbstractVirtualMemory.javaoshi-common/src/main/java/oshi/hardware/common/NoOpGpuStats.javaoshi-common/src/main/java/oshi/hardware/common/package-info.javaoshi-common/src/main/java/oshi/software/common/AbstractFileSystem.javaoshi-common/src/main/java/oshi/software/common/AbstractInternetProtocolStats.javaoshi-common/src/main/java/oshi/software/common/AbstractNetworkParams.javaoshi-common/src/main/java/oshi/software/common/AbstractOSFileStore.javaoshi-common/src/main/java/oshi/software/common/AbstractOSProcess.javaoshi-common/src/main/java/oshi/software/common/AbstractOSThread.javaoshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.javaoshi-common/src/main/java/oshi/software/common/package-info.javaoshi-common/src/main/java/oshi/util/driver/unix/NetStat.javaoshi-common/src/main/java/oshi/util/driver/unix/Who.javaoshi-common/src/main/java/oshi/util/driver/unix/Xwininfo.javaoshi-common/src/main/java/oshi/util/driver/unix/package-info.javaoshi-common/src/test/java/module-info.testoshi-common/src/test/java/oshi/hardware/common/AbstractBaseboardTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractDisplayTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractFirmwareTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractGraphicsCardTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractSensorsTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractSoundCardTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.javaoshi-common/src/test/java/oshi/software/common/AbstractFileSystemTest.javaoshi-common/src/test/java/oshi/software/common/AbstractInternetProtocolStatsTest.javaoshi-common/src/test/java/oshi/software/common/AbstractNetworkParamsTest.javaoshi-common/src/test/java/oshi/software/common/AbstractOSFileStoreTest.javaoshi-common/src/test/java/oshi/software/common/AbstractOSProcessTest.javaoshi-common/src/test/java/oshi/software/common/AbstractOSThreadTest.javaoshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.javaoshi-common/src/test/java/oshi/util/driver/unix/NetStatTest.javaoshi-common/src/test/java/oshi/util/driver/unix/WhoTest.javaoshi-common/src/test/java/oshi/util/driver/unix/XwininfoTest.javaoshi-core-java25/pom.xmloshi-core-java25/src/main/java/oshi/driver/mac/WhoFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.javaoshi-core-java25/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsFFM.javaoshi-core/src/main/java/oshi/driver/linux/Who.javaoshi-core/src/main/java/oshi/driver/mac/Who.javaoshi-core/src/main/java/oshi/driver/unix/freebsd/Who.javaoshi-core/src/main/java/oshi/driver/unix/solaris/Who.javaoshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessor.javaoshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacInternetProtocolStats.javaoshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.javaoshi-core/src/main/java/oshi/software/os/unix/openbsd/OpenBsdInternetProtocolStats.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, windows-latest
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Test JDK 25, macos-latest
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 11, macos-latest
- GitHub Check: Test JDK 25, windows-latest
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (12)
📚 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/AbstractDisplay.javaoshi-common/src/main/java/oshi/hardware/common/AbstractComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/AbstractBaseboard.javaoshi-common/src/main/java/oshi/hardware/common/AbstractSensors.javaoshi-common/src/main/java/oshi/software/common/AbstractOSProcess.javaoshi-common/src/main/java/oshi/hardware/common/AbstractLogicalVolumeGroup.javaoshi-common/src/main/java/oshi/software/common/AbstractNetworkParams.javaoshi-common/src/main/java/oshi/hardware/common/AbstractVirtualMemory.javaoshi-common/src/main/java/oshi/hardware/common/AbstractFirmware.javaoshi-common/src/main/java/oshi/software/common/AbstractOSThread.javaoshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.javaoshi-common/src/main/java/oshi/software/common/AbstractFileSystem.javaoshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.javaoshi-common/src/test/java/oshi/util/driver/unix/NetStatTest.javaoshi-core/src/main/java/oshi/driver/mac/Who.javaoshi-common/src/main/java/oshi/hardware/common/AbstractSoundCard.javaoshi-core/src/main/java/oshi/driver/unix/solaris/Who.javaoshi-common/src/main/java/module-info.javaoshi-common/src/main/java/oshi/util/driver/unix/Who.javaoshi-core-java25/pom.xmloshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.javaoshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.javaoshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.javaoshi-common/src/main/java/oshi/util/driver/unix/Xwininfo.javaoshi-common/src/test/java/module-info.testoshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.javaoshi-common/src/main/java/oshi/util/driver/unix/package-info.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/AbstractDisplay.javaoshi-common/src/main/java/oshi/hardware/common/AbstractComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/AbstractBaseboard.javaoshi-common/src/main/java/oshi/hardware/common/AbstractSensors.javaoshi-common/src/main/java/oshi/software/common/AbstractOSProcess.javaoshi-common/src/main/java/oshi/hardware/common/AbstractLogicalVolumeGroup.javaoshi-common/src/main/java/oshi/software/common/AbstractNetworkParams.javaoshi-common/src/main/java/oshi/hardware/common/AbstractVirtualMemory.javaoshi-common/src/main/java/oshi/hardware/common/AbstractFirmware.javaoshi-common/src/main/java/oshi/software/common/AbstractOSThread.javaoshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.javaoshi-common/src/main/java/oshi/software/common/AbstractFileSystem.javaoshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.javaoshi-common/src/test/java/oshi/util/driver/unix/NetStatTest.javaoshi-core/src/main/java/oshi/driver/mac/Who.javaoshi-common/src/main/java/oshi/hardware/common/AbstractSoundCard.javaoshi-core/src/main/java/oshi/driver/unix/solaris/Who.javaoshi-common/src/main/java/module-info.javaoshi-core/src/main/java/oshi/driver/unix/freebsd/Who.javaoshi-common/src/test/java/oshi/util/driver/unix/WhoTest.javaoshi-common/src/main/java/oshi/util/driver/unix/Who.javaoshi-core-java25/pom.xmloshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.javaoshi-common/src/test/java/oshi/util/driver/unix/XwininfoTest.javaoshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/unix/openbsd/OpenBsdInternetProtocolStats.javaoshi-common/src/main/java/oshi/util/driver/unix/NetStat.javaoshi-common/src/main/java/oshi/util/driver/unix/Xwininfo.javaoshi-common/src/test/java/module-info.testoshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.javaoshi-common/src/main/java/oshi/util/driver/unix/package-info.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/AbstractLogicalVolumeGroup.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/test/java/oshi/util/driver/unix/NetStatTest.javaoshi-common/src/test/java/oshi/util/driver/unix/WhoTest.javaoshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.javaoshi-core/src/main/java/oshi/driver/linux/Who.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/driver/mac/Who.javaoshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.java
📚 Learning: 2026-04-03T18:44:48.200Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3112
File: oshi-core/src/main/java/oshi/PlatformEnum.java:63-66
Timestamp: 2026-04-03T18:44:48.200Z
Learning: In oshi/oshi PlatformEnum.java, the DRAGONFLYBSD enum constant is intentionally added for platform detection only (no implementation classes exist yet). It allows UnsupportedOperationException messages to say "DragonFly BSD" rather than "Unknown". Full DragonFly BSD support is tracked in issue `#2583`. Do not flag the missing switch-case implementations as a bug.
Applied to files:
oshi-core/src/main/java/oshi/driver/unix/solaris/Who.javaoshi-core/src/main/java/oshi/driver/unix/freebsd/Who.javaoshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.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/driver/mac/WhoFFM.javaoshi-core-java25/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.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/MacInternetProtocolStats.javaoshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.javaoshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.javaoshi-core/src/main/java/oshi/software/os/unix/openbsd/OpenBsdInternetProtocolStats.javaoshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessor.java
📚 Learning: 2026-04-05T05:39:21.126Z
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:39:21.126Z
Learning: In OSHI's Linux FFM/JNA udev code, a null guard on `udev_enumerate_new()` is unnecessary if `udev_new()` has already been guarded: per libudev semantics, `udev_enumerate_new()` only returns NULL when udev itself is broken (e.g. OOM), so a successful `udev_new()` implies `udev_enumerate_new()` will succeed as well. Do not flag missing null checks on `udev_enumerate_new()` as an issue.
Applied to files:
oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.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-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.java
📚 Learning: 2026-04-05T05:40:43.357Z
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:43.357Z
Learning: In OSHI’s Linux FFM implementations (e.g., LinuxPowerSourceFFM, LinuxHWDiskStoreFFM, LinuxLogicalVolumeGroupFFM, LinuxUsbDeviceFFM) and the corresponding JNA udev code, do not require/flag a missing null check around `udev_enumerate_new()`/`enumerateNew()`. Per libudev semantics, `udev_enumerate_new()` returns NULL only if udev itself is broken (e.g., OOM). Since `udev_new()` is already guarded and is the successful prerequisite for enumeration, treating `udev_enumerate_new()` as non-null is consistent with the established pattern; adding a redundant null guard would be inconsistent.
Applied to files:
oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
📚 Learning: 2026-04-05T05:39:18.791Z
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:39:18.791Z
Learning: When reviewing OSHI Linux FFM/JNA code that uses libudev, do not flag a missing null check on `udev_enumerate_new()` if `udev_new()` has already been guarded. Per libudev semantics, `udev_enumerate_new()` returns NULL only when the udev context itself is broken (e.g., OOM), so a successful `udev_new()` implies `udev_enumerate_new()` should succeed as well. Therefore, lack of a redundant null guard on `udev_enumerate_new()` is acceptable in this pattern.
Applied to files:
oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
🔇 Additional comments (56)
oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java (1)
2-2: Copyright header update looks good.Metadata-only change; no functional concerns.
oshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.java (1)
19-51: Good foundational coverage for constructor-backed behavior.These tests validate the core contract (getters, child propagation, and natural ordering) and match the current
AbstractUsbDeviceimplementation well.oshi-common/src/main/java/oshi/hardware/common/AbstractComputerSystem.java (1)
2-2: LGTM!Copyright year range update is appropriate and aligns with the current year.
oshi-common/src/test/java/oshi/hardware/common/AbstractGraphicsCardTest.java (1)
115-123: LGTM! Clean test coverage for basic getters.The test correctly validates that all getter methods return the expected values passed to the AbstractGraphicsCard constructor. The assertions align with the hardcoded values in StubGraphicsCard's super() call.
oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java (1)
2-2: Header-only update looks good.This is a non-functional copyright year bump with no runtime/API impact.
oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java (1)
2-2: Header-only update is fine.No functional change introduced.
oshi-common/src/main/java/oshi/hardware/common/AbstractSensors.java (1)
2-2: Looks good.Metadata-only header update; no behavior impact.
oshi-common/src/main/java/oshi/hardware/common/AbstractLogicalVolumeGroup.java (1)
2-2: No concerns on this change.Header year-range update is safe.
oshi-common/src/main/java/oshi/hardware/common/AbstractVirtualMemory.java (1)
2-2: Approved.This is a non-functional copyright header update.
oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.java (1)
2-2: Change is good.No functional differences; header metadata only.
oshi-common/src/main/java/oshi/hardware/common/AbstractFirmware.java (1)
2-2: Looks correct.Header-year update is non-functional and low risk.
oshi-common/src/main/java/oshi/hardware/common/AbstractSoundCard.java (1)
2-2: LGTM for this segment.Non-functional header update only.
oshi-common/src/main/java/oshi/util/driver/unix/Xwininfo.java (1)
2-5: Package relocation and metadata update look correct.The namespace move to
oshi.util.driver.unixis consistent with the PR goal, and no behavior change is introduced in this segment.oshi-common/src/test/java/oshi/hardware/common/AbstractFirmwareTest.java (1)
15-42: Good baseline coverage forAbstractFirmware.The test validates both default fallback behavior and
toString()content with deterministic fixtures.oshi-common/src/test/java/oshi/hardware/common/AbstractSoundCardTest.java (1)
13-31:AbstractSoundCardtest coverage is solid.Getter and string-format assertions are clear and sufficient for this abstraction-level contract.
oshi-common/src/test/java/oshi/hardware/common/AbstractSensorsTest.java (1)
33-47: Nice coverage for sensor getters and string output.The assertions are deterministic and exercise the key
AbstractSensorscontract paths.oshi-common/src/test/java/oshi/software/common/AbstractOSFileStoreTest.java (1)
65-136: Comprehensive contract checks forAbstractOSFileStore.The test set covers primary getters, default-object behavior, and string representation effectively.
oshi-common/src/test/java/oshi/software/common/AbstractOSThreadTest.java (1)
58-101: Strong coverage for thread CPU-load semantics.This validates both normal and fallback paths (
nullprior, mismatched thread ID) with clear expected values.oshi-common/src/test/java/oshi/software/common/AbstractOSProcessTest.java (1)
171-214:AbstractOSProcesstests look complete for the intended contract.CPU-load calculations and fallback branches are well exercised with deterministic fixtures.
oshi-common/src/main/java/oshi/hardware/common/AbstractDisplay.java (1)
2-2: Metadata-only change is fine.Year range update is consistent and does not affect behavior.
oshi-common/src/main/java/oshi/hardware/common/AbstractBaseboard.java (1)
2-2: Header-only update looks good.This is a metadata-only change and does not affect runtime behavior.
oshi-common/src/main/java/oshi/software/common/AbstractNetworkParams.java (1)
2-2: No issues in this change.Only the copyright range was updated.
oshi-common/src/main/java/oshi/software/common/AbstractInternetProtocolStats.java (1)
2-2: Import migration is correct and consistent.The NetStat dependency now points to the shared
oshi.util.driver.unixpackage while keeping behavior unchanged.Also applies to: 10-10
oshi-common/src/main/java/oshi/software/common/AbstractFileSystem.java (1)
2-2: Looks good.No functional impact from this header update.
oshi-common/src/test/java/oshi/util/driver/unix/WhoTest.java (1)
2-2: Test package relocation is clean.This aligns the test with the new
oshi.util.driver.unixnamespace.Also applies to: 5-5
oshi-core/src/main/java/oshi/driver/mac/Who.java (1)
2-2: Fallback migration is correct.Switching the fallback call to
oshi.util.driver.unix.Who.queryWho()is consistent with the package move and preserves intent.Also applies to: 52-52
oshi-common/src/test/java/oshi/util/driver/unix/NetStatTest.java (1)
2-2: Good namespace update for test relocation.Package change is consistent with the moved
NetStatutility location.Also applies to: 5-5
oshi-core-java25/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsFFM.java (1)
68-68: Import update is correct.The
NetStatreference now points to the shared unix utility package as intended.oshi-common/src/main/java/oshi/util/driver/unix/Who.java (1)
5-5: Package relocation looks correct and consistent.The move to
oshi.util.driver.unixmatches the shared-utility extraction and aligns with updated consumers.oshi-core-java25/pom.xml (1)
79-79: OSGi export cleanup is sensible here.Removing
oshi.hardware.common.*fromoshi-core-java25aligns packaging with the newoshi-commonownership of common abstractions.oshi-core/src/main/java/oshi/driver/unix/freebsd/Who.java (1)
53-53: Fallback target update is correct.Line 53 now points to the shared
oshi.util.driver.unix.Whoutility, which is consistent with the package move.oshi-core/src/main/java/oshi/driver/unix/solaris/Who.java (1)
53-53: Solaris fallback migration is consistent.Switching to
oshi.util.driver.unix.Who.queryWho()correctly follows the shared utility relocation.oshi-common/src/main/java/oshi/util/driver/unix/package-info.java (1)
1-8: Nice addition of package-level docs.This package-info cleanly documents the purpose of the new shared Unix driver utility namespace.
oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.java (1)
19-19: Import path update is correct.Using
oshi.util.driver.unix.NetStatmatches the utility package migration without altering behavior.oshi-common/src/test/java/oshi/hardware/common/AbstractBaseboardTest.java (1)
14-43: Good baseline coverage forAbstractBaseboard#toString().The assertions verify all key fields, which is useful protection for this moved common abstraction.
oshi-core-java25/src/main/java/oshi/driver/mac/WhoFFM.java (1)
66-66: FFM fallback migration is implemented correctly.Both failure paths now consistently use the relocated shared
Whoutility, with existing behavior preserved.Also applies to: 75-75
oshi-common/src/test/java/oshi/util/driver/unix/XwininfoTest.java (1)
5-5: Package/class rename is consistent with the driver relocation.The test now correctly follows the
oshi.util.driver.unixnamespace and target utility naming.Also applies to: 19-19
oshi-core/src/main/java/oshi/software/os/mac/MacInternetProtocolStats.java (1)
49-49: Import relocation looks correct.
NetStatnow points to the sharedoshi.util.driver.unixpackage with no behavior impact.oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java (1)
30-32: Bitness and unix-driver updates are sound.Switching to
Util.is64Bit()keeps common code implementation-agnostic, and theWho/Xwininfoimports align with the new shared package.Also applies to: 71-71
oshi-common/src/test/java/module-info.test (1)
3-10: Test module opens are correctly extended.The new
--add-opensentries match the packages introduced/moved in this PR and support reflective test access.oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java (1)
144-147:queryHwcap()override is clean and appropriate.Using
Auxv.AT_HWCAPwith0Lfallback integrates well with the new hardware-capability-aware processor ID path.oshi-common/src/main/java/module-info.java (1)
9-10: Module exports are correctly updated for the new shared packages.These exports match the moved abstractions and unix utility drivers now consumed by dependent modules.
Also applies to: 13-13
oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java (1)
41-43: FFM HWCAP extraction implementation looks good.The native long-size handling and auxv scan logic are consistent with Linux auxv semantics and provide a sensible
0Lfallback.Also applies to: 45-57, 59-61
oshi-core/src/main/java/oshi/driver/linux/Who.java (1)
81-81: Fallback migration to sharedWhoutility is correct.Both fallback paths now consistently use
oshi.util.driver.unix.Who.queryWho()after the package move.Also applies to: 96-96
oshi-core/src/main/java/oshi/software/os/unix/openbsd/OpenBsdInternetProtocolStats.java (1)
2-9: LGTM!The copyright year update and import relocation from
oshi.driver.unix.NetStattooshi.util.driver.unix.NetStatare consistent with the PR's objective of moving Unix driver utilities tooshi-commonunder the new package namespace.oshi-common/src/test/java/oshi/software/common/AbstractFileSystemTest.java (1)
19-49: LGTM!Clean and focused test that correctly validates the
getFileStores()→getFileStores(false)delegation contract using a call-capturing anonymous implementation.oshi-common/src/test/java/oshi/software/common/AbstractNetworkParamsTest.java (1)
18-58: LGTM!Comprehensive test coverage for
AbstractNetworkParamsincluding hostname/domain defaults,searchGatewayparsing (with interface suffix stripping), empty-list edge case, andtoStringoutput validation.oshi-common/src/test/java/oshi/hardware/common/AbstractDisplayTest.java (1)
14-29: LGTM!Excellent tests for defensive copying behavior—both verifying that constructor input modifications don't leak into the object, and that
getEdid()returns a copy that can be safely modified without affecting internal state.oshi-common/src/test/java/oshi/software/common/AbstractInternetProtocolStatsTest.java (1)
15-43: LGTM!Well-structured tests validating that the default
getTCPv6Stats()andgetUDPv6Stats()implementations return zero-valued statistics. The test double correctly provides v4 implementations while relying on inherited default v6 behavior.oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java (1)
286-301: LGTM!Clean refactor that introduces a new
hwcap-accepting overload while maintaining backward compatibility through delegation. The existing no-argument overload now passes0Las the default hwcap value.oshi-common/src/main/java/oshi/util/driver/unix/NetStat.java (1)
2-5: LGTM!Package relocation from
oshi.driver.unixtooshi.util.driver.unixaligns with the PR objective of moving shared Unix driver utilities intooshi-commonto avoid package collision with platform-specific drivers inoshi-core.oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessor.java (2)
144-144: LGTM!Clean integration of
queryHwcap()into the processor ID generation flow. The template method pattern allows platform-specific subclasses (JNA/FFM) to provide actual hardware capability values while the base class defaults to flag-based encoding.
579-587: LGTM!Well-documented hook method with sensible default behavior. Returning
0Lensures backward compatibility—when not overridden, the processor ID falls back to flag-based encoding increateProcessorID.oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java (2)
77-116: Good coverage for CPU load delta math and validation paths.The tests around Line 78, Line 89, Line 101, and Line 106 exercise both expected load outcomes and invalid input handling well.
126-131: HWCAP encoding check is on point.The assertion at Line 130 directly verifies the expected bit placement behavior for HWCAP.
oshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.java (1)
133-169: Nice behavioral coverage for filtering, sorting, limiting, and memoized fields.The checks around Line 143, Line 149, and Line 156 validate the key
getProcessespaths cleanly.
cc9cbea to
bf25a9e
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (2)
oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java (2)
36-39: Verify null handling for physical processors and caches in the test double.The test double returns
nullforList<PhysicalProcessor>(2nd element) andList<ProcessorCache>(3rd element). While this works ifAbstractCentralProcessorgracefully handles nulls, it could causeNullPointerExceptionin methods that iterate over these lists.Consider using empty lists for safer test isolation:
♻️ Suggested change
`@Override` protected Quartet<List<LogicalProcessor>, List<PhysicalProcessor>, List<ProcessorCache>, List<String>> initProcessorCounts() { - return new Quartet<>(Collections.singletonList(new LogicalProcessor(0, 0, 0)), null, null, + return new Quartet<>(Collections.singletonList(new LogicalProcessor(0, 0, 0)), + Collections.singletonList(new PhysicalProcessor(0, 0, 0, "")), + Collections.emptyList(), Collections.emptyList()); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java` around lines 36 - 39, The test double in AbstractCentralProcessorTest.initProcessorCounts currently returns null for the second and third Quartet elements (List<PhysicalProcessor> and List<ProcessorCache>), which can cause NPEs; update the Quartet construction in initProcessorCounts to return empty lists instead of null (e.g., use Collections.emptyList() for the PhysicalProcessor and ProcessorCache slots) so callers that iterate those lists (via the Quartet from initProcessorCounts) will safely see empty collections.
119-125: Consider making the hex validation assertion explicit.The call to
Long.parseUnsignedLong(id, 16)validates the hex format by throwing on failure, but discarding the result makes the intent less clear.♻️ Optional: explicit assertion
`@Test` void testCreateProcessorIDNoHwcap() { String id = AbstractCentralProcessor.createProcessorID("1", "2", "3", new String[] { "fpu", "sse" }); assertThat(id, is(notNullValue())); assertThat(id.length(), is(16)); - Long.parseUnsignedLong(id, 16); // validates hex + // Validates hex format - should not throw + assertThat(Long.parseUnsignedLong(id, 16) >= 0, is(true)); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java` around lines 119 - 125, The test currently calls Long.parseUnsignedLong(id, 16) and discards the result; make the hex-format validation explicit by wrapping that call in an assertion such as Assertions.assertDoesNotThrow(() -> Long.parseUnsignedLong(id, 16)) (or an equivalent Hamcrest/JUnit assertion) in the testCreateProcessorIDNoHwcap method so the intent of validating that AbstractCentralProcessor.createProcessorID returns a valid hex string is clear and fails with a test assertion instead of an implicit exception.
🤖 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-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java`:
- Around line 36-39: The test double in
AbstractCentralProcessorTest.initProcessorCounts currently returns null for the
second and third Quartet elements (List<PhysicalProcessor> and
List<ProcessorCache>), which can cause NPEs; update the Quartet construction in
initProcessorCounts to return empty lists instead of null (e.g., use
Collections.emptyList() for the PhysicalProcessor and ProcessorCache slots) so
callers that iterate those lists (via the Quartet from initProcessorCounts) will
safely see empty collections.
- Around line 119-125: The test currently calls Long.parseUnsignedLong(id, 16)
and discards the result; make the hex-format validation explicit by wrapping
that call in an assertion such as Assertions.assertDoesNotThrow(() ->
Long.parseUnsignedLong(id, 16)) (or an equivalent Hamcrest/JUnit assertion) in
the testCreateProcessorIDNoHwcap method so the intent of validating that
AbstractCentralProcessor.createProcessorID returns a valid hex string is clear
and fails with a test assertion instead of an implicit exception.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b1e16b71-10b2-4902-b1ae-34403148c932
📒 Files selected for processing (70)
CHANGELOG.mdoshi-common/src/main/java/module-info.javaoshi-common/src/main/java/oshi/hardware/common/AbstractBaseboard.javaoshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/AbstractComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/AbstractDisplay.javaoshi-common/src/main/java/oshi/hardware/common/AbstractFirmware.javaoshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.javaoshi-common/src/main/java/oshi/hardware/common/AbstractGraphicsCard.javaoshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.javaoshi-common/src/main/java/oshi/hardware/common/AbstractHardwareAbstractionLayer.javaoshi-common/src/main/java/oshi/hardware/common/AbstractLogicalVolumeGroup.javaoshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.javaoshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.javaoshi-common/src/main/java/oshi/hardware/common/AbstractPrinter.javaoshi-common/src/main/java/oshi/hardware/common/AbstractSensors.javaoshi-common/src/main/java/oshi/hardware/common/AbstractSoundCard.javaoshi-common/src/main/java/oshi/hardware/common/AbstractUsbDevice.javaoshi-common/src/main/java/oshi/hardware/common/AbstractVirtualMemory.javaoshi-common/src/main/java/oshi/hardware/common/NoOpGpuStats.javaoshi-common/src/main/java/oshi/hardware/common/package-info.javaoshi-common/src/main/java/oshi/software/common/AbstractFileSystem.javaoshi-common/src/main/java/oshi/software/common/AbstractInternetProtocolStats.javaoshi-common/src/main/java/oshi/software/common/AbstractNetworkParams.javaoshi-common/src/main/java/oshi/software/common/AbstractOSFileStore.javaoshi-common/src/main/java/oshi/software/common/AbstractOSProcess.javaoshi-common/src/main/java/oshi/software/common/AbstractOSThread.javaoshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.javaoshi-common/src/main/java/oshi/software/common/package-info.javaoshi-common/src/main/java/oshi/util/driver/unix/NetStat.javaoshi-common/src/main/java/oshi/util/driver/unix/Who.javaoshi-common/src/main/java/oshi/util/driver/unix/Xwininfo.javaoshi-common/src/main/java/oshi/util/driver/unix/package-info.javaoshi-common/src/main/resources/oshi.architecture.propertiesoshi-common/src/main/resources/oshi.linux.filename.propertiesoshi-common/src/main/resources/oshi.macos.versions.propertiesoshi-common/src/main/resources/oshi.propertiesoshi-common/src/main/resources/oshi.vmmacaddr.propertiesoshi-common/src/test/java/module-info.testoshi-common/src/test/java/oshi/hardware/common/AbstractBaseboardTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractDisplayTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractFirmwareTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractGraphicsCardTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractSensorsTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractSoundCardTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.javaoshi-common/src/test/java/oshi/software/common/AbstractFileSystemTest.javaoshi-common/src/test/java/oshi/software/common/AbstractInternetProtocolStatsTest.javaoshi-common/src/test/java/oshi/software/common/AbstractNetworkParamsTest.javaoshi-common/src/test/java/oshi/software/common/AbstractOSFileStoreTest.javaoshi-common/src/test/java/oshi/software/common/AbstractOSProcessTest.javaoshi-common/src/test/java/oshi/software/common/AbstractOSThreadTest.javaoshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.javaoshi-common/src/test/java/oshi/util/driver/unix/NetStatTest.javaoshi-common/src/test/java/oshi/util/driver/unix/WhoTest.javaoshi-common/src/test/java/oshi/util/driver/unix/XwininfoTest.javaoshi-core-java25/pom.xmloshi-core-java25/src/main/java/oshi/driver/mac/WhoFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.javaoshi-core-java25/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsFFM.javaoshi-core/src/main/java/oshi/driver/linux/Who.javaoshi-core/src/main/java/oshi/driver/mac/Who.javaoshi-core/src/main/java/oshi/driver/unix/freebsd/Who.javaoshi-core/src/main/java/oshi/driver/unix/solaris/Who.javaoshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessor.javaoshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacInternetProtocolStats.javaoshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.javaoshi-core/src/main/java/oshi/software/os/unix/openbsd/OpenBsdInternetProtocolStats.java
✅ Files skipped from review due to trivial changes (31)
- oshi-common/src/main/java/oshi/hardware/common/AbstractComputerSystem.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractFirmware.java
- oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractDisplay.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractLogicalVolumeGroup.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractSensors.java
- oshi-common/src/main/java/oshi/software/common/AbstractNetworkParams.java
- oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractGraphicsCard.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractSoundCard.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.java
- oshi-common/src/main/java/oshi/software/common/AbstractFileSystem.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractVirtualMemory.java
- oshi-common/src/main/java/oshi/software/common/AbstractInternetProtocolStats.java
- oshi-common/src/main/java/oshi/util/driver/unix/package-info.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractBaseboardTest.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractBaseboard.java
- oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java
- oshi-common/src/test/java/oshi/util/driver/unix/XwininfoTest.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractSoundCardTest.java
- oshi-core-java25/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsFFM.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractFirmwareTest.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractGraphicsCardTest.java
- CHANGELOG.md
- oshi-common/src/test/java/oshi/software/common/AbstractOSFileStoreTest.java
- oshi-common/src/test/java/oshi/software/common/AbstractFileSystemTest.java
- oshi-common/src/test/java/oshi/software/common/AbstractOSProcessTest.java
- oshi-common/src/test/java/oshi/software/common/AbstractOSThreadTest.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractDisplayTest.java
- oshi-common/src/test/java/oshi/software/common/AbstractInternetProtocolStatsTest.java
🚧 Files skipped from review as they are similar to previous changes (22)
- oshi-common/src/main/java/module-info.java
- oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.java
- oshi-core/src/main/java/oshi/software/os/mac/MacInternetProtocolStats.java
- oshi-common/src/test/java/oshi/util/driver/unix/NetStatTest.java
- oshi-common/src/test/java/oshi/util/driver/unix/WhoTest.java
- oshi-common/src/main/java/oshi/util/driver/unix/Who.java
- oshi-core-java25/src/main/java/oshi/driver/mac/WhoFFM.java
- oshi-core/src/main/java/oshi/driver/unix/solaris/Who.java
- oshi-common/src/test/java/module-info.test
- oshi-common/src/main/java/oshi/util/driver/unix/Xwininfo.java
- oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
- oshi-common/src/test/java/oshi/software/common/AbstractNetworkParamsTest.java
- oshi-core/src/main/java/oshi/software/os/unix/openbsd/OpenBsdInternetProtocolStats.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
- oshi-core/src/main/java/oshi/driver/linux/Who.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractSensorsTest.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.java
- oshi-core/src/main/java/oshi/driver/mac/Who.java
- oshi-core-java25/pom.xml
- oshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.java
- oshi-common/src/main/java/oshi/util/driver/unix/NetStat.java
- oshi-core/src/main/java/oshi/driver/unix/freebsd/Who.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). (1)
- GitHub Check: Codacy Static Code Analysis
🧰 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.
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.
📚 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/linux/LinuxCentralProcessor.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/hardware/platform/linux/LinuxCentralProcessorFFM.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/linux/LinuxCentralProcessorFFM.java
📚 Learning: 2026-04-05T05:40:43.357Z
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:43.357Z
Learning: In OSHI’s Linux FFM implementations (e.g., LinuxPowerSourceFFM, LinuxHWDiskStoreFFM, LinuxLogicalVolumeGroupFFM, LinuxUsbDeviceFFM) and the corresponding JNA udev code, do not require/flag a missing null check around `udev_enumerate_new()`/`enumerateNew()`. Per libudev semantics, `udev_enumerate_new()` returns NULL only if udev itself is broken (e.g., OOM). Since `udev_new()` is already guarded and is the successful prerequisite for enumeration, treating `udev_enumerate_new()` as non-null is consistent with the established pattern; adding a redundant null guard would be inconsistent.
Applied to files:
oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
📚 Learning: 2026-04-05T05:39:18.791Z
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:39:18.791Z
Learning: When reviewing OSHI Linux FFM/JNA code that uses libudev, do not flag a missing null check on `udev_enumerate_new()` if `udev_new()` has already been guarded. Per libudev semantics, `udev_enumerate_new()` returns NULL only when the udev context itself is broken (e.g., OOM), so a successful `udev_new()` implies `udev_enumerate_new()` should succeed as well. Therefore, lack of a redundant null guard on `udev_enumerate_new()` is acceptable in this pattern.
Applied to files:
oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.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/linux/LinuxCentralProcessorFFM.java
🔇 Additional comments (3)
oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java (1)
41-61: LGTM - clean FFM implementation for reading Linux hwcap.The approach correctly handles platform-native
longsize differences using FFM's canonical layouts, and the auxv parsing loop properly terminates onAT_NULL(key == 0). The fallback to0LwhenAT_HWCAPis not found is consistent with the base class default behavior.One minor note: if
/proc/auxvis truncated or unreadable,readNativeLongcould throwBufferUnderflowException. Given that this is a stable kernel interface on functioning Linux systems and the caller would likely catch/handle any throwable, this is acceptable.oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessor.java (1)
144-144: LGTM - clean integration of hwcap into processor ID generation.The refactoring correctly threads the hardware capabilities value through the processor ID flow:
queryHwcap()is properly designed as a protected hook with a safe0Ldefault- The hwcap is only used in the non-DMI encoding path (line 576), which aligns with the ARM/non-x86 processor ID generation
- Subclasses (
LinuxCentralProcessorJNA,LinuxCentralProcessorFFM) can override to provide platform-native implementationsAlso applies to: 576-587
oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java (1)
78-174: Good test coverage for the abstract processor class.The tests comprehensively cover:
- CPU load calculations with boundary cases (full load, half idle, wrong array length)
- Processor ID generation with and without hwcap, verifying the upper 32-bit encoding
- Cache ordering with a realistic Apple Silicon P-core/E-core scenario
- Basic processor count getters and toString output
The test structure is clean and follows good testing practices.
bf25a9e to
b5ba6d0
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
oshi-common/src/test/java/oshi/software/common/AbstractInternetProtocolStatsTest.java (1)
29-42: Consider asserting all zero-valued fields, not only a subset.Current checks validate the main path, but asserting every field in
TcpStats/UdpStatswould better guard against partial default-constructor regressions.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/test/java/oshi/software/common/AbstractInternetProtocolStatsTest.java` around lines 29 - 42, Extend the two tests so they assert every zero-valued accessor on the TcpStats and UdpStats objects instead of only a subset: in testDefaultTCPv6StatsAllZeros call and assert is(0L) for getConnectionsEstablished(), getConnectionsActive(), getConnectionsPassive(), getFailedConnectionAttempts(), getSegmentsSent(), getSegmentsReceived(), getRetransmittedSegments(), getInErrors(), getOutResets() (or all other TcpStats getters present); in testDefaultUDPv6StatsAllZeros assert is(0L) for getDatagramsSent(), getDatagramsReceived(), getInboundErrors(), getOutboundErrors() (and any other UdpStats getters in the class) so every field exposed by TcpStats and UdpStats is validated as zero.
🤖 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/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java`:
- Around line 128-134: Add a second regression test in
AbstractCentralProcessorTest that calls
AbstractCentralProcessor.createProcessorID with a hwcap value that has the
high/sign bit set (for example 0x80000000L) and assert the returned hex id is 16
chars and that Long.parseUnsignedLong(id, 16) shifted right by 32 equals that
hwcap value; place it alongside testCreateProcessorIDWithHwcap to ensure
signed/high-bit hwcap inputs are handled correctly.
---
Nitpick comments:
In
`@oshi-common/src/test/java/oshi/software/common/AbstractInternetProtocolStatsTest.java`:
- Around line 29-42: Extend the two tests so they assert every zero-valued
accessor on the TcpStats and UdpStats objects instead of only a subset: in
testDefaultTCPv6StatsAllZeros call and assert is(0L) for
getConnectionsEstablished(), getConnectionsActive(), getConnectionsPassive(),
getFailedConnectionAttempts(), getSegmentsSent(), getSegmentsReceived(),
getRetransmittedSegments(), getInErrors(), getOutResets() (or all other TcpStats
getters present); in testDefaultUDPv6StatsAllZeros assert is(0L) for
getDatagramsSent(), getDatagramsReceived(), getInboundErrors(),
getOutboundErrors() (and any other UdpStats getters in the class) so every field
exposed by TcpStats and UdpStats is validated as zero.
🪄 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: af6ec5c3-990d-40a7-93d4-2b43ca3d133f
📒 Files selected for processing (70)
CHANGELOG.mdoshi-common/src/main/java/module-info.javaoshi-common/src/main/java/oshi/hardware/common/AbstractBaseboard.javaoshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/AbstractComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/AbstractDisplay.javaoshi-common/src/main/java/oshi/hardware/common/AbstractFirmware.javaoshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.javaoshi-common/src/main/java/oshi/hardware/common/AbstractGraphicsCard.javaoshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.javaoshi-common/src/main/java/oshi/hardware/common/AbstractHardwareAbstractionLayer.javaoshi-common/src/main/java/oshi/hardware/common/AbstractLogicalVolumeGroup.javaoshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.javaoshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.javaoshi-common/src/main/java/oshi/hardware/common/AbstractPrinter.javaoshi-common/src/main/java/oshi/hardware/common/AbstractSensors.javaoshi-common/src/main/java/oshi/hardware/common/AbstractSoundCard.javaoshi-common/src/main/java/oshi/hardware/common/AbstractUsbDevice.javaoshi-common/src/main/java/oshi/hardware/common/AbstractVirtualMemory.javaoshi-common/src/main/java/oshi/hardware/common/NoOpGpuStats.javaoshi-common/src/main/java/oshi/hardware/common/package-info.javaoshi-common/src/main/java/oshi/software/common/AbstractFileSystem.javaoshi-common/src/main/java/oshi/software/common/AbstractInternetProtocolStats.javaoshi-common/src/main/java/oshi/software/common/AbstractNetworkParams.javaoshi-common/src/main/java/oshi/software/common/AbstractOSFileStore.javaoshi-common/src/main/java/oshi/software/common/AbstractOSProcess.javaoshi-common/src/main/java/oshi/software/common/AbstractOSThread.javaoshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.javaoshi-common/src/main/java/oshi/software/common/package-info.javaoshi-common/src/main/java/oshi/util/driver/unix/NetStat.javaoshi-common/src/main/java/oshi/util/driver/unix/Who.javaoshi-common/src/main/java/oshi/util/driver/unix/Xwininfo.javaoshi-common/src/main/java/oshi/util/driver/unix/package-info.javaoshi-common/src/main/resources/oshi.architecture.propertiesoshi-common/src/main/resources/oshi.linux.filename.propertiesoshi-common/src/main/resources/oshi.macos.versions.propertiesoshi-common/src/main/resources/oshi.propertiesoshi-common/src/main/resources/oshi.vmmacaddr.propertiesoshi-common/src/test/java/module-info.testoshi-common/src/test/java/oshi/hardware/common/AbstractBaseboardTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractDisplayTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractFirmwareTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractGraphicsCardTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractSensorsTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractSoundCardTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.javaoshi-common/src/test/java/oshi/software/common/AbstractFileSystemTest.javaoshi-common/src/test/java/oshi/software/common/AbstractInternetProtocolStatsTest.javaoshi-common/src/test/java/oshi/software/common/AbstractNetworkParamsTest.javaoshi-common/src/test/java/oshi/software/common/AbstractOSFileStoreTest.javaoshi-common/src/test/java/oshi/software/common/AbstractOSProcessTest.javaoshi-common/src/test/java/oshi/software/common/AbstractOSThreadTest.javaoshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.javaoshi-common/src/test/java/oshi/util/driver/unix/NetStatTest.javaoshi-common/src/test/java/oshi/util/driver/unix/WhoTest.javaoshi-common/src/test/java/oshi/util/driver/unix/XwininfoTest.javaoshi-core-java25/pom.xmloshi-core-java25/src/main/java/oshi/driver/mac/WhoFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.javaoshi-core-java25/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsFFM.javaoshi-core/src/main/java/oshi/driver/linux/Who.javaoshi-core/src/main/java/oshi/driver/mac/Who.javaoshi-core/src/main/java/oshi/driver/unix/freebsd/Who.javaoshi-core/src/main/java/oshi/driver/unix/solaris/Who.javaoshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessor.javaoshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacInternetProtocolStats.javaoshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.javaoshi-core/src/main/java/oshi/software/os/unix/openbsd/OpenBsdInternetProtocolStats.java
✅ Files skipped from review due to trivial changes (30)
- oshi-common/src/main/java/oshi/hardware/common/AbstractSensors.java
- oshi-common/src/main/java/oshi/software/common/AbstractFileSystem.java
- oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractLogicalVolumeGroup.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractComputerSystem.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractVirtualMemory.java
- oshi-common/src/main/java/oshi/software/common/AbstractNetworkParams.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractDisplay.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractSoundCard.java
- oshi-common/src/main/java/module-info.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractGraphicsCard.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractBaseboard.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractFirmware.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractBaseboardTest.java
- oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
- oshi-common/src/main/java/oshi/software/common/AbstractInternetProtocolStats.java
- oshi-common/src/main/java/oshi/util/driver/unix/package-info.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractSoundCardTest.java
- oshi-common/src/test/java/oshi/software/common/AbstractFileSystemTest.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractFirmwareTest.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractGraphicsCardTest.java
- oshi-common/src/test/java/oshi/util/driver/unix/XwininfoTest.java
- oshi-core/src/main/java/oshi/software/os/unix/openbsd/OpenBsdInternetProtocolStats.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractSensorsTest.java
- CHANGELOG.md
- oshi-common/src/test/java/oshi/software/common/AbstractOSFileStoreTest.java
- oshi-common/src/test/java/oshi/software/common/AbstractOSThreadTest.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.java
🚧 Files skipped from review as they are similar to previous changes (19)
- oshi-common/src/main/java/oshi/util/driver/unix/Who.java
- oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.java
- oshi-core-java25/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsFFM.java
- oshi-common/src/test/java/oshi/util/driver/unix/NetStatTest.java
- oshi-core/src/main/java/oshi/driver/unix/freebsd/Who.java
- oshi-core/src/main/java/oshi/driver/unix/solaris/Who.java
- oshi-core-java25/src/main/java/oshi/driver/mac/WhoFFM.java
- oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java
- oshi-core/src/main/java/oshi/software/os/mac/MacInternetProtocolStats.java
- oshi-common/src/test/java/module-info.test
- oshi-core/src/main/java/oshi/driver/mac/Who.java
- oshi-core-java25/pom.xml
- oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
- oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractDisplayTest.java
- oshi-common/src/main/java/oshi/util/driver/unix/Xwininfo.java
- oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
- oshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.java
- oshi-common/src/main/java/oshi/util/driver/unix/NetStat.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). (4)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 25, macos-latest
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
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.
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-common/src/test/java/oshi/util/driver/unix/WhoTest.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/test/java/oshi/util/driver/unix/WhoTest.javaoshi-core/src/main/java/oshi/driver/linux/Who.java
📚 Learning: 2026-04-05T05:39:21.126Z
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:39:21.126Z
Learning: In OSHI's Linux FFM/JNA udev code, a null guard on `udev_enumerate_new()` is unnecessary if `udev_new()` has already been guarded: per libudev semantics, `udev_enumerate_new()` only returns NULL when udev itself is broken (e.g. OOM), so a successful `udev_new()` implies `udev_enumerate_new()` will succeed as well. Do not flag missing null checks on `udev_enumerate_new()` as an issue.
Applied to files:
oshi-core/src/main/java/oshi/driver/linux/Who.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/linux/LinuxCentralProcessor.java
🔇 Additional comments (10)
oshi-common/src/test/java/oshi/util/driver/unix/WhoTest.java (1)
2-5: Package migration in test file looks correct.
WhoTestnow lives underoshi.util.driver.unix, which matches the movedWhoutility location and keeps this test aligned with the new module layout.oshi-core/src/main/java/oshi/driver/linux/Who.java (2)
81-82: Fallback target update is correct and safely resolves package migration.Switching both fallback paths to
oshi.util.driver.unix.Who.queryWho()is the right fix after moving Unix driver utilities tooshi-common, and keeps Linux behavior consistent with other Unix implementations.Also applies to: 96-97
7-9: Import updates are clean and consistent with current usage.The static/object import reshuffle matches symbols used in this class and keeps the file aligned with the refactored dependencies.
Also applies to: 21-21, 24-25
oshi-common/src/test/java/oshi/software/common/AbstractOSProcessTest.java (3)
22-169: DeterministicAbstractOSProcessfixture is well-constructed.The helper gives stable inputs and cleanly isolates CPU/time behavior under test, which keeps these assertions robust.
176-206: CPU-load branch coverage is solid.These cases exercise both normal and fallback paths (
nulland mismatched PID prior), which meaningfully strengthens regression protection.
209-213:toString()assertions check the right contract surface.Verifying both
processIDandnameis a good minimal guard for object representation.oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessor.java (3)
144-144: LGTM!The integration of
queryHwcap()into the processor ID generation is well-designed. The call here provides the hardware capabilities value thatcreateProcessorIDuses to encode platform-specific information. The default return of0Lensures backward compatibility by falling back to flag-based encoding.
541-577: LGTM!The updated method signature and documentation correctly reflect the hwcap parameter flow. The
hwcapvalue is appropriately forwarded tocreateProcessorIDfor the non-ARM path, while ARM processors continue using MIDR encoding as before.
579-587: LGTM!Clean extension point for platform-specific hardware capability queries. The default return of
0Lcorrectly triggers fallback to flag-based processor ID encoding increateProcessorID. The JNA and FFM subclasses appropriately override this to read from the auxiliary vector.oshi-common/src/test/java/oshi/software/common/AbstractNetworkParamsTest.java (1)
34-58: Nice focused coverage of default and parsing behavior.These tests validate both environmental defaults and
searchGatewayparsing (including%ifacesuffix stripping) without overfitting.
b5ba6d0 to
167494e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
oshi-common/src/test/java/oshi/software/common/AbstractOSThreadTest.java (1)
74-93: Consider covering the remaining guard branches ingetThreadCpuLoadBetweenTicks.Adding tests for owner PID mismatch and equal/lower uptime would complete branch coverage for fallback-to-cumulative logic.
✅ Suggested test additions
+ `@Test` + void testCpuLoadBetweenTicksDifferentOwnerFallsToCumulative() { + AbstractOSThread prior = createThread(99, 10, 100, 100, 1000); + AbstractOSThread current = createThread(1, 10, 400, 600, 2000); + assertThat(current.getThreadCpuLoadBetweenTicks(prior), is(closeTo(0.5, 0.001))); + } + + `@Test` + void testCpuLoadBetweenTicksNonIncreasingUptimeFallsToCumulative() { + AbstractOSThread prior = createThread(1, 10, 100, 100, 2000); + AbstractOSThread current = createThread(1, 10, 400, 600, 2000); + assertThat(current.getThreadCpuLoadBetweenTicks(prior), is(closeTo(0.5, 0.001))); + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/test/java/oshi/software/common/AbstractOSThreadTest.java` around lines 74 - 93, Add two unit tests for getThreadCpuLoadBetweenTicks to hit the remaining guard branches: one where the prior thread has a different owner PID (use createThread to construct prior with ownerPid != current.ownerPid) and assert the result falls back to cumulative load (match expected cumulative calculation from current.getThreadCpuLoad()); and another where prior.upTime is greater-than-or-equal-to current.upTime (use createThread to make prior.upTime == current.upTime or prior.upTime > current.upTime) and assert it also falls back to the cumulative value. Use the same assertThat/closeTo pattern as the existing tests and reference AbstractOSThread/getThreadCpuLoadBetweenTicks and createThread to locate the code.oshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.java (1)
134-141: Test name/intent mismatch:testMemoizedFieldsdoesn’t assert memoization yet.Either rename to reflect value checks only, or add repeated calls with invocation-count assertions to verify caching behavior explicitly.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.java` around lines 134 - 141, The test named testMemoizedFields currently only asserts field values; either rename it to something like testFieldValues or update it to verify memoization by invoking the same accessors twice and asserting caching: call getManufacturer(), getFamily(), getVersionInfo(), and getBitness() twice and assert the results are equal and, where applicable, identical (e.g., assertSame for getVersionInfo() to ensure the same instance is returned), and if the OS implementation exposes invocation counters use them to assert the underlying computation was performed only once; update the test method name or add these repeated-invocation assertions in AbstractOperatingSystemTest.testMemoizedFields accordingly.oshi-common/src/test/java/oshi/software/common/AbstractOSProcessTest.java (1)
187-206: Add a non-increasing-uptime fallback test for between-ticks load.A small edge-case test for same PID with equal/lower uptime would lock in the
getUpTime() > prior.getUpTime()guard behavior.✅ Suggested test addition
+ `@Test` + void testCpuLoadBetweenTicksNonIncreasingUptimeFallsToCumulative() { + AbstractOSProcess prior = createProcess(1, 100, 100, 2000); + AbstractOSProcess current = createProcess(1, 300, 700, 2000); + assertThat(current.getProcessCpuLoadBetweenTicks(prior), is(closeTo(0.5, 0.001))); + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/test/java/oshi/software/common/AbstractOSProcessTest.java` around lines 187 - 206, Add a test in AbstractOSProcessTest that verifies when prior has the same PID but non-increasing uptime (equal or lower) the method falls back to the cumulative calculation: create a prior via createProcess with the same PID and uptime >= current.getUpTime(), create a current via createProcess with that PID and lower/equal uptime, then assert current.getProcessCpuLoadBetweenTicks(prior) matches current.getProcessCpuLoadBetweenTicks(null) (use is(closeTo(..., 0.001)) like the other tests) to lock in the getUpTime() > prior.getUpTime() guard behavior; reference the existing tests and methods (createProcess, getProcessCpuLoadBetweenTicks, getUpTime) when adding the new test (e.g., name it testCpuLoadBetweenTicksNonIncreasingUptimeFallsToCumulative).
🤖 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/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java`:
- Around line 129-143: In the test methods testCreateProcessorIDWithHwcap and
testCreateProcessorIDWithHighBitHwcap (calling
AbstractCentralProcessor.createProcessorID), change the bit extraction of the
high 32 bits from a signed right shift (>>) to an unsigned right shift (>>>)
when parsing the hex id: after Long.parseUnsignedLong(id, 16) use parsed >>> 32
to compare against the original hwcap so high-bit values like 0x80000000L are
not sign-extended to negative values.
---
Nitpick comments:
In
`@oshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.java`:
- Around line 134-141: The test named testMemoizedFields currently only asserts
field values; either rename it to something like testFieldValues or update it to
verify memoization by invoking the same accessors twice and asserting caching:
call getManufacturer(), getFamily(), getVersionInfo(), and getBitness() twice
and assert the results are equal and, where applicable, identical (e.g.,
assertSame for getVersionInfo() to ensure the same instance is returned), and if
the OS implementation exposes invocation counters use them to assert the
underlying computation was performed only once; update the test method name or
add these repeated-invocation assertions in
AbstractOperatingSystemTest.testMemoizedFields accordingly.
In `@oshi-common/src/test/java/oshi/software/common/AbstractOSProcessTest.java`:
- Around line 187-206: Add a test in AbstractOSProcessTest that verifies when
prior has the same PID but non-increasing uptime (equal or lower) the method
falls back to the cumulative calculation: create a prior via createProcess with
the same PID and uptime >= current.getUpTime(), create a current via
createProcess with that PID and lower/equal uptime, then assert
current.getProcessCpuLoadBetweenTicks(prior) matches
current.getProcessCpuLoadBetweenTicks(null) (use is(closeTo(..., 0.001)) like
the other tests) to lock in the getUpTime() > prior.getUpTime() guard behavior;
reference the existing tests and methods (createProcess,
getProcessCpuLoadBetweenTicks, getUpTime) when adding the new test (e.g., name
it testCpuLoadBetweenTicksNonIncreasingUptimeFallsToCumulative).
In `@oshi-common/src/test/java/oshi/software/common/AbstractOSThreadTest.java`:
- Around line 74-93: Add two unit tests for getThreadCpuLoadBetweenTicks to hit
the remaining guard branches: one where the prior thread has a different owner
PID (use createThread to construct prior with ownerPid != current.ownerPid) and
assert the result falls back to cumulative load (match expected cumulative
calculation from current.getThreadCpuLoad()); and another where prior.upTime is
greater-than-or-equal-to current.upTime (use createThread to make prior.upTime
== current.upTime or prior.upTime > current.upTime) and assert it also falls
back to the cumulative value. Use the same assertThat/closeTo pattern as the
existing tests and reference AbstractOSThread/getThreadCpuLoadBetweenTicks and
createThread to locate the code.
🪄 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: 640edf16-def6-4413-9f36-fa08816bdf4a
📒 Files selected for processing (70)
CHANGELOG.mdoshi-common/src/main/java/module-info.javaoshi-common/src/main/java/oshi/hardware/common/AbstractBaseboard.javaoshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/AbstractComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/AbstractDisplay.javaoshi-common/src/main/java/oshi/hardware/common/AbstractFirmware.javaoshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.javaoshi-common/src/main/java/oshi/hardware/common/AbstractGraphicsCard.javaoshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.javaoshi-common/src/main/java/oshi/hardware/common/AbstractHardwareAbstractionLayer.javaoshi-common/src/main/java/oshi/hardware/common/AbstractLogicalVolumeGroup.javaoshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.javaoshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.javaoshi-common/src/main/java/oshi/hardware/common/AbstractPrinter.javaoshi-common/src/main/java/oshi/hardware/common/AbstractSensors.javaoshi-common/src/main/java/oshi/hardware/common/AbstractSoundCard.javaoshi-common/src/main/java/oshi/hardware/common/AbstractUsbDevice.javaoshi-common/src/main/java/oshi/hardware/common/AbstractVirtualMemory.javaoshi-common/src/main/java/oshi/hardware/common/NoOpGpuStats.javaoshi-common/src/main/java/oshi/hardware/common/package-info.javaoshi-common/src/main/java/oshi/software/common/AbstractFileSystem.javaoshi-common/src/main/java/oshi/software/common/AbstractInternetProtocolStats.javaoshi-common/src/main/java/oshi/software/common/AbstractNetworkParams.javaoshi-common/src/main/java/oshi/software/common/AbstractOSFileStore.javaoshi-common/src/main/java/oshi/software/common/AbstractOSProcess.javaoshi-common/src/main/java/oshi/software/common/AbstractOSThread.javaoshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.javaoshi-common/src/main/java/oshi/software/common/package-info.javaoshi-common/src/main/java/oshi/util/driver/unix/NetStat.javaoshi-common/src/main/java/oshi/util/driver/unix/Who.javaoshi-common/src/main/java/oshi/util/driver/unix/Xwininfo.javaoshi-common/src/main/java/oshi/util/driver/unix/package-info.javaoshi-common/src/main/resources/oshi.architecture.propertiesoshi-common/src/main/resources/oshi.linux.filename.propertiesoshi-common/src/main/resources/oshi.macos.versions.propertiesoshi-common/src/main/resources/oshi.propertiesoshi-common/src/main/resources/oshi.vmmacaddr.propertiesoshi-common/src/test/java/module-info.testoshi-common/src/test/java/oshi/hardware/common/AbstractBaseboardTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractDisplayTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractFirmwareTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractGraphicsCardTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractSensorsTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractSoundCardTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.javaoshi-common/src/test/java/oshi/software/common/AbstractFileSystemTest.javaoshi-common/src/test/java/oshi/software/common/AbstractInternetProtocolStatsTest.javaoshi-common/src/test/java/oshi/software/common/AbstractNetworkParamsTest.javaoshi-common/src/test/java/oshi/software/common/AbstractOSFileStoreTest.javaoshi-common/src/test/java/oshi/software/common/AbstractOSProcessTest.javaoshi-common/src/test/java/oshi/software/common/AbstractOSThreadTest.javaoshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.javaoshi-common/src/test/java/oshi/util/driver/unix/NetStatTest.javaoshi-common/src/test/java/oshi/util/driver/unix/WhoTest.javaoshi-common/src/test/java/oshi/util/driver/unix/XwininfoTest.javaoshi-core-java25/pom.xmloshi-core-java25/src/main/java/oshi/driver/mac/WhoFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.javaoshi-core-java25/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsFFM.javaoshi-core/src/main/java/oshi/driver/linux/Who.javaoshi-core/src/main/java/oshi/driver/mac/Who.javaoshi-core/src/main/java/oshi/driver/unix/freebsd/Who.javaoshi-core/src/main/java/oshi/driver/unix/solaris/Who.javaoshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessor.javaoshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacInternetProtocolStats.javaoshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.javaoshi-core/src/main/java/oshi/software/os/unix/openbsd/OpenBsdInternetProtocolStats.java
✅ Files skipped from review due to trivial changes (32)
- oshi-common/src/main/java/oshi/hardware/common/AbstractLogicalVolumeGroup.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractDisplay.java
- oshi-common/src/main/java/module-info.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractVirtualMemory.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractBaseboard.java
- oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractFirmware.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractSoundCard.java
- oshi-common/src/main/java/oshi/software/common/AbstractNetworkParams.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractSensors.java
- oshi-common/src/test/java/oshi/util/driver/unix/WhoTest.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractGraphicsCard.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.java
- oshi-common/src/main/java/oshi/software/common/AbstractInternetProtocolStats.java
- oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java
- oshi-common/src/main/java/oshi/util/driver/unix/Who.java
- oshi-common/src/main/java/oshi/util/driver/unix/package-info.java
- oshi-core/src/main/java/oshi/software/os/mac/MacInternetProtocolStats.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractSoundCardTest.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractBaseboardTest.java
- oshi-common/src/test/java/oshi/software/common/AbstractFileSystemTest.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractGraphicsCardTest.java
- CHANGELOG.md
- oshi-common/src/main/java/oshi/hardware/common/AbstractComputerSystem.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractSensorsTest.java
- oshi-core/src/main/java/oshi/software/os/unix/openbsd/OpenBsdInternetProtocolStats.java
- oshi-common/src/test/java/oshi/software/common/AbstractNetworkParamsTest.java
- oshi-common/src/test/java/oshi/software/common/AbstractOSFileStoreTest.java
- oshi-common/src/test/java/oshi/software/common/AbstractInternetProtocolStatsTest.java
- oshi-common/src/test/java/oshi/util/driver/unix/XwininfoTest.java
- oshi-common/src/main/java/oshi/software/common/AbstractFileSystem.java
🚧 Files skipped from review as they are similar to previous changes (17)
- oshi-core/src/main/java/oshi/driver/mac/Who.java
- oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java
- oshi-common/src/main/java/oshi/util/driver/unix/Xwininfo.java
- oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.java
- oshi-common/src/test/java/oshi/util/driver/unix/NetStatTest.java
- oshi-core/src/main/java/oshi/driver/unix/freebsd/Who.java
- oshi-core/src/main/java/oshi/driver/unix/solaris/Who.java
- oshi-core-java25/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsFFM.java
- oshi-common/src/test/java/module-info.test
- oshi-common/src/test/java/oshi/hardware/common/AbstractFirmwareTest.java
- oshi-core-java25/pom.xml
- oshi-common/src/test/java/oshi/hardware/common/AbstractDisplayTest.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
- oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.java
- oshi-common/src/main/java/oshi/util/driver/unix/NetStat.java
- oshi-core-java25/src/main/java/oshi/driver/mac/WhoFFM.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). (3)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (5)
📓 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: 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.
📚 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/linux/LinuxCentralProcessorJNA.javaoshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessor.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-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.javaoshi-core/src/main/java/oshi/driver/linux/Who.java
📚 Learning: 2026-04-05T05:39:21.126Z
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:39:21.126Z
Learning: In OSHI's Linux FFM/JNA udev code, a null guard on `udev_enumerate_new()` is unnecessary if `udev_new()` has already been guarded: per libudev semantics, `udev_enumerate_new()` only returns NULL when udev itself is broken (e.g. OOM), so a successful `udev_new()` implies `udev_enumerate_new()` will succeed as well. Do not flag missing null checks on `udev_enumerate_new()` as an issue.
Applied to files:
oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.javaoshi-core/src/main/java/oshi/driver/linux/Who.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/test/java/oshi/software/common/AbstractOperatingSystemTest.java
🔇 Additional comments (8)
oshi-core/src/main/java/oshi/driver/linux/Who.java (2)
7-9: Import updates are clean and consistent.These changes are non-functional and align with current symbol usage in this file.
Also applies to: 21-21, 24-25
81-81: Fallback target migration is correct.Both fallback paths now point to
oshi.util.driver.unix.Who.queryWho(), which matches the module/package move and keeps behavior consistent.Also applies to: 96-96
oshi-common/src/test/java/oshi/software/common/AbstractOSProcessTest.java (1)
171-213: Solid coverage forAbstractOSProcesscore behavior.These tests validate the key CPU-load formulas and fallback paths clearly, and the
toString()assertions are practical and stable.oshi-common/src/test/java/oshi/software/common/AbstractOSThreadTest.java (1)
63-100: Good baseline assertions forAbstractOSThread.The test matrix is clean and deterministic for cumulative and between-ticks CPU-load behavior.
oshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.java (1)
172-199:getChildrenOrDescendantstests are well-targeted.Immediate-children and full-descendant cases both validate expected set semantics without order coupling.
oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java (1)
146-170: Cache-ordering test update looks solid.The tie-aware grouping assertions are a good fit for the current comparator behavior and avoid brittle within-group ordering assumptions.
oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java (1)
144-147: Nice hwcap hook override.This is a clean platform-specific implementation with a safe zero fallback when AUXV doesn’t provide
AT_HWCAP.oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessor.java (1)
144-145: Good end-to-end hwcap propagation.The new
queryHwcap()hook + default0L+ forwarding intocreateProcessorID(..., hwcap)is well-scoped and keeps backward behavior intact for non-overriding paths.Also applies to: 544-577, 579-587
Move shared abstract classes (hardware.common, software.common) and
cross-platform Unix driver utilities (NetStat, Who, Xwininfo) from
oshi-core into oshi-common so both oshi-core (JNA) and
oshi-core-java25 (FFM) can depend on them without duplication.
- Move oshi.hardware.common.* to oshi-common
- Move oshi.software.common.* to oshi-common
- Move oshi.driver.unix.{NetStat,Who,Xwininfo} to
oshi.util.driver.unix in oshi-common
- Update module-info.java exports for new packages
- Update all imports in oshi-core and oshi-core-java25
- Migrate and enhance tests into oshi-common
Signed-off-by: Daniel Widdis <[email protected]>
167494e to
1e1231a
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
oshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.java (1)
43-50: StrengthencompareTocontract coverage.Consider also asserting reverse ordering and self-equality so the test validates more of the comparator contract.
♻️ Suggested enhancement
`@Test` void testCompareTo() { AbstractUsbDevice a = new AbstractUsbDevice("Alpha", "", "", "", "", "", Collections.emptyList()) { }; AbstractUsbDevice b = new AbstractUsbDevice("Beta", "", "", "", "", "", Collections.emptyList()) { }; assertThat(a.compareTo(b), is(lessThan(0))); + assertThat(b.compareTo(a), is(lessThan(1))); + assertThat(a.compareTo(a), is(0)); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.java` around lines 43 - 50, Expand the testCompareTo in AbstractUsbDeviceTest to cover the full comparator contract: after the existing assert on a.compareTo(b) being lessThan(0), add assertions that b.compareTo(a) is greaterThan(0) and that a.compareTo(a) equals 0 (self-equality). Locate the test method testCompareTo and the AbstractUsbDevice instances (variables a and b) to add these two assertions using the same assertion style (e.g., assertThat with greaterThan(0) and equalTo(0)/is(0)).
🤖 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-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.java`:
- Around line 43-50: Expand the testCompareTo in AbstractUsbDeviceTest to cover
the full comparator contract: after the existing assert on a.compareTo(b) being
lessThan(0), add assertions that b.compareTo(a) is greaterThan(0) and that
a.compareTo(a) equals 0 (self-equality). Locate the test method testCompareTo
and the AbstractUsbDevice instances (variables a and b) to add these two
assertions using the same assertion style (e.g., assertThat with greaterThan(0)
and equalTo(0)/is(0)).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 50d3ff57-536f-4ff8-8f4a-35cb8281f832
📒 Files selected for processing (70)
CHANGELOG.mdoshi-common/src/main/java/module-info.javaoshi-common/src/main/java/oshi/hardware/common/AbstractBaseboard.javaoshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/AbstractComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/AbstractDisplay.javaoshi-common/src/main/java/oshi/hardware/common/AbstractFirmware.javaoshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.javaoshi-common/src/main/java/oshi/hardware/common/AbstractGraphicsCard.javaoshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.javaoshi-common/src/main/java/oshi/hardware/common/AbstractHardwareAbstractionLayer.javaoshi-common/src/main/java/oshi/hardware/common/AbstractLogicalVolumeGroup.javaoshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.javaoshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.javaoshi-common/src/main/java/oshi/hardware/common/AbstractPrinter.javaoshi-common/src/main/java/oshi/hardware/common/AbstractSensors.javaoshi-common/src/main/java/oshi/hardware/common/AbstractSoundCard.javaoshi-common/src/main/java/oshi/hardware/common/AbstractUsbDevice.javaoshi-common/src/main/java/oshi/hardware/common/AbstractVirtualMemory.javaoshi-common/src/main/java/oshi/hardware/common/NoOpGpuStats.javaoshi-common/src/main/java/oshi/hardware/common/package-info.javaoshi-common/src/main/java/oshi/software/common/AbstractFileSystem.javaoshi-common/src/main/java/oshi/software/common/AbstractInternetProtocolStats.javaoshi-common/src/main/java/oshi/software/common/AbstractNetworkParams.javaoshi-common/src/main/java/oshi/software/common/AbstractOSFileStore.javaoshi-common/src/main/java/oshi/software/common/AbstractOSProcess.javaoshi-common/src/main/java/oshi/software/common/AbstractOSThread.javaoshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.javaoshi-common/src/main/java/oshi/software/common/package-info.javaoshi-common/src/main/java/oshi/util/driver/unix/NetStat.javaoshi-common/src/main/java/oshi/util/driver/unix/Who.javaoshi-common/src/main/java/oshi/util/driver/unix/Xwininfo.javaoshi-common/src/main/java/oshi/util/driver/unix/package-info.javaoshi-common/src/main/resources/oshi.architecture.propertiesoshi-common/src/main/resources/oshi.linux.filename.propertiesoshi-common/src/main/resources/oshi.macos.versions.propertiesoshi-common/src/main/resources/oshi.propertiesoshi-common/src/main/resources/oshi.vmmacaddr.propertiesoshi-common/src/test/java/module-info.testoshi-common/src/test/java/oshi/hardware/common/AbstractBaseboardTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractDisplayTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractFirmwareTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractGraphicsCardTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractSensorsTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractSoundCardTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.javaoshi-common/src/test/java/oshi/software/common/AbstractFileSystemTest.javaoshi-common/src/test/java/oshi/software/common/AbstractInternetProtocolStatsTest.javaoshi-common/src/test/java/oshi/software/common/AbstractNetworkParamsTest.javaoshi-common/src/test/java/oshi/software/common/AbstractOSFileStoreTest.javaoshi-common/src/test/java/oshi/software/common/AbstractOSProcessTest.javaoshi-common/src/test/java/oshi/software/common/AbstractOSThreadTest.javaoshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.javaoshi-common/src/test/java/oshi/util/driver/unix/NetStatTest.javaoshi-common/src/test/java/oshi/util/driver/unix/WhoTest.javaoshi-common/src/test/java/oshi/util/driver/unix/XwininfoTest.javaoshi-core-java25/pom.xmloshi-core-java25/src/main/java/oshi/driver/mac/WhoFFM.javaoshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.javaoshi-core-java25/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsFFM.javaoshi-core/src/main/java/oshi/driver/linux/Who.javaoshi-core/src/main/java/oshi/driver/mac/Who.javaoshi-core/src/main/java/oshi/driver/unix/freebsd/Who.javaoshi-core/src/main/java/oshi/driver/unix/solaris/Who.javaoshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessor.javaoshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacInternetProtocolStats.javaoshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.javaoshi-core/src/main/java/oshi/software/os/unix/openbsd/OpenBsdInternetProtocolStats.java
✅ Files skipped from review due to trivial changes (30)
- oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractComputerSystem.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractBaseboard.java
- oshi-common/src/main/java/oshi/software/common/AbstractFileSystem.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractSoundCard.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractVirtualMemory.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractFirmware.java
- oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractSensors.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java
- oshi-common/src/main/java/oshi/software/common/AbstractNetworkParams.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractLogicalVolumeGroup.java
- oshi-common/src/main/java/oshi/software/common/AbstractInternetProtocolStats.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.java
- oshi-common/src/main/java/oshi/util/driver/unix/package-info.java
- oshi-common/src/test/java/module-info.test
- oshi-common/src/main/java/oshi/hardware/common/AbstractDisplay.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractSoundCardTest.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractBaseboardTest.java
- oshi-core/src/main/java/oshi/driver/unix/freebsd/Who.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractGraphicsCard.java
- oshi-common/src/main/java/module-info.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractGraphicsCardTest.java
- oshi-common/src/test/java/oshi/software/common/AbstractFileSystemTest.java
- oshi-common/src/test/java/oshi/util/driver/unix/WhoTest.java
- oshi-common/src/test/java/oshi/software/common/AbstractOSFileStoreTest.java
- oshi-common/src/test/java/oshi/software/common/AbstractOSThreadTest.java
- oshi-core/src/main/java/oshi/software/os/unix/openbsd/OpenBsdInternetProtocolStats.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractSensorsTest.java
- oshi-common/src/main/java/oshi/util/driver/unix/NetStat.java
🚧 Files skipped from review as they are similar to previous changes (19)
- oshi-common/src/main/java/oshi/util/driver/unix/Xwininfo.java
- oshi-core/src/main/java/oshi/driver/mac/Who.java
- oshi-common/src/test/java/oshi/util/driver/unix/NetStatTest.java
- oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java
- oshi-common/src/main/java/oshi/util/driver/unix/Who.java
- oshi-core-java25/pom.xml
- oshi-core/src/main/java/oshi/software/os/mac/MacInternetProtocolStats.java
- oshi-common/src/test/java/oshi/util/driver/unix/XwininfoTest.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractFirmwareTest.java
- oshi-core-java25/src/main/java/oshi/driver/mac/WhoFFM.java
- oshi-core-java25/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsFFM.java
- CHANGELOG.md
- oshi-core/src/main/java/oshi/driver/unix/solaris/Who.java
- oshi-core/src/main/java/oshi/driver/linux/Who.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractDisplayTest.java
- oshi-common/src/test/java/oshi/software/common/AbstractInternetProtocolStatsTest.java
- oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
- oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.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). (12)
- GitHub Check: Test JDK 11, ubuntu-latest
- GitHub Check: Test JDK 25, ubuntu-latest
- GitHub Check: Test JDK 11, macos-latest
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 25, macos-latest
- GitHub Check: Test JDK 11, windows-latest
- GitHub Check: Test JDK 21, ubuntu-latest
- GitHub Check: Test JDK 25, windows-latest
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Analyze (java)
- 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: 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.
📚 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/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.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/unix/freebsd/FreeBsdInternetProtocolStats.javaoshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessor.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-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.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-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.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/test/java/oshi/software/common/AbstractOperatingSystemTest.java
🔇 Additional comments (23)
oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.java (1)
19-19: Import migration is correct and consistent.Line 19 updates
NetStattooshi.util.driver.unix.NetStat, which aligns with the shared driver relocation and keeps the existingqueryTcpnetstatusage intact.oshi-common/src/test/java/oshi/software/common/AbstractOSProcessTest.java (4)
22-169: DeterministiccreateProcess(...)fixture is well-constructed.This anonymous
AbstractOSProcessstub provides stable values and keeps CPU-load tests focused on base-class logic.
171-174:getProcessID()assertion is clear and minimal.Good sanity check for identity passthrough from the abstract base implementation.
176-213: CPU-load coverage is strong across normal and fallback paths.Nice matrix here: zero-uptime cumulative, valid prior tick delta, and cumulative fallback for null/different PID/non-increasing uptime.
215-220:toString()test is robustly asserted.Using
containsStringfor key fields avoids brittle full-string coupling.oshi-common/src/test/java/oshi/software/common/AbstractNetworkParamsTest.java (4)
20-32: Good test fixture isolation withcreateParams().Using an anonymous
AbstractNetworkParamswith fixed gateway values keeps these tests deterministic and focused.
34-39: Host/domain sanity coverage looks good.The non-null checks validate core contract behavior without making brittle environment-specific assumptions.
41-50: Gateway parsing coverage is well targeted.Nice coverage for both the
%ifacesuffix case and the not-found fallback ("").
52-58:toString()regression assertions are useful and focused.Checking label presence plus both gateway values gives solid signal without overfitting formatting details.
oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessor.java (2)
144-145: HWCAP propagation into processor ID generation looks solid.Passing
queryHwcap()throughgetProcessorID(...)keeps the Linux-specific capability path explicit while preserving existing ID fallback behavior.
541-587: Good extensibility point for JNA/FFM-specific capability retrieval.The
queryHwcap()hook with a safe0Ldefault cleanly enables platform-specific overrides without changing baseline behavior when HWCAP is unavailable.oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java (5)
34-77: Deterministic processor fixture is well-constructed.The anonymous
AbstractCentralProcessorsetup provides stable inputs for behavior-focused unit tests.
79-118: CPU load-between-ticks coverage is strong.The full-load, partial-idle, invalid-length, and per-processor scenarios provide good regression protection for tick-delta calculations.
120-143: Processor ID tests now cover both normal and high-bit HWCAP cases.The unsigned parse and upper-32-bit assertions are aligned with the intended
hwcapencoding behavior.
145-170: Great targeted test for cache ordering tie behavior.The Apple Silicon-style cache inputs are a practical way to validate stable grouping and ordering guarantees.
172-184: Nice sanity checks for processor counts andtoString()output.These tests add useful guardrails for basic object invariants and human-readable summary formatting.
oshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.java (3)
46-166: Good deterministic test harness forAbstractOperatingSystembehavior.The anonymous stub plus memoization/process tests are clear, deterministic, and aligned with the production contract being exercised.
175-202: Nice coverage of immediate-children vs all-descendants traversal.These two tests validate both modes of
getChildrenOrDescendants(...)and guard BFS behavior well.
205-371:StubProcessis a solid minimal fixture.PID-driven identity with safe defaults keeps tests focused and avoids incidental behavior coupling.
oshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.java (4)
7-16: Clean test scaffold and assertion style.JUnit 5 + Hamcrest setup is consistent and readable for this class.
18-30: Getter coverage is thorough and focused.This test validates all exposed metadata fields and the empty connected-device list clearly.
32-41: Connected-device hierarchy check looks good.This captures the parent-child wiring behavior with a concise assertion set.
52-60:toString()tree-format test is valuable.Great to see the child rendering path covered with an explicit expected structure.
Move shared abstract classes, cross-platform Unix driver utilities, and resource files from
oshi-coreintooshi-commonso bothoshi-core(JNA) andoshi-core-java25(FFM) can depend on them without duplication.Changes
Moved to
oshi-commonoshi.hardware.common.*— all abstract hardware classes (AbstractCentralProcessor,AbstractGlobalMemory,AbstractGraphicsCard,NoOpGpuStats, etc.)oshi.software.common.*— all abstract OS classes (AbstractOperatingSystem,AbstractFileSystem,AbstractInternetProtocolStats, etc.)oshi.driver.unix.{NetStat, Who, Xwininfo}→oshi.util.driver.unix(package renamed to avoid collision with platform-specificoshi.driver.unixin oshi-core)oshi.*.propertiesresource files (oshi.properties,oshi.architecture.properties,oshi.vmmacaddr.properties,oshi.linux.filename.properties,oshi.macos.versions.properties) — these remain on the classpath for all dependent modulesBug fixes
NetStat.java: Fixed typo in switch case label ("woth no checksum"→"with no checksum")AbstractCentralProcessor.java: Changedif (hwcap > 0)toif (hwcap != 0)so unsigned AT_HWCAP values with the high bit set are not incorrectly skippedUpdated imports
oshi-core: Platform-specificWhoclasses (Mac, Linux, FreeBSD, Solaris) andInternetProtocolStatsclasses (Mac, FreeBSD, OpenBSD) updated to referenceoshi.util.driver.unixoshi-core-java25:WhoFFMandMacInternetProtocolStatsFFMupdated to referenceoshi.util.driver.unixModule metadata
oshi-commonmodule-info.java: Added exports foroshi.hardware.common,oshi.software.common,oshi.util.driver.unixoshi-commonmodule-info.test: Added--add-opensfor test reflection accessTests
NetStatTest,WhoTest,XwininfoTest) tooshi-commonunderoshi.util.driver.unixoshi-common(AbstractBaseboardTest,AbstractCentralProcessorTest,AbstractDisplayTest,AbstractFirmwareTest,AbstractSensorsTest,AbstractSoundCardTest,AbstractUsbDeviceTest,AbstractFileSystemTest,AbstractInternetProtocolStatsTest,AbstractNetworkParamsTest,AbstractOSFileStoreTest,AbstractOSProcessTest,AbstractOSThreadTest,AbstractOperatingSystemTest)AbstractGraphicsCardTestwith comprehensivetoString/metrics coverageAbstractCentralProcessorTest.testOrderedProcCachesuses realistic Apple Silicon-style cache data withhighestOneBitties, asserting level grouping without assuming order within tied groupsSummary by CodeRabbit
New Features
Refactor
Bug Fixes
Tests
Chores