Skip to content

Move abstract implementations, drivers, and tests to oshi-common - #3133

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:abstract-common
Apr 10, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:abstract-common

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Apr 10, 2026 •

Copy link
Copy Markdown
Member

Move shared abstract classes, cross-platform Unix driver utilities, and resource files from oshi-core into oshi-common so both oshi-core (JNA) and oshi-core-java25 (FFM) can depend on them without duplication.

Changes

Moved to oshi-common

  • oshi.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-specific oshi.driver.unix in oshi-core)
  • All oshi.*.properties resource 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 modules

Bug fixes

  • NetStat.java: Fixed typo in switch case label ("woth no checksum" → "with no checksum")
  • AbstractCentralProcessor.java: Changed if (hwcap > 0) to if (hwcap != 0) so unsigned AT_HWCAP values with the high bit set are not incorrectly skipped

Updated imports

  • oshi-core: Platform-specific Who classes (Mac, Linux, FreeBSD, Solaris) and InternetProtocolStats classes (Mac, FreeBSD, OpenBSD) updated to reference oshi.util.driver.unix
  • oshi-core-java25: WhoFFM and MacInternetProtocolStatsFFM updated to reference oshi.util.driver.unix

Module metadata

  • oshi-common module-info.java: Added exports for oshi.hardware.common, oshi.software.common, oshi.util.driver.unix
  • oshi-common module-info.test: Added --add-opens for test reflection access

Tests

  • Migrated driver tests (NetStatTest, WhoTest, XwininfoTest) to oshi-common under oshi.util.driver.unix
  • Created new tests for abstract classes in oshi-common (AbstractBaseboardTest, AbstractCentralProcessorTest, AbstractDisplayTest, AbstractFirmwareTest, AbstractSensorsTest, AbstractSoundCardTest, AbstractUsbDeviceTest, AbstractFileSystemTest, AbstractInternetProtocolStatsTest, AbstractNetworkParamsTest, AbstractOSFileStoreTest, AbstractOSProcessTest, AbstractOSThreadTest, AbstractOperatingSystemTest)
  • Enhanced AbstractGraphicsCardTest with comprehensive toString/metrics coverage
  • AbstractCentralProcessorTest.testOrderedProcCaches uses realistic Apple Silicon-style cache data with highestOneBit ties, asserting level grouping without assuming order within tied groups

Summary by CodeRabbit

  • New Features

    • Exposed additional common hardware, software, and Unix driver utilities; CPU IDs may now include explicit hardware-capability values.
  • Refactor

    • Reorganized Unix driver utilities and adjusted processor ID generation to accept hwcap input.
  • Bug Fixes

    • Fixed UDP parsing in netstat handling.
  • Tests

    • Added numerous unit tests covering hardware, software, networking, and OS subsystems.
  • Chores

    • Updated copyright years and adjusted changelog formatting.

@coderabbitai

coderabbitai Bot commented Apr 10, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Module exports extended and several Unix driver classes moved into oshi.util.driver.unix; processor ID generation became hwcap-aware with new query hooks/readers; many copyright year bumps and a large suite of JUnit5 tests were added.

Changes

Cohort / File(s) Summary
Module descriptor
oshi-common/src/main/java/module-info.java
Added exports for oshi.hardware.common, oshi.software.common, and oshi.util.driver.unix.
Unix driver package moves
oshi-common/src/main/java/oshi/util/driver/unix/*, oshi-common/src/test/java/oshi/util/driver/unix/*, oshi-core/src/main/java/oshi/driver/.../Who.java, oshi-core-java25/src/main/java/oshi/driver/mac/WhoFFM.java
Moved Who, Xwininfo, NetStat from oshi.driver.unix → oshi.util.driver.unix; updated package declarations, imports, tests, and added package-info.java.
NetStat parsing fix
oshi-common/src/main/java/oshi/util/driver/unix/NetStat.java
Package rename and corrected UDP receive-error case string ("with no checksum"); minor re-indentation.
Processor ID / hwcap plumbing
oshi-common/.../AbstractCentralProcessor.java, oshi-core/.../LinuxCentralProcessor*.java, oshi-core-java25/.../LinuxCentralProcessorFFM.java, oshi-core/.../LinuxCentralProcessorJNA.java
Added createProcessorID(..., long hwcap) overload; added queryHwcap() hook and platform-specific implementations reading AT_HWCAP (Auxv or /proc/auxv) and passing hwcap into processor-ID generation.
Who fallback updates
oshi-core/src/main/java/oshi/driver/*/Who.java, oshi-core-java25/.../WhoFFM.java, oshi-core/src/main/java/oshi/driver/mac/Who.java
Changed invalid-session/empty-utmp fallbacks to call oshi.util.driver.unix.Who.queryWho() (new package).
Platform/util import changes
oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java, oshi-common/src/main/java/oshi/software/common/AbstractInternetProtocolStats.java, oshi-core/**/MacInternetProtocolStats*.java, oshi-core/**/FreeBsdInternetProtocolStats.java, oshi-core/**/OpenBsdInternetProtocolStats.java
Replaced JNA Platform.is64Bit() usage with oshi.util.Util.is64Bit() and updated imports to oshi.util.driver.unix.* where applicable.
Tests added/updated
oshi-common/src/test/java/... (many files, e.g., oshi/hardware/common/*, oshi/software/common/*), oshi-common/src/test/java/module-info.test
Added numerous JUnit5 tests for hardware/software abstractions; updated module-info.test to add --add-opens for new packages.
Package-info added
oshi-common/src/main/java/oshi/util/driver/unix/package-info.java
New package-level Javadoc/license for oshi.util.driver.unix.
OSGi / packaging
oshi-core-java25/pom.xml
Removed oshi.hardware.common.* from bnd Export-Package directive.
Copyright/header updates
many oshi-common and driver/core files
Updated copyright year ranges to end in 2026 across many files; no logic changes.
Changelog
CHANGELOG.md
Combined PR bullets to reference multiple PRs (#3130, #3132, #3133) and adjusted formatting.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • rohan-coder02

Poem

"🐰 I hopped through package trees so neat,
Moved Who and NetStat to a new street.
Hwcap tucked in the processor's shell,
Tests multiplied to prove it well.
A little carrot cheer — code tidy and sweet! 🥕"

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Move abstract implementations, drivers, and tests to oshi-common' accurately describes the primary objective of the changeset: relocating shared abstract classes and Unix driver utilities from oshi-core into a new oshi-common module.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Apr 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.61%. Comparing base (3c77525) to head (1e1231a).
⚠️ Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🟡 Minor

Use hwcap != 0 instead of hwcap > 0 to correctly handle unsigned AT_HWCAP values.

On 32-bit systems, FileUtil.readIntFromBuffer() reads a signed 32-bit integer and promotes it to long with sign-extension. Unsigned AT_HWCAP values with the high bit set (e.g., 0x80000000+) would become negative longs and be rejected by the hwcap > 0 check, even though they represent valid hardware capabilities. Since the javadoc states "0 if unavailable," the correct guard is hwcap != 0 to 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: Strengthen toString() 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 for notNullValue().

Line 35 uses a fully qualified reference org.hamcrest.Matchers.notNullValue() while other matchers in this file are statically imported (Line 8: is). Consider adding notNullValue to 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 returning null and getProcessCount() always returning 0 conflicts with queryAllProcesses() 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

📥 Commits

Reviewing files that changed from the base of the PR and between 3c77525 and cc9cbea.

📒 Files selected for processing (64)
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractBaseboard.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractDisplay.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractFirmware.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractGraphicsCard.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractHardwareAbstractionLayer.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractLogicalVolumeGroup.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractPrinter.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractSensors.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractSoundCard.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractUsbDevice.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractVirtualMemory.java
  • oshi-common/src/main/java/oshi/hardware/common/NoOpGpuStats.java
  • oshi-common/src/main/java/oshi/hardware/common/package-info.java
  • oshi-common/src/main/java/oshi/software/common/AbstractFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/AbstractInternetProtocolStats.java
  • oshi-common/src/main/java/oshi/software/common/AbstractNetworkParams.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSFileStore.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/unix/NetStat.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Who.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Xwininfo.java
  • oshi-common/src/main/java/oshi/util/driver/unix/package-info.java
  • oshi-common/src/test/java/module-info.test
  • oshi-common/src/test/java/oshi/hardware/common/AbstractBaseboardTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractDisplayTest.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/hardware/common/AbstractSensorsTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractSoundCardTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.java
  • oshi-common/src/test/java/oshi/software/common/AbstractFileSystemTest.java
  • oshi-common/src/test/java/oshi/software/common/AbstractInternetProtocolStatsTest.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/AbstractOSProcessTest.java
  • oshi-common/src/test/java/oshi/software/common/AbstractOSThreadTest.java
  • oshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.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/test/java/oshi/util/driver/unix/XwininfoTest.java
  • oshi-core-java25/pom.xml
  • oshi-core-java25/src/main/java/oshi/driver/mac/WhoFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsFFM.java
  • oshi-core/src/main/java/oshi/driver/linux/Who.java
  • oshi-core/src/main/java/oshi/driver/mac/Who.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/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
  • oshi-core/src/main/java/oshi/software/os/mac/MacInternetProtocolStats.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.java
  • oshi-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.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/hardware/common/AbstractSensors.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractLogicalVolumeGroup.java
  • oshi-common/src/main/java/oshi/software/common/AbstractNetworkParams.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/AbstractNetworkIF.java
  • oshi-common/src/main/java/oshi/software/common/AbstractFileSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java
  • oshi-common/src/test/java/oshi/util/driver/unix/NetStatTest.java
  • oshi-core/src/main/java/oshi/driver/mac/Who.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractSoundCard.java
  • oshi-core/src/main/java/oshi/driver/unix/solaris/Who.java
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Who.java
  • oshi-core-java25/pom.xml
  • oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
  • oshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Xwininfo.java
  • oshi-common/src/test/java/module-info.test
  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
  • oshi-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.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/hardware/common/AbstractSensors.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractLogicalVolumeGroup.java
  • oshi-common/src/main/java/oshi/software/common/AbstractNetworkParams.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/AbstractNetworkIF.java
  • oshi-common/src/main/java/oshi/software/common/AbstractFileSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java
  • oshi-common/src/test/java/oshi/util/driver/unix/NetStatTest.java
  • oshi-core/src/main/java/oshi/driver/mac/Who.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractSoundCard.java
  • oshi-core/src/main/java/oshi/driver/unix/solaris/Who.java
  • oshi-common/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/driver/unix/freebsd/Who.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/pom.xml
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.java
  • oshi-common/src/test/java/oshi/util/driver/unix/XwininfoTest.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/openbsd/OpenBsdInternetProtocolStats.java
  • oshi-common/src/main/java/oshi/util/driver/unix/NetStat.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Xwininfo.java
  • oshi-common/src/test/java/module-info.test
  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
  • oshi-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.java
  • oshi-common/src/test/java/oshi/util/driver/unix/WhoTest.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
  • oshi-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.java
  • oshi-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.java
  • oshi-core/src/main/java/oshi/driver/unix/freebsd/Who.java
  • oshi-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.java
  • oshi-core-java25/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsFFM.java
  • oshi-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.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
  • oshi-core/src/main/java/oshi/software/os/unix/openbsd/OpenBsdInternetProtocolStats.java
  • oshi-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 AbstractUsbDevice implementation 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.unix is 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 for AbstractFirmware.

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: AbstractSoundCard test 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 AbstractSensors contract paths.

oshi-common/src/test/java/oshi/software/common/AbstractOSFileStoreTest.java (1)

65-136: Comprehensive contract checks for AbstractOSFileStore.

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 (null prior, mismatched thread ID) with clear expected values.

oshi-common/src/test/java/oshi/software/common/AbstractOSProcessTest.java (1)

171-214: AbstractOSProcess tests 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.unix package 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.unix namespace.

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 NetStat utility 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 NetStat reference 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.unix matches 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.* from oshi-core-java25 aligns packaging with the new oshi-common ownership 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.Who utility, 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.NetStat matches the utility package migration without altering behavior.

oshi-common/src/test/java/oshi/hardware/common/AbstractBaseboardTest.java (1)

14-43: Good baseline coverage for AbstractBaseboard#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 Who utility, 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.unix namespace 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.

NetStat now points to the shared oshi.util.driver.unix package 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 the Who/Xwininfo imports 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-opens entries 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_HWCAP with 0L fallback 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 0L fallback.

Also applies to: 45-57, 59-61

oshi-core/src/main/java/oshi/driver/linux/Who.java (1)

81-81: Fallback migration to shared Who utility 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.NetStat to oshi.util.driver.unix.NetStat are consistent with the PR's objective of moving Unix driver utilities to oshi-common under 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 AbstractNetworkParams including hostname/domain defaults, searchGateway parsing (with interface suffix stripping), empty-list edge case, and toString output 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() and getUDPv6Stats() 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 passes 0L as the default hwcap value.

oshi-common/src/main/java/oshi/util/driver/unix/NetStat.java (1)

2-5: LGTM!

Package relocation from oshi.driver.unix to oshi.util.driver.unix aligns with the PR objective of moving shared Unix driver utilities into oshi-common to avoid package collision with platform-specific drivers in oshi-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 0L ensures backward compatibility—when not overridden, the processor ID falls back to flag-based encoding in createProcessorID.

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 getProcesses paths cleanly.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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 null for List<PhysicalProcessor> (2nd element) and List<ProcessorCache> (3rd element). While this works if AbstractCentralProcessor gracefully handles nulls, it could cause NullPointerException in 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

📥 Commits

Reviewing files that changed from the base of the PR and between cc9cbea and bf25a9e.

📒 Files selected for processing (70)
  • CHANGELOG.md
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractBaseboard.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractDisplay.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractFirmware.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractGraphicsCard.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractHardwareAbstractionLayer.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractLogicalVolumeGroup.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractPrinter.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractSensors.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractSoundCard.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractUsbDevice.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractVirtualMemory.java
  • oshi-common/src/main/java/oshi/hardware/common/NoOpGpuStats.java
  • oshi-common/src/main/java/oshi/hardware/common/package-info.java
  • oshi-common/src/main/java/oshi/software/common/AbstractFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/AbstractInternetProtocolStats.java
  • oshi-common/src/main/java/oshi/software/common/AbstractNetworkParams.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSFileStore.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/unix/NetStat.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Who.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Xwininfo.java
  • oshi-common/src/main/java/oshi/util/driver/unix/package-info.java
  • oshi-common/src/main/resources/oshi.architecture.properties
  • oshi-common/src/main/resources/oshi.linux.filename.properties
  • oshi-common/src/main/resources/oshi.macos.versions.properties
  • oshi-common/src/main/resources/oshi.properties
  • oshi-common/src/main/resources/oshi.vmmacaddr.properties
  • oshi-common/src/test/java/module-info.test
  • oshi-common/src/test/java/oshi/hardware/common/AbstractBaseboardTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractDisplayTest.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/hardware/common/AbstractSensorsTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractSoundCardTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.java
  • oshi-common/src/test/java/oshi/software/common/AbstractFileSystemTest.java
  • oshi-common/src/test/java/oshi/software/common/AbstractInternetProtocolStatsTest.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/AbstractOSProcessTest.java
  • oshi-common/src/test/java/oshi/software/common/AbstractOSThreadTest.java
  • oshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.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/test/java/oshi/util/driver/unix/XwininfoTest.java
  • oshi-core-java25/pom.xml
  • oshi-core-java25/src/main/java/oshi/driver/mac/WhoFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsFFM.java
  • oshi-core/src/main/java/oshi/driver/linux/Who.java
  • oshi-core/src/main/java/oshi/driver/mac/Who.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/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
  • oshi-core/src/main/java/oshi/software/os/mac/MacInternetProtocolStats.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.java
  • oshi-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 long size differences using FFM's canonical layouts, and the auxv parsing loop properly terminates on AT_NULL (key == 0). The fallback to 0L when AT_HWCAP is not found is consistent with the base class default behavior.

One minor note: if /proc/auxv is truncated or unreadable, readNativeLong could throw BufferUnderflowException. 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 safe 0L default
  • 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 implementations

Also 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/UdpStats would 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

📥 Commits

Reviewing files that changed from the base of the PR and between bf25a9e and b5ba6d0.

📒 Files selected for processing (70)
  • CHANGELOG.md
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractBaseboard.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractDisplay.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractFirmware.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractGraphicsCard.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractHardwareAbstractionLayer.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractLogicalVolumeGroup.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractPrinter.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractSensors.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractSoundCard.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractUsbDevice.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractVirtualMemory.java
  • oshi-common/src/main/java/oshi/hardware/common/NoOpGpuStats.java
  • oshi-common/src/main/java/oshi/hardware/common/package-info.java
  • oshi-common/src/main/java/oshi/software/common/AbstractFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/AbstractInternetProtocolStats.java
  • oshi-common/src/main/java/oshi/software/common/AbstractNetworkParams.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSFileStore.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/unix/NetStat.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Who.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Xwininfo.java
  • oshi-common/src/main/java/oshi/util/driver/unix/package-info.java
  • oshi-common/src/main/resources/oshi.architecture.properties
  • oshi-common/src/main/resources/oshi.linux.filename.properties
  • oshi-common/src/main/resources/oshi.macos.versions.properties
  • oshi-common/src/main/resources/oshi.properties
  • oshi-common/src/main/resources/oshi.vmmacaddr.properties
  • oshi-common/src/test/java/module-info.test
  • oshi-common/src/test/java/oshi/hardware/common/AbstractBaseboardTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractDisplayTest.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/hardware/common/AbstractSensorsTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractSoundCardTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.java
  • oshi-common/src/test/java/oshi/software/common/AbstractFileSystemTest.java
  • oshi-common/src/test/java/oshi/software/common/AbstractInternetProtocolStatsTest.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/AbstractOSProcessTest.java
  • oshi-common/src/test/java/oshi/software/common/AbstractOSThreadTest.java
  • oshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.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/test/java/oshi/util/driver/unix/XwininfoTest.java
  • oshi-core-java25/pom.xml
  • oshi-core-java25/src/main/java/oshi/driver/mac/WhoFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsFFM.java
  • oshi-core/src/main/java/oshi/driver/linux/Who.java
  • oshi-core/src/main/java/oshi/driver/mac/Who.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/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
  • oshi-core/src/main/java/oshi/software/os/mac/MacInternetProtocolStats.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.java
  • oshi-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.java
  • oshi-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.

WhoTest now lives under oshi.util.driver.unix, which matches the moved Who utility 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 to oshi-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: Deterministic AbstractOSProcess fixture 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 (null and mismatched PID prior), which meaningfully strengthens regression protection.


209-213: toString() assertions check the right contract surface.

Verifying both processID and name is 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 that createProcessorID uses to encode platform-specific information. The default return of 0L ensures 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 hwcap value is appropriately forwarded to createProcessorID for 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 0L correctly triggers fallback to flag-based processor ID encoding in createProcessorID. 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 searchGateway parsing (including %iface suffix stripping) without overfitting.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in getThreadCpuLoadBetweenTicks.

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: testMemoizedFields doesn’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

📥 Commits

Reviewing files that changed from the base of the PR and between b5ba6d0 and 167494e.

📒 Files selected for processing (70)
  • CHANGELOG.md
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractBaseboard.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractDisplay.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractFirmware.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractGraphicsCard.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractHardwareAbstractionLayer.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractLogicalVolumeGroup.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractPrinter.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractSensors.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractSoundCard.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractUsbDevice.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractVirtualMemory.java
  • oshi-common/src/main/java/oshi/hardware/common/NoOpGpuStats.java
  • oshi-common/src/main/java/oshi/hardware/common/package-info.java
  • oshi-common/src/main/java/oshi/software/common/AbstractFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/AbstractInternetProtocolStats.java
  • oshi-common/src/main/java/oshi/software/common/AbstractNetworkParams.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSFileStore.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/unix/NetStat.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Who.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Xwininfo.java
  • oshi-common/src/main/java/oshi/util/driver/unix/package-info.java
  • oshi-common/src/main/resources/oshi.architecture.properties
  • oshi-common/src/main/resources/oshi.linux.filename.properties
  • oshi-common/src/main/resources/oshi.macos.versions.properties
  • oshi-common/src/main/resources/oshi.properties
  • oshi-common/src/main/resources/oshi.vmmacaddr.properties
  • oshi-common/src/test/java/module-info.test
  • oshi-common/src/test/java/oshi/hardware/common/AbstractBaseboardTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractDisplayTest.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/hardware/common/AbstractSensorsTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractSoundCardTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.java
  • oshi-common/src/test/java/oshi/software/common/AbstractFileSystemTest.java
  • oshi-common/src/test/java/oshi/software/common/AbstractInternetProtocolStatsTest.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/AbstractOSProcessTest.java
  • oshi-common/src/test/java/oshi/software/common/AbstractOSThreadTest.java
  • oshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.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/test/java/oshi/util/driver/unix/XwininfoTest.java
  • oshi-core-java25/pom.xml
  • oshi-core-java25/src/main/java/oshi/driver/mac/WhoFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsFFM.java
  • oshi-core/src/main/java/oshi/driver/linux/Who.java
  • oshi-core/src/main/java/oshi/driver/mac/Who.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/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
  • oshi-core/src/main/java/oshi/software/os/mac/MacInternetProtocolStats.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.java
  • oshi-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.java
  • oshi-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.java
  • oshi-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.java
  • oshi-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 for AbstractOSProcess core 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 for AbstractOSThread.

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: getChildrenOrDescendants tests 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 + default 0L + forwarding into createProcessorID(..., 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]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
oshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.java (1)

43-50: Strengthen compareTo contract 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

📥 Commits

Reviewing files that changed from the base of the PR and between 167494e and 1e1231a.

📒 Files selected for processing (70)
  • CHANGELOG.md
  • oshi-common/src/main/java/module-info.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractBaseboard.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractDisplay.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractFirmware.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractGraphicsCard.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractHardwareAbstractionLayer.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractLogicalVolumeGroup.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractPrinter.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractSensors.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractSoundCard.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractUsbDevice.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractVirtualMemory.java
  • oshi-common/src/main/java/oshi/hardware/common/NoOpGpuStats.java
  • oshi-common/src/main/java/oshi/hardware/common/package-info.java
  • oshi-common/src/main/java/oshi/software/common/AbstractFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/AbstractInternetProtocolStats.java
  • oshi-common/src/main/java/oshi/software/common/AbstractNetworkParams.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSFileStore.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/package-info.java
  • oshi-common/src/main/java/oshi/util/driver/unix/NetStat.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Who.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Xwininfo.java
  • oshi-common/src/main/java/oshi/util/driver/unix/package-info.java
  • oshi-common/src/main/resources/oshi.architecture.properties
  • oshi-common/src/main/resources/oshi.linux.filename.properties
  • oshi-common/src/main/resources/oshi.macos.versions.properties
  • oshi-common/src/main/resources/oshi.properties
  • oshi-common/src/main/resources/oshi.vmmacaddr.properties
  • oshi-common/src/test/java/module-info.test
  • oshi-common/src/test/java/oshi/hardware/common/AbstractBaseboardTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractDisplayTest.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/hardware/common/AbstractSensorsTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractSoundCardTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractUsbDeviceTest.java
  • oshi-common/src/test/java/oshi/software/common/AbstractFileSystemTest.java
  • oshi-common/src/test/java/oshi/software/common/AbstractInternetProtocolStatsTest.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/AbstractOSProcessTest.java
  • oshi-common/src/test/java/oshi/software/common/AbstractOSThreadTest.java
  • oshi-common/src/test/java/oshi/software/common/AbstractOperatingSystemTest.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/test/java/oshi/util/driver/unix/XwininfoTest.java
  • oshi-core-java25/pom.xml
  • oshi-core-java25/src/main/java/oshi/driver/mac/WhoFFM.java
  • oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsFFM.java
  • oshi-core/src/main/java/oshi/driver/linux/Who.java
  • oshi-core/src/main/java/oshi/driver/mac/Who.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/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorJNA.java
  • oshi-core/src/main/java/oshi/software/os/mac/MacInternetProtocolStats.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.java
  • oshi-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.java
  • oshi-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 NetStat to oshi.util.driver.unix.NetStat, which aligns with the shared driver relocation and keeps the existing queryTcpnetstat usage intact.

oshi-common/src/test/java/oshi/software/common/AbstractOSProcessTest.java (4)

22-169: Deterministic createProcess(...) fixture is well-constructed.

This anonymous AbstractOSProcess stub 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 containsString for key fields avoids brittle full-string coupling.

oshi-common/src/test/java/oshi/software/common/AbstractNetworkParamsTest.java (4)

20-32: Good test fixture isolation with createParams().

Using an anonymous AbstractNetworkParams with 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 %iface suffix 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() through getProcessorID(...) 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 safe 0L default 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 AbstractCentralProcessor setup 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 hwcap encoding 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 and toString() 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 for AbstractOperatingSystem behavior.

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: StubProcess is 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant