Skip to content

Share the Windows OS layer between the backends and fix the FFM process lookup - #3568

Merged
dbwiddis merged 4 commits into
oshi:masterfrom
dbwiddis:windows-os-shared-base
Aug 3, 2026
Merged

dbwiddis merged 4 commits into
oshi:masterfrom
dbwiddis:windows-os-shared-base

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Aug 3, 2026 •

Copy link
Copy Markdown
Member

Two commits: the first fixes a divergence between the Windows backends and shares the version parsing; the second removes the duplication that let the divergence happen.

The bug

WindowsOperatingSystemFFM.processMapToList filtered an explicit pid request against the perf counter map alone, skipping the WTS map that the all-processes path intersects with. Both backends agree when pids == null; only the explicit-pid path differed.

The perf counter map is memoized (300 ms by default) and always fetched for every pid, so it can still name a process that has since exited. WindowsOSProcess.updateAttributes explicitly tolerates a null WtsInfo, and WindowsOSProcessFFM ignores a failed OpenProcess, so the state stayed RUNNING and ProcessFiltering.VALID_PROCESS passed it through. The caller got a process reporting RUNNING with an empty path, zero threads, zero virtual size and zero CPU time.

Put plainly: getProcess(pid) could return a process that getProcesses() would not list. FFM now intersects with the freshly queried WTS keys either way, matching JNA.

It arrived with the FFM port of WindowsOSProcess (#3126), whose description lists "PID filtering" as a fix, so it was deliberate rather than an oversight — but the comment on the pids == null branch already said WTS enrichment was required for full data, which is just as true for an explicit pid.

Sharing the code

queryFamilyVersionInfo and processMapToList were both duplicated between the twins, and processMapToList is exactly where they drifted apart. Both now live in the common WindowsOperatingSystem base.

The version logic is split so the parsing is separable from the acquisition: parseVersionInfo and resolveVersionAlias are pure and unit tested on every platform rather than only under Windows CI. That also settles JNA comparing the service pack against Constants.UNKNOWN where FFM used an "unknown" literal.

The process plumbing takes seven one-line hooks per backend: the four registry/perf-counter map builders, the WTS query, the parent pid map, and an OSProcess factory. Because the builders take the pid collection, the four queryXMapFromY() wrappers that existed only as memoizer method references are gone.

queryParentPidMap is the one genuine difference and stays a hook: JNA takes a live ToolHelp32 snapshot, FFM derives parents from the cached perf counter data. The reason is recorded on the FFM override.

Also

  • WindowsForeignFunctions.succeededOrLog replaces the repeated "log GetLastError and bail" guard, and fixes five FFM sites that logged the OptionalInt wrapper instead of the error code.
  • resolveProcessMap returns an empty map rather than null when neither source has data — reachable on both backends before.
  • Dropped the FFM copy of USE_PROCSTATE_SUSPENDED, which shadowed the identical inherited constant.
  • Added WindowsOperatingSystemJNATest mirroring the FFM backend's test, and moved WindowsOperatingSystemFFMTest into the package of the class under test.

Compatibility

queryAllProcesses, queryChildProcesses, queryDescendantProcesses and queryFamilyVersionInfo are protected on the base; they were public on the concrete classes only because each override widened them. getProcesses(Collection) and getProcess(int) remain public, and the OperatingSystem interface is unchanged.

Verification

Full clean reactor build, tests, checkstyle, forbidden-apis and javadoc pass locally on macOS. The Windows paths themselves are unverified — I cannot run them here, so the process behavior rests on Windows CI.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed Windows process lookups so recently exited or unavailable processes are no longer reported as running with incomplete metadata.
    • Improved process and thread information retrieval across supported Windows backends.
    • Improved child and descendant process queries.
    • Improved Windows version and service-pack identification, including Windows 11 and Windows Server releases.
    • Added clearer diagnostics when Windows system calls fail.
  • Release Notes

    • Updated the changelog for version 7.4.4.

Hoist queryFamilyVersionInfo into the common WindowsOperatingSystem base
behind an abstract queryOsVersion() hook, splitting the parsing from the
acquisition so parseVersionInfo and resolveVersionAlias can be unit tested
on any platform rather than only under Windows CI. This also settles two
differences between the twins: JNA compared the service pack against
Constants.UNKNOWN while FFM used a "unknown" string literal, and JNA
widened queryFamilyVersionInfo to public.

Fix WindowsOperatingSystemFFM.processMapToList keying an explicit pid
request off the perf counter map alone. That map is memoized, so it can
still name a process that has exited, and WindowsOSProcess tolerates a
null WtsInfo; the caller got a process reporting RUNNING with no path, no
threads and no CPU time, and getProcess(pid) could return a process that
getProcesses() would not list. Intersect with the freshly queried WTS
keys whether or not pids were requested, matching the JNA backend.

Add WindowsForeignFunctions.succeededOrLog to replace the repeated
"log GetLastError and bail" guard, which also fixes five FFM call sites
logging the OptionalInt wrapper instead of the error code.

Add WindowsOperatingSystemJNATest mirroring the FFM backend's test, and
move WindowsOperatingSystemFFMTest into the package of the class under
test. Drop the FFM copy of USE_PROCSTATE_SUSPENDED, which shadowed the
identical constant it inherits.
processMapToList was identical in both backends apart from the driver
class names, which is how the two came to disagree on how an explicit pid
request is filtered. Move it, the four memoized perf counter suppliers,
and the five process query methods into the common WindowsOperatingSystem
base so there is one implementation to keep correct.

Each backend now supplies seven one-line hooks: the four registry and
perf counter map builders, the WTS query, the parent pid map, and an
OSProcess factory. The builders take the pid collection, so the four
per-backend queryXMapFromY() wrappers that existed only to be memoizer
method references are gone; the suppliers pass null themselves.

queryParentPidMap is the one place the backends genuinely differ: JNA
takes a live ToolHelp32 snapshot while FFM derives parents from the
cached perf counter data, so it stays a hook with the reason recorded on
the FFM override. FFM reaches that data through a new getCachedProcessMap
on the base rather than its own copy of the registry-then-perf-counters
fallback.

resolveProcessMap now returns an empty map rather than null when neither
source has data, which was reachable on both backends.

Note that queryAllProcesses, queryChildProcesses, queryDescendantProcesses
and queryFamilyVersionInfo are protected on the base; they were public on
the concrete classes only because each override widened them. The
OperatingSystem interface is unchanged.
@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 737f25d7-dd74-460b-bb6e-61a2c461f6c9

📥 Commits

Reviewing files that changed from the base of the PR and between 1d52af4 and 189cb05.

📒 Files selected for processing (1)
  • AGENTS.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • AGENTS.md
📜 Recent review details
⏰ Context from checks skipped due to timeout. (6)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Analyze (java)

📝 Walkthrough

Walkthrough

Windows process enumeration and version parsing now reside in WindowsOperatingSystem. JNA and FFM backends provide data through protected hooks. FFM native-call failures use shared logging. Windows-specific tests cover process maps, parent relationships, versions, native-call results, and test-module access.

Changes

Windows process and version handling

Layer / File(s) Summary
Common process queries and version parsing
oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.java, oshi-common/src/test/java/oshi/software/common/os/windows/WindowsOperatingSystemTest.java
The common class adds cached process data, process lookup and enumeration, parent-process queries, and Windows version alias resolution. Tests cover version parsing and aliases.
JNA and FFM backend delegation
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.java, oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java, oshi-core/src/test/java/oshi/software/os/windows/WindowsOperatingSystemJNATest.java, oshi-core-ffm/src/test/java/oshi/software/os/windows/WindowsOperatingSystemFFMTest.java
Both backends provide process and thread maps, WTS data, process construction, OS-version data, and parent-PID mappings through superclass hooks. Tests cover backend maps and process relationships.
Shared FFM error reporting
oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/WindowsForeignFunctions.java, oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java, oshi-core-ffm/src/test/java/oshi/ffm/platform/windows/WindowsForeignFunctionsTest.java
FFM native-call failures use succeededOrLog, which logs the function and Windows error value. Tests cover success, failure, and BOOL handling.
Test wiring and release note
oshi-core/src/test/java/module-info.test, oshi-core-ffm/src/test/java/module-info.test, AGENTS.md, CHANGELOG.md
Test module openings and setup guidance support Windows test access. The changelog records the Windows FFM process lookup fix.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant WindowsOperatingSystem
  participant WindowsOperatingSystemJNA
  participant WindowsOperatingSystemFFM
  participant WindowsOSProcessFFM
  WindowsOperatingSystem->>WindowsOperatingSystemJNA: request process data
  WindowsOperatingSystem->>WindowsOperatingSystemFFM: request process data
  WindowsOperatingSystemJNA->>WindowsOperatingSystem: provide backend maps and process construction
  WindowsOperatingSystemFFM->>WindowsOSProcessFFM: create FFM OS process
  WindowsOperatingSystemFFM->>WindowsOperatingSystem: provide backend maps and parent-PID data
Loading

Possibly related PRs

  • oshi/oshi#3126: Refactors the FFM process-query architecture used by this change.
  • oshi/oshi#3141: Refactors shared Windows process handling across JNA and FFM backends.
  • oshi/oshi#3216: Changes the WTS data path used by FFM process enumeration.

Poem

A rabbit checks each process trail,
Cached maps guide the Windows sail.
FFM errors now log clear,
Parent links and versions appear.
“Hop,” says the rabbit, “the fix is done!”

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the two main changes: sharing the Windows OS layer and fixing FFM process lookup.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@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 (2)
oshi-core-ffm/src/test/java/oshi/software/os/windows/WindowsOperatingSystemFFMTest.java (1)

66-72: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Confirm that the parent-PID assertion tolerates empty performance-counter data.

WindowsOperatingSystemFFM.queryParentPidMap builds the map from getCachedProcessMap(). If both the registry and the performance-counter sources return no data, resolveProcessMap returns an empty map and this assertion fails. The JNA twin does not have this exposure, because it enumerates through ToolHelp.

Consider asserting the current process only when the map is not empty.

As per path instructions: "Assert hardware-independent invariants such as non-null values, types, ordering, and plausible ranges rather than specific hardware values; allow zero and empty results."

🧪 Proposed adjustment
     `@Test`
     void testQueryParentPidMap() {
         Map<Integer, Integer> parentPidMap = os.queryParentPidMapForTest();
         assertThat("Parent pid map should not be null", parentPidMap, is(notNullValue()));
-        assertThat("Parent pid map should include the current process", parentPidMap.containsKey(os.getProcessId()),
-                is(true));
+        if (!parentPidMap.isEmpty()) {
+            assertThat("A populated parent pid map should include the current process",
+                    parentPidMap.containsKey(os.getProcessId()), is(true));
+        }
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@oshi-core-ffm/src/test/java/oshi/software/os/windows/WindowsOperatingSystemFFMTest.java`
around lines 66 - 72, Update testQueryParentPidMap so the current-process
containsKey assertion runs only when parentPidMap is non-empty, while always
retaining the non-null assertion. This allows valid empty performance-counter
results without asserting a hardware-dependent entry.

Source: Coding guidelines

oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.java (1)

253-267: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Consider numeric build comparison instead of String.compareTo.

The thresholds compare build numbers lexicographically. This is correct only while all build numbers have the same digit count. A build number with a different length, for example a future six-digit build or a short or empty value, would compare incorrectly. The current inputs are five digits, so behavior is correct today.

If you change this, use ParseUtil rather than Integer.parseInt, because oshi-common bans the direct numeric parsing APIs.

As per coding guidelines: "Use oshi.util.ParseUtil methods instead of banned numeric parsing APIs such as Integer.parseInt, Long.parseLong, Double.parseDouble, and Integer.decode."

♻️ Example of a length-safe comparison
 static String resolveVersionAlias(String version, String buildNumber) {
-        if ("10".equals(version) && buildNumber.compareTo("22000") >= 0) {
+        int build = ParseUtil.parseIntOrDefault(buildNumber, 0);
+        if ("10".equals(version) && build >= 22000) {
             return "11";
         }
-        if ("Server 2016".equals(version) && buildNumber.compareTo("17762") > 0) {
+        if ("Server 2016".equals(version) && build > 17762) {
             version = "Server 2019";
         }
-        if ("Server 2019".equals(version) && buildNumber.compareTo("20347") > 0) {
+        if ("Server 2019".equals(version) && build > 20347) {
             version = "Server 2022";
         }
-        if ("Server 2022".equals(version) && buildNumber.compareTo("26039") > 0) {
+        if ("Server 2022".equals(version) && build > 26039) {
             version = "Server 2025";
         }
         return version;
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.java`
around lines 253 - 267, Update WindowsOperatingSystem.resolveVersionAlias to
compare buildNumber numerically via the appropriate oshi.util.ParseUtil method
instead of String.compareTo or banned direct parsing APIs. Preserve the existing
version thresholds and alias transitions, while handling short, empty, or future
differently sized build values safely.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@oshi-core/src/test/java/oshi/software/os/windows/WindowsOperatingSystemJNATest.java`:
- Around line 27-30: Add the required `@DisabledIfSystemProperty` annotation to
`WindowsOperatingSystemJNATest`, using the `os.name` property and a
case-insensitive `.*netbsd.*` pattern while preserving the existing
`@EnabledOnOs(OS.WINDOWS)` guard.

---

Nitpick comments:
In
`@oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.java`:
- Around line 253-267: Update WindowsOperatingSystem.resolveVersionAlias to
compare buildNumber numerically via the appropriate oshi.util.ParseUtil method
instead of String.compareTo or banned direct parsing APIs. Preserve the existing
version thresholds and alias transitions, while handling short, empty, or future
differently sized build values safely.

In
`@oshi-core-ffm/src/test/java/oshi/software/os/windows/WindowsOperatingSystemFFMTest.java`:
- Around line 66-72: Update testQueryParentPidMap so the current-process
containsKey assertion runs only when parentPidMap is non-empty, while always
retaining the non-null assertion. This allows valid empty performance-counter
results without asserting a hardware-dependent entry.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fc6f8e24-9f68-477b-ac1a-b4455060be89

📥 Commits

Reviewing files that changed from the base of the PR and between 7ffc556 and 886f4e9.

📒 Files selected for processing (9)
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.java
  • oshi-common/src/test/java/oshi/software/common/os/windows/WindowsOperatingSystemTest.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/WindowsForeignFunctions.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-core-ffm/src/test/java/oshi/ffm/platform/windows/WindowsForeignFunctionsTest.java
  • oshi-core-ffm/src/test/java/oshi/software/os/windows/WindowsOperatingSystemFFMTest.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.java
  • oshi-core/src/test/java/oshi/software/os/windows/WindowsOperatingSystemJNATest.java
📜 Review details
⏰ Context from checks skipped due to timeout. (6)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Analyze (java)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

**/*.java: Do not use org.slf4j.event.**; use oshi.util.LogLevel instead.
Add the imports needed by code, and let Spotless own formatting and import ordering.
Verify native struct offsets, field widths, and sysctl/ioctl constants against the target operating system's real headers rather than inferring them from another OS.

Files:

  • oshi-core/src/test/java/oshi/software/os/windows/WindowsOperatingSystemJNATest.java
  • oshi-core-ffm/src/test/java/oshi/ffm/platform/windows/WindowsForeignFunctionsTest.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/WindowsForeignFunctions.java
  • oshi-common/src/test/java/oshi/software/common/os/windows/WindowsOperatingSystemTest.java
  • oshi-core-ffm/src/test/java/oshi/software/os/windows/WindowsOperatingSystemFFMTest.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.java
**/src/test/java/**/*Test.java

📄 CodeRabbit inference engine (AGENTS.md)

**/src/test/java/**/*Test.java: Use JUnit 5 and Hamcrest; do not add Mockito. Extract parsing into methods accepting fixture data such as List<String> or String, and test those methods separately from acquisition.
Assert hardware-independent invariants such as non-null values, types, ordering, and plausible ranges rather than specific hardware values; allow zero and empty results.
Avoid timing-sensitive assertions comparing live readings, including CPU frequency, tick counters, and uptime.
Do not assume platform-specific hardware exists; tests must tolerate absent batteries, sensors, GPUs, sound cards, and processors.

Files:

  • oshi-core/src/test/java/oshi/software/os/windows/WindowsOperatingSystemJNATest.java
  • oshi-core-ffm/src/test/java/oshi/ffm/platform/windows/WindowsForeignFunctionsTest.java
  • oshi-common/src/test/java/oshi/software/common/os/windows/WindowsOperatingSystemTest.java
  • oshi-core-ffm/src/test/java/oshi/software/os/windows/WindowsOperatingSystemFFMTest.java
oshi-core/src/test/java/**/*Test.java

📄 CodeRabbit inference engine (AGENTS.md)

Tests that allocate JNA must be annotated with @DisabledIfSystemProperty(named = "os.name", matches = "(?i).*netbsd.*").

Files:

  • oshi-core/src/test/java/oshi/software/os/windows/WindowsOperatingSystemJNATest.java
oshi-core-ffm/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

oshi-core-ffm/src/main/java/**/*.java: oshi-core-ffm must not reference com.sun.jna.**.
Behavior changes in FFM implementation classes should also be applied equivalently to their corresponding JNA twins, unless the difference is intentionally specific to FFM or JNA.

Files:

  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/WindowsForeignFunctions.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
**/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

**/src/main/java/**/*.java: Every public member must have Javadoc, and code and Javadoc—including {@link ...}—must use imported simple class names rather than fully qualified names.
New classes should declare an appropriate concurrency annotation from oshi.annotation.concurrent, matching the modeled class when applicable.
Memoize constant or expensive, slowly changing system-call results with oshi.util.Memoizer, following surrounding patterns and using defaultExpiration() when values must refresh.
Place reusable per-OS acquisition and parsing helpers in oshi/driver/<os>/; keep parsing logic out of HAL classes where practical.
Prefer native calls for system information; on Linux prefer FileUtil for /proc and /sys, while on other platforms ExecutingCommand is acceptable when native APIs do not expose the information.
Do not commit generated output, target/, or IDE files.

Files:

  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/WindowsForeignFunctions.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.java
oshi-common/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

oshi-common/src/main/java/**/*.java: Keep oshi-common pure Java 8 with no JNA, FFM, or native library loading references; shared parsing, conversion, filtering, caching, and validation logic belongs here rather than duplicated in implementation modules.
Use oshi.util.ParseUtil methods instead of banned numeric parsing APIs such as Integer.parseInt, Long.parseLong, Double.parseDouble, and Integer.decode.

Files:

  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.java
oshi-core/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

oshi-core/src/main/java/**/*.java: oshi-core must compile with Java 8; do not use modern features such as var, records, switch expressions, text blocks, List.of, or Stream.toList().
Behavior changes in JNA implementation classes should also be applied equivalently to their corresponding FFM twins, unless the difference is intentionally specific to JNA or FFM.

Files:

  • oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.java
🧠 Learnings (6)
📚 Learning: 2026-08-03T00:46:14.953Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3566
File: oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdNetworkParams.java:18-22
Timestamp: 2026-08-03T00:46:14.953Z
Learning: In the OSHI Java codebase, do not require duplicate Javadoc on public methods annotated with Override when the inherited Javadoc from the parent declaration adequately documents the method. The general public-member Javadoc requirement should not flag these overrides solely because they lack redundant documentation.

Applied to files:

  • oshi-core/src/test/java/oshi/software/os/windows/WindowsOperatingSystemJNATest.java
  • oshi-core-ffm/src/test/java/oshi/ffm/platform/windows/WindowsForeignFunctionsTest.java
  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/WindowsForeignFunctions.java
  • oshi-common/src/test/java/oshi/software/common/os/windows/WindowsOperatingSystemTest.java
  • oshi-core-ffm/src/test/java/oshi/software/os/windows/WindowsOperatingSystemFFMTest.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.java
📚 Learning: 2026-07-06T19:25:59.225Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:25:59.225Z
Learning: In this repo’s SLF4J 1.x-compatible logging code, do not flag cases where a logger call uses SLF4J 1.6+ implicit-cause handling—e.g., `log.error("...{}", value, t)` (or similar with a single `{}` placeholder) where `t` is passed as the final/trailing argument. SLF4J will attach `t` as the log event’s cause with the full stack trace; this is equivalent to SLF4J 2.x’s fluent `atLevel(...).setCause(t).log(...)` and is intentionally used to preserve SLF4J 1.x runtime compatibility.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/WindowsForeignFunctions.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.java
📚 Learning: 2026-07-30T00:35:22.638Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3547
File: oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdFirmware.java:82-82
Timestamp: 2026-07-30T00:35:22.638Z
Learning: In OSHI, treat changes as “API-breaking” only when they affect classes (or relevant API surface) annotated with `PublicAPI`. Public classes/members that are not annotated with `PublicAPI` should be reviewed as internal implementation details, even if they are public (e.g., classes like `oshi.hardware.common.platform.unix.BsdFirmware`). Also, respect intentional visibility decisions used for tests—e.g., methods like `BsdFirmware.parseDmesg(List<String>)` may be intentionally package-private to support tests within the same package; avoid widening visibility or altering signatures unless the related `PublicAPI` contract requires it.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/WindowsForeignFunctions.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.java
📚 Learning: 2026-08-02T23:56:23.866Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3565
File: oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/PosixLibcFunctions.java:51-56
Timestamp: 2026-08-02T23:56:23.866Z
Learning: For Java FFM bindings in the oshi-core-ffm module, assume a 64-bit JVM and 64-bit operating system. Do not flag 32-bit native ABI or memory-layout compatibility concerns, consistent with the project's JDK 25 support policy, unless that policy changes.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/WindowsForeignFunctions.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
📚 Learning: 2026-04-12T19:22:09.716Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:22:09.716Z
Learning: When reviewing OSHI hardware platform code that uses or implements `CentralProcessor`/`PhysicalProcessor.getEfficiency()`, remember the API’s counterintuitive semantics: a *higher* efficiency-class value indicates *greater performance* (lower efficiency). P-cores/“performance cores” should therefore have higher values (e.g., 1) than E-cores/“efficiency cores” (e.g., 0), as documented in the `CentralProcessor` Javadoc. Do not flag code as incorrect solely because ARM_P_CORES or Intel P-cores are assigned higher efficiency values.

Applied to files:

  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.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/windows/WindowsOperatingSystemJNA.java
🔇 Additional comments (14)
CHANGELOG.md (1)

9-9: LGTM!

oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.java (4)

7-33: LGTM!


51-124: LGTM!


126-197: LGTM!


204-242: LGTM!

oshi-common/src/test/java/oshi/software/common/os/windows/WindowsOperatingSystemTest.java (1)

12-14: LGTM!

Also applies to: 45-111

oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/WindowsForeignFunctions.java (1)

21-22: LGTM!

Also applies to: 64-86

oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java (3)

16-16: LGTM!

Also applies to: 92-104, 157-160, 249-249


273-307: LGTM!


320-331: LGTM!

oshi-core-ffm/src/test/java/oshi/ffm/platform/windows/WindowsForeignFunctionsTest.java (1)

1-37: LGTM!

oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.java (1)

111-145: LGTM!

Also applies to: 182-182

oshi-core/src/test/java/oshi/software/os/windows/WindowsOperatingSystemJNATest.java (1)

32-99: LGTM!

oshi-core-ffm/src/test/java/oshi/software/os/windows/WindowsOperatingSystemFFMTest.java (1)

5-5: LGTM!

Also applies to: 14-23, 58-64, 86-97

The tests added in the first commit live in packages no existing test
used: oshi.software.os.windows in both backends, and
oshi.ffm.platform.windows in oshi-core-ffm. Tests run patched into the
module under test, so JUnit cannot construct a test class whose package is
not opened to org.junit.platform.commons, and the Windows CI job failed
with InaccessibleObjectException for all five.

The opens for tests live in src/test/java/module-info.test rather than the
main module descriptor. Add the three missing entries.

This could only fail on Windows: @EnabledOnOs skips the container before
JUnit instantiates the class, so every other platform reported green.
Document that in AGENTS.md along with what module-info.test is for, since
nothing in the repo explained it, and note the trick of dropping an
unconditional throwaway test in the new package to check the wiring from
any platform.
@codecov

codecov Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.00000% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.55%. Comparing base (7ffc556) to head (189cb05).

Files with missing lines Patch % Lines
...ware/common/os/windows/WindowsOperatingSystem.java 87.50% 2 Missing and 5 partials ⚠️
...software/os/windows/WindowsOperatingSystemFFM.java 70.58% 0 Missing and 5 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3568      +/-   ##
============================================
+ Coverage     79.44%   79.55%   +0.10%     
- Complexity     3804     4040     +236     
============================================
  Files           709      709              
  Lines         24296    24224      -72     
  Branches       4064     4047      -17     
============================================
- Hits          19302    19271      -31     
+ Misses         2800     2771      -29     
+ Partials       2194     2182      -12     
Flag Coverage Δ
linux 36.96% <17.50%> (+0.13%) ⬆️
macos 37.89% <17.50%> (+0.13%) ⬆️
windows 44.69% <85.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@AGENTS.md`:
- Around line 143-146: Add the text language identifier to both fenced code
blocks containing the JVM --add-opens options and the related error output,
including the block around the JVM options and the block around the
accessibility error, while preserving their contents.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 17227f68-3c4d-4b0b-932c-e5de510f0da9

📥 Commits

Reviewing files that changed from the base of the PR and between 886f4e9 and 1d52af4.

📒 Files selected for processing (3)
  • AGENTS.md
  • oshi-core-ffm/src/test/java/module-info.test
  • oshi-core/src/test/java/module-info.test
📜 Review details
⏰ Context from checks skipped due to timeout. (6)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Analyze (java)
🧰 Additional context used
📓 Path-based instructions (3)
**/src/test/java/module-info.test

📄 CodeRabbit inference engine (AGENTS.md)

When adding tests in a previously unused package, add the package's appropriate --add-opens entry to that module's module-info.test; declare any required test --add-reads, --add-modules, or native-access options there as well.

Files:

  • oshi-core/src/test/java/module-info.test
  • oshi-core-ffm/src/test/java/module-info.test
**/*

📄 CodeRabbit inference engine (AGENTS.md)

Before a pull request, run the relevant validation gate in order: spotless:apply, checkstyle:check, install, forbiddenapis:check, and javadoc:javadoc; use -am with -pl, clean-rebuild after changing oshi-common, and use a JDK 25+ toolchain to compile FFM code.

Files:

  • oshi-core/src/test/java/module-info.test
  • AGENTS.md
  • oshi-core-ffm/src/test/java/module-info.test
**/*.{java,xml,properties,md}

📄 CodeRabbit inference engine (AGENTS.md)

Do not commit generated output, target/, or IDE files.

Files:

  • AGENTS.md
🪛 LanguageTool
AGENTS.md

[uncategorized] ~148-~148: The official name of this software platform is spelled with a capital “H”.
Context: ...latform.commons ``` The module name is com.github.oshi for `oshi-core`, `com.github.oshi...

(GITHUB)


[uncategorized] ~148-~148: The official name of this software platform is spelled with a capital “H”.
Context: ...e is com.github.oshi for oshi-core, com.github.oshi.ffm for oshi-core-ffm, and `com...

(GITHUB)


[uncategorized] ~148-~148: The official name of this software platform is spelled with a capital “H”.
Context: ...thub.oshi.ffmforoshi-core-ffm, and com.github.oshi.commonforoshi-common`. The sam...

(GITHUB)

🪛 markdownlint-cli2 (0.23.1)
AGENTS.md

[warning] 143-143: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


[warning] 157-157: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🔇 Additional comments (2)
oshi-core-ffm/src/test/java/module-info.test (1)

23-24: LGTM!

Also applies to: 27-28

oshi-core/src/test/java/module-info.test (1)

51-52: LGTM!

Comment thread AGENTS.md Resolved
Both fenced blocks added with the module-info.test section were untagged;
every other block in AGENTS.md declares one.
@dbwiddis
dbwiddis merged commit 79fe2aa into oshi:master Aug 3, 2026
16 checks passed
@dbwiddis
dbwiddis deleted the windows-os-shared-base branch August 3, 2026 04:14
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