Repository navigation
Share the Windows OS layer between the backends and fix the FFM process lookup - #3568
Conversation
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout. (6)
📝 WalkthroughWalkthroughWindows process enumeration and version parsing now reside in ChangesWindows process and version handling
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
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
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 valueConfirm that the parent-PID assertion tolerates empty performance-counter data.
WindowsOperatingSystemFFM.queryParentPidMapbuilds the map fromgetCachedProcessMap(). If both the registry and the performance-counter sources return no data,resolveProcessMapreturns 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 valueConsider 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
ParseUtilrather thanInteger.parseInt, becauseoshi-commonbans the direct numeric parsing APIs.As per coding guidelines: "Use
oshi.util.ParseUtilmethods instead of banned numeric parsing APIs such asInteger.parseInt,Long.parseLong,Double.parseDouble, andInteger.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
📒 Files selected for processing (9)
CHANGELOG.mdoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.javaoshi-common/src/test/java/oshi/software/common/os/windows/WindowsOperatingSystemTest.javaoshi-core-ffm/src/main/java/oshi/ffm/platform/windows/WindowsForeignFunctions.javaoshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core-ffm/src/test/java/oshi/ffm/platform/windows/WindowsForeignFunctionsTest.javaoshi-core-ffm/src/test/java/oshi/software/os/windows/WindowsOperatingSystemFFMTest.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.javaoshi-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 useorg.slf4j.event.**; useoshi.util.LogLevelinstead.
Add the imports needed by code, and let Spotless own formatting and import ordering.
Verify native struct offsets, field widths, andsysctl/ioctlconstants 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.javaoshi-core-ffm/src/test/java/oshi/ffm/platform/windows/WindowsForeignFunctionsTest.javaoshi-core-ffm/src/main/java/oshi/ffm/platform/windows/WindowsForeignFunctions.javaoshi-common/src/test/java/oshi/software/common/os/windows/WindowsOperatingSystemTest.javaoshi-core-ffm/src/test/java/oshi/software/os/windows/WindowsOperatingSystemFFMTest.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.javaoshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-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 asList<String>orString, 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.javaoshi-core-ffm/src/test/java/oshi/ffm/platform/windows/WindowsForeignFunctionsTest.javaoshi-common/src/test/java/oshi/software/common/os/windows/WindowsOperatingSystemTest.javaoshi-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-ffmmust not referencecom.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.javaoshi-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 fromoshi.annotation.concurrent, matching the modeled class when applicable.
Memoize constant or expensive, slowly changing system-call results withoshi.util.Memoizer, following surrounding patterns and usingdefaultExpiration()when values must refresh.
Place reusable per-OS acquisition and parsing helpers inoshi/driver/<os>/; keep parsing logic out of HAL classes where practical.
Prefer native calls for system information; on Linux preferFileUtilfor/procand/sys, while on other platformsExecutingCommandis 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.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.javaoshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-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: Keeposhi-commonpure 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.
Useoshi.util.ParseUtilmethods instead of banned numeric parsing APIs such asInteger.parseInt,Long.parseLong,Double.parseDouble, andInteger.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-coremust compile with Java 8; do not use modern features such asvar, records, switch expressions, text blocks,List.of, orStream.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.javaoshi-core-ffm/src/test/java/oshi/ffm/platform/windows/WindowsForeignFunctionsTest.javaoshi-core-ffm/src/main/java/oshi/ffm/platform/windows/WindowsForeignFunctions.javaoshi-common/src/test/java/oshi/software/common/os/windows/WindowsOperatingSystemTest.javaoshi-core-ffm/src/test/java/oshi/software/os/windows/WindowsOperatingSystemFFMTest.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.javaoshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-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.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.javaoshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-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.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOperatingSystem.javaoshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-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.javaoshi-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 Report❌ Patch coverage is 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
AGENTS.mdoshi-core-ffm/src/test/java/module-info.testoshi-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-opensentry to that module'smodule-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.testoshi-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, andjavadoc:javadoc; use-amwith-pl, clean-rebuild after changingoshi-common, and use a JDK 25+ toolchain to compile FFM code.
Files:
oshi-core/src/test/java/module-info.testAGENTS.mdoshi-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!
Both fenced blocks added with the module-info.test section were untagged; every other block in AGENTS.md declares one.
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.processMapToListfiltered an explicit pid request against the perf counter map alone, skipping the WTS map that the all-processes path intersects with. Both backends agree whenpids == 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.updateAttributesexplicitly tolerates a nullWtsInfo, andWindowsOSProcessFFMignores a failedOpenProcess, so the state stayedRUNNINGandProcessFiltering.VALID_PROCESSpassed it through. The caller got a process reportingRUNNINGwith an empty path, zero threads, zero virtual size and zero CPU time.Put plainly:
getProcess(pid)could return a process thatgetProcesses()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 thepids == nullbranch already said WTS enrichment was required for full data, which is just as true for an explicit pid.Sharing the code
queryFamilyVersionInfoandprocessMapToListwere both duplicated between the twins, andprocessMapToListis exactly where they drifted apart. Both now live in the commonWindowsOperatingSystembase.The version logic is split so the parsing is separable from the acquisition:
parseVersionInfoandresolveVersionAliasare pure and unit tested on every platform rather than only under Windows CI. That also settles JNA comparing the service pack againstConstants.UNKNOWNwhere 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
OSProcessfactory. Because the builders take the pid collection, the fourqueryXMapFromY()wrappers that existed only as memoizer method references are gone.queryParentPidMapis 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.succeededOrLogreplaces the repeated "logGetLastErrorand bail" guard, and fixes five FFM sites that logged theOptionalIntwrapper instead of the error code.resolveProcessMapreturns an empty map rather than null when neither source has data — reachable on both backends before.USE_PROCSTATE_SUSPENDED, which shadowed the identical inherited constant.WindowsOperatingSystemJNATestmirroring the FFM backend's test, and movedWindowsOperatingSystemFFMTestinto the package of the class under test.Compatibility
queryAllProcesses,queryChildProcesses,queryDescendantProcessesandqueryFamilyVersionInfoareprotectedon the base; they werepublicon the concrete classes only because each override widened them.getProcesses(Collection)andgetProcess(int)remain public, and theOperatingSysteminterface 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
Release Notes