Repository navigation
Migrate Windows software OS classes to common/JNA/FFM pattern - #3177
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughExtracts WTS process info into a new top-level Changes
Sequence Diagram(s)sequenceDiagram
participant Common as WindowsOSProcess (common)
participant Impl as Impl (JNA/FFM)
participant Perf as PerfCounter/Registry
participant WTS as ProcessWtsData (WTS)
participant Threads as OSThread instances
Common->>Impl: updateAttributes()
Impl->>Perf: buildProcessMapFromRegistry(pids) or fallback to perf counters
Perf-->>Impl: Map<pid, ProcessPerfCounterBlock>
Impl->>WTS: queryProcessWtsMap(pids)
WTS-->>Impl: Map<pid, WtsInfo>
Impl->>Impl: setTcb(queryMatchingThreads(pids))
Impl->>Threads: createOSThread(pid, tid, procName, pcb)
Threads-->>Impl: thread.updateAttributes(procName, pcb)
Impl-->>Common: updateAttributes(ProcessPerfCounterBlock, WtsInfo) per-process
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3177 +/- ##
=======================================
Coverage 57.29% 57.30%
=======================================
Files 414 417 +3
Lines 19919 19973 +54
Branches 3496 3510 +14
=======================================
+ Hits 11413 11445 +32
- Misses 6786 6799 +13
- Partials 1720 1729 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (6)
oshi-common/src/main/java/oshi/driver/common/windows/registry/WtsInfo.java (1)
10-79: Optional: mark immutable data holderfinal.All fields are already
finaland this is purely a data holder, so making the classfinalwould prevent accidental inheritance. Very minor.Proposed tweak
-public class WtsInfo { +public final class WtsInfo {Also — if the project targets a Java version that supports it here (oshi-common), a
recordwould collapse this nicely. Totally fine to keep as-is for consistency with other data holders in this module.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/main/java/oshi/driver/common/windows/registry/WtsInfo.java` around lines 10 - 79, Mark the WtsInfo data holder class as final to prevent accidental inheritance: update the class declaration for WtsInfo so it is declared final (e.g., public final class WtsInfo) while leaving all existing final fields and constructor unchanged; optionally consider converting to a Java record if language level permits, but the immediate fix is to make the WtsInfo class final.oshi-core/src/main/java/oshi/software/os/windows/WindowsNetworkParamsJNA.java (1)
30-32: Nit: stale class name in Javadoc.The Javadoc still references "WindowsNetworkParams" but the class is now
WindowsNetworkParamsJNA. Totally optional to update.Proposed tweak
/** - * WindowsNetworkParams class. + * WindowsNetworkParamsJNA class. */🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-core/src/main/java/oshi/software/os/windows/WindowsNetworkParamsJNA.java` around lines 30 - 32, Update the class Javadoc so the description matches the actual class name: replace the stale "WindowsNetworkParams" reference with "WindowsNetworkParamsJNA" in the Javadoc block above the WindowsNetworkParamsJNA class declaration; ensure the short description and any `@author/`@since lines (if present) consistently refer to WindowsNetworkParamsJNA.oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java (1)
93-101: Nit: stale constructor Javadoc.Javadoc still says "Constructor for WindowsFileSystem." Purely cosmetic.
Proposed tweak
/** * <p> - * Constructor for WindowsFileSystem. + * Constructor for WindowsFileSystemJNA. * </p> */ public WindowsFileSystemJNA() {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java` around lines 93 - 101, The constructor Javadoc for WindowsFileSystemJNA is stale ("Constructor for WindowsFileSystem"); update the JavaDoc above the WindowsFileSystemJNA() constructor to accurately describe its purpose (e.g., mention setting the Windows error mode to avoid prompts for floppy/CD-ROM) and retain reference to Kernel32.INSTANCE.SetErrorMode and SEM_FAILCRITICALERRORS so readers know why the constructor exists.oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java (1)
182-188: Note thatgetCurrentProcess()can return null (consistent across all platform implementations).
getCurrentProcess()may returnnullwhen the process is not found. All platform implementations (JNA and FFM across Windows, macOS, Linux, BSD, and AIX) use the same pattern without guarding—callingproc.getThreadDetails()andproc.getProcessID()directly. While this will throw aNullPointerExceptionif the current process cannot be retrieved, this appears to be an established design throughout the codebase. If you'd like to add a null guard for defensive robustness, your suggestion above is a good approach; otherwise, this matches the existing pattern.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java` around lines 182 - 188, Guard against getCurrentProcess() returning null in getCurrentThread(): call getCurrentProcess() once into a local (proc), call getThreadId() for tid, and if proc is null return a fallback WindowsOSThreadFFM using a sane default PID (e.g., 0) and tid; otherwise proceed to search proc.getThreadDetails() and use proc.getProcessID() as before. Update getCurrentThread() to use these symbols: getCurrentProcess(), getThreadId(), proc.getThreadDetails(), proc.getProcessID(), and WindowsOSThreadFFM(...).oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java (1)
99-114: Nit: variable namepcbshadows the single-block meaning used elsewhere.
pcbhere is aMap<Integer, ProcessPerfCounterBlock>, but in the protectedupdateAttributes(ProcessPerfCounterBlock pcb, WtsInfo wts)on line 117 the same name refers to a single block. Consider renaming the local map (e.g.,pcbMap/perfMap) to matchwts/wtsMapstyle elsewhere. Same applies to the siblingWindowsOSProcessJNA.updateAttributes().🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java` around lines 99 - 114, Local variable name pcb in WindowsOSProcessFFM.updateAttributes() is a Map<Integer, ProcessPerfCounterBlock> that conflicts with the single-block parameter name used by the protected updateAttributes(ProcessPerfCounterBlock pcb, WtsInfo wts); rename the local Map to pcbMap or perfMap (and update all references, including the ternary when calling updateAttributes) to avoid shadowing, and make the same rename in the sibling WindowsOSProcessJNA.updateAttributes() for consistency (retain calls to ProcessPerformanceDataFFM.buildProcessMapFromRegistry/buildProcessMapFromPerfCounters and ProcessWtsData.queryProcessWtsMap as-is).oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java (1)
12-17: Optional: importjava.util.Setinstead of fully qualifying it.
Setisn't in the import list, so the abstract declaration on line 376 falls back tojava.util.Set<Integer>. A one-line import would align with the neighboringMap/List/Collectionsimports.♻️ Proposed change
import java.util.Map; +import java.util.Set; import java.util.function.Supplier;- protected abstract Map<Integer, ThreadPerfCounterBlock> queryMatchingThreads(java.util.Set<Integer> pids); + protected abstract Map<Integer, ThreadPerfCounterBlock> queryMatchingThreads(Set<Integer> pids);Also applies to: 376-376
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java` around lines 12 - 17, Add a one-line import for java.util.Set and update the abstract declaration that currently uses the fully qualified java.util.Set<Integer> to use the imported Set<Integer> instead; locate the declaration in the WindowsOSProcess class (the abstract declaration currently written as java.util.Set<Integer>) and replace the fully-qualified type with Set<Integer> after adding import java.util.Set; this aligns imports with List/Map/Collections and removes the fully-qualified reference.
🤖 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/main/java/oshi/driver/common/windows/registry/WtsInfo.java`:
- Around line 10-79: Mark the WtsInfo data holder class as final to prevent
accidental inheritance: update the class declaration for WtsInfo so it is
declared final (e.g., public final class WtsInfo) while leaving all existing
final fields and constructor unchanged; optionally consider converting to a Java
record if language level permits, but the immediate fix is to make the WtsInfo
class final.
In
`@oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java`:
- Around line 12-17: Add a one-line import for java.util.Set and update the
abstract declaration that currently uses the fully qualified
java.util.Set<Integer> to use the imported Set<Integer> instead; locate the
declaration in the WindowsOSProcess class (the abstract declaration currently
written as java.util.Set<Integer>) and replace the fully-qualified type with
Set<Integer> after adding import java.util.Set; this aligns imports with
List/Map/Collections and removes the fully-qualified reference.
In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java`:
- Around line 182-188: Guard against getCurrentProcess() returning null in
getCurrentThread(): call getCurrentProcess() once into a local (proc), call
getThreadId() for tid, and if proc is null return a fallback WindowsOSThreadFFM
using a sane default PID (e.g., 0) and tid; otherwise proceed to search
proc.getThreadDetails() and use proc.getProcessID() as before. Update
getCurrentThread() to use these symbols: getCurrentProcess(), getThreadId(),
proc.getThreadDetails(), proc.getProcessID(), and WindowsOSThreadFFM(...).
In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java`:
- Around line 99-114: Local variable name pcb in
WindowsOSProcessFFM.updateAttributes() is a Map<Integer,
ProcessPerfCounterBlock> that conflicts with the single-block parameter name
used by the protected updateAttributes(ProcessPerfCounterBlock pcb, WtsInfo
wts); rename the local Map to pcbMap or perfMap (and update all references,
including the ternary when calling updateAttributes) to avoid shadowing, and
make the same rename in the sibling WindowsOSProcessJNA.updateAttributes() for
consistency (retain calls to
ProcessPerformanceDataFFM.buildProcessMapFromRegistry/buildProcessMapFromPerfCounters
and ProcessWtsData.queryProcessWtsMap as-is).
In `@oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java`:
- Around line 93-101: The constructor Javadoc for WindowsFileSystemJNA is stale
("Constructor for WindowsFileSystem"); update the JavaDoc above the
WindowsFileSystemJNA() constructor to accurately describe its purpose (e.g.,
mention setting the Windows error mode to avoid prompts for floppy/CD-ROM) and
retain reference to Kernel32.INSTANCE.SetErrorMode and SEM_FAILCRITICALERRORS so
readers know why the constructor exists.
In
`@oshi-core/src/main/java/oshi/software/os/windows/WindowsNetworkParamsJNA.java`:
- Around line 30-32: Update the class Javadoc so the description matches the
actual class name: replace the stale "WindowsNetworkParams" reference with
"WindowsNetworkParamsJNA" in the Javadoc block above the WindowsNetworkParamsJNA
class declaration; ensure the short description and any `@author/`@since lines (if
present) consistently refer to WindowsNetworkParamsJNA.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cd135b71-c221-4b30-a30d-f6fe5a73e76f
📒 Files selected for processing (15)
oshi-common/src/main/java/oshi/driver/common/windows/registry/WtsInfo.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSThread.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSThreadFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessWtsData.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsInstalledAppsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsNetworkParamsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSFileStoreJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSThreadJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.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). (8)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Test JDK 11, macos-latest
- GitHub Check: Analyze (java)
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
🧰 Additional context used
🧠 Learnings (15)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3173
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java:107-193
Timestamp: 2026-04-18T22:53:49.248Z
Learning: In OSHI's `WmiQueryHandlerFFM` (oshi-core-java25) and the JNA `WmiQueryHandler` (oshi-core), the `failedWmiClassNames` cache intentionally keys failures by WMI class name only (not namespace). This is a pre-existing, accepted pattern shared between both implementations. Do not flag this as a bug in future reviews — the project maintainer (dbwiddis) confirmed it does not impact callers and the added complexity of a composite namespace+class key is not warranted.
📚 Learning: 2026-04-18T22:53:49.248Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3173
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java:107-193
Timestamp: 2026-04-18T22:53:49.248Z
Learning: In OSHI's `WmiQueryHandlerFFM` (oshi-core-java25) and the JNA `WmiQueryHandler` (oshi-core), the `failedWmiClassNames` cache intentionally keys failures by WMI class name only (not namespace). This is a pre-existing, accepted pattern shared between both implementations. Do not flag this as a bug in future reviews — the project maintainer (dbwiddis) confirmed it does not impact callers and the added complexity of a composite namespace+class key is not warranted.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSFileStoreJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsNetworkParamsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-common/src/main/java/oshi/driver/common/windows/registry/WtsInfo.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessWtsData.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/WindowsFileSystemJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSFileStoreJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsNetworkParamsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsInstalledAppsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSThreadJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
📚 Learning: 2026-04-03T02:07:49.467Z
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:49.467Z
Learning: In `oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHWDiskStoreFFM.java` (and similar FFM/API implementations in OSHI), the `updateAttributes()` method intentionally uses `catch (Throwable e) { return false; }` without logging. This is by design: `updateAttributes()` is a public API method whose contract is to return `false` on failure; callers consume the boolean and would never see log output, so adding a log statement is not desired.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOSFileStoreJNA.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/src/main/java/oshi/software/os/windows/WindowsNetworkParamsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSThread.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java
📚 Learning: 2026-04-08T00:58:10.736Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3125
File: oshi-core-java25/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java:131-133
Timestamp: 2026-04-08T00:58:10.736Z
Learning: In `oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceJNA.java` and `oshi-core-java25/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java`, the `getPowerSources()` method intentionally returns a singleton list wrapping a single `getPowerSource("System Battery")` call, and the enumeration loop short-circuits after the first eligible battery pack. This matches the longstanding JNA behavior and is not a bug. A broader refactor to support zero-or-more batteries across both implementations is planned for a later date. Do not flag this as an issue.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.java
📚 Learning: 2026-04-19T01:28:43.529Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3174
File: oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java:237-257
Timestamp: 2026-04-19T01:28:43.529Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`, the WMI comparison tests (e.g., `testProcessor`) intentionally validate only index 0 and a few representative fields per WMI data type (String, uint16, uint32, uint64). Exhaustive row-by-row comparison is deliberately avoided for numerically heavy multi-row tables. The design rationale is: matching row counts + a few selected fields covering each data type is sufficient to verify JNA vs FFM driver parity. Do not suggest looping over all rows for these tests.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java
📚 Learning: 2026-04-18T03:18:03.725Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:03.725Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java
📚 Learning: 2026-04-17T23:43:33.461Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java:0-0
Timestamp: 2026-04-17T23:43:33.461Z
Learning: In `oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java`, the `PDH_RAW_COUNTER_LAYOUT` Java FFM struct layout must place `FirstValue` at byte offset 16 (not 12). The native MSVC compiler inserts 4 bytes of implicit alignment padding before the `LONGLONG FirstValue` field (after CStatus=4 bytes + FILETIME TimeStamp=8 bytes = 12 bytes), because LONGLONG requires 8-byte alignment. The total struct size is 40 bytes (with trailing padding). Do not use JAVA_LONG_UNALIGNED without explicit padding here, as that incorrectly places FirstValue at offset 12 and causes reads of garbage counter values.
Applied to files:
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSThreadFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java
📚 Learning: 2026-03-29T20:03:00.830Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java:87-89
Timestamp: 2026-03-29T20:03:00.830Z
Learning: In the OSHI FFM codebase (oshi-core-java25), all PDH/Kernel32/COM wrapper methods in classes like PdhFFM, Kernel32FFM, etc. declare `throws Throwable` solely as a compiler artifact of `MethodHandle.invokeExact`. They are native calls and do not throw Java checked exceptions in practice. The enclosing `getOpenFileDescriptors()` method in PdhUtilFFM already has an outer `catch (Throwable t)` that covers the entire method body including any `finally` blocks, so no exception-masking concern exists for cleanup calls like `PdhCloseQuery` in `finally`.
Applied to files:
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
📚 Learning: 2026-04-17T23:52:52.926Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java:47-58
Timestamp: 2026-04-17T23:52:52.926Z
Learning: In `oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java`, the `stopDaemon()` / `startDaemon()` lifecycle pattern (both `public synchronized` instance methods on the same monitor) is intentionally safe: `stopDaemon()` sets `loadAvgThread = null` immediately after `interrupt()`, and `startDaemon()` checks `loadAvgThread != null` under the same lock. Since both methods are synchronized on `this`, they cannot run concurrently, so no double-sampler race is possible. Do not flag this pattern as a race condition.
Applied to files:
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.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/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSThreadFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.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/driver/common/windows/registry/WtsInfo.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSThread.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java
📚 Learning: 2026-04-17T23:56:43.867Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java:287-298
Timestamp: 2026-04-17T23:56:43.867Z
Learning: In `oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java`, the `queryWildcardCounters` method intentionally aborts and returns an empty Pair when any `addEnglishCounter` call fails. This is by design: the returned `Pair<List<String>, Map<T, List<Long>>>` requires strict parallel alignment between the instance list and each per-property value list. Aborting on failure preserves this alignment contract. This is different from `queryCounters` (non-wildcard), which gracefully skips individual failed counters since it returns a flat `Map<T, Long>` with no alignment constraint.
Applied to files:
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.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/main/java/oshi/software/common/os/windows/WindowsOSThread.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java
🔇 Additional comments (12)
oshi-core/src/main/java/oshi/software/os/windows/WindowsInstalledAppsJNA.java (1)
12-20: LGTM — clean rename.Class and constructor rename consistently applied; the added
Listimport is correct for the return type.oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSThread.java (1)
94-153: LGTM — clean extraction to common.Null-guard on
procNameinupdateAttributes(Line 114) is a nice addition over the prior behavior which only checkedisEmpty().getProcName()returning""for a null name also keeps subclasses from having to special-case it.One small inconsistency worth noting (purely cosmetic): some assignments use
this.name/this.prioritywhile others use barename,state, etc. Not a bug, just unalike. Feel free to ignore.oshi-core/src/main/java/oshi/software/os/windows/WindowsOSFileStoreJNA.java (1)
27-44: LGTM.Consistent with the
WindowsFileSystem→WindowsFileSystemJNArename. Behavior unchanged.oshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.java (1)
52-52: LGTM.Rename applied consistently;
stateLookupTCP state mappings are unchanged (1/12→CLOSED, 2→LISTEN, ..., 11→TIME_WAIT, default→UNKNOWN).Also applies to: 219-247
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.java (1)
120-446: Clean rename pass — LGTM.All constructor/factory references consistently updated to the
*JNAvariants, and the new top-levelWtsInfoimport replaces the removed nested type. Context snippets confirm the referenced JNA classes (WindowsFileSystemJNA,WindowsInternetProtocolStatsJNA,WindowsOSThreadJNA,WindowsInstalledAppsJNA) expose the expected constructors/static methods.oshi-core/src/main/java/oshi/driver/windows/registry/ProcessWtsData.java (1)
22-101: Extraction to sharedWtsInfolooks correct.Both code paths (
queryProcessWtsMapFromWTSandqueryProcessWtsMapFromPerfMon) invoke the new top-leveloshi.driver.common.windows.registry.WtsInfowith the same 7-arg order as the moved constructor, and the parameter types align (int, long, long, long, long, long).oshi-core/src/main/java/oshi/software/os/windows/WindowsOSThreadJNA.java (1)
19-32: Implementation looks good.The
updateAttributes()override correctly delegates to the protected 2-arg helper, and the ternary guards against a null map beforeget(tid). Parallel structure withWindowsOSThreadFFMmakes the JNA/FFM split easy to reason about.oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSThreadFFM.java (1)
19-32: Mirrors the JNA implementation cleanly — LGTM.Parallel to
WindowsOSThreadJNA, routing throughThreadPerformanceDataFFM.buildThreadMapFromPerfCounters(pids, procName, threadNum). Nothing to flag.oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java (1)
148-175: Overrides line up with the new abstract hooks.
createOSThread,queryMatchingThreads, andqueryCommandLineall match the signatures declared in the commonWindowsOSProcess, and the command-line fallback chain (cwdCmdEnv → batch cache → WMI) mirrors the JNA path.oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java (1)
85-162: Symmetric withWindowsOSProcessFFM— looks good.Command-line fallback chain, thread map query priority (registry → perf counters with process-name filter), and suspended-thread handling under
USE_PROCSTATE_SUSPENDEDare all mirrored between JNA and FFM. Nothing additional to flag here beyond thepcblocal-variable naming nit noted on the FFM side.oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java (2)
263-282: Abstraction split reads cleanly.Hoisting the thread-map lookup behind
queryMatchingThreads(...)and thread construction behindcreateOSThread(...)keeps the common class platform-agnostic while preserving thetcb-cache short-circuit. Thethis.nameused when buildingOSThreadinstances is already populated viaupdateAttributes(...)in the constructor, so the invariant holds.
37-45: Relocation ofMAX_WINDOWS_HANDLESis fine.Moving this constant out of the (now renamed)
WindowsFileSystemand into the common process class avoids a cross-module dependency from the abstract process onto a JNA-specific filesystem class. TheProgramFiles(x86)probe preserves the 32-bit vs. 64-bit handle cap semantics from the original implementation.
e1d0946 to
3d1eb6e
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (4)
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java (1)
182-192: ConsiderorElseGetto avoid eagerly constructing the fallback thread.
orElse(new WindowsOSThreadFFM(...))always allocates and runs theWindowsOSThreadFFMconstructor — which invokesupdateAttributes(null, null)and sets state toINVALID— even whenfindFirst()succeeds. Deferring viaorElseGetkeeps the common (hit) path allocation-free.♻️ Proposed refactor
- return proc.getThreadDetails().stream().filter(t -> t.getThreadId() == tid).findFirst() - .orElse(new WindowsOSThreadFFM(proc.getProcessID(), tid, null, null)); + return proc.getThreadDetails().stream().filter(t -> t.getThreadId() == tid).findFirst() + .orElseGet(() -> new WindowsOSThreadFFM(proc.getProcessID(), tid, null, null));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java` around lines 182 - 192, The getCurrentThread() method eagerly constructs the fallback WindowsOSThreadFFM via orElse(...), causing updateAttributes(null, null) and INVALID state to run even when findFirst() succeeds; change the terminal call to use orElseGet(...) with a Supplier that constructs the new WindowsOSThreadFFM(proc.getProcessID(), tid, null, null) so the fallback object is created lazily only when needed (modify the return expression in getCurrentThread() to call orElseGet(() -> new WindowsOSThreadFFM(...))).oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java (1)
148-162: Optional: cache the memoized cwdCmdEnv command-line locally to avoid the double call.
getCwdCmdEnv().getB()is already memoized in the base class, so the cost is tiny, but calling it twice here reads slightly awkwardly. A local variable also mirrors the common pattern used inWindowsOSProcess.queryCwd().♻️ Proposed refactor
protected String queryCommandLine() { - if (!getCwdCmdEnv().getB().isEmpty()) { - return getCwdCmdEnv().getB(); - } + String cmd = getCwdCmdEnv().getB(); + if (!cmd.isEmpty()) { + return cmd; + } if (USE_BATCH_COMMANDLINE) { return Win32ProcessCachedJNA.getInstance().getCommandLine(getProcessID(), getStartTime()); } WmiResult<CommandLineProperty> commandLineProcs = Win32ProcessJNA .queryCommandLines(Collections.singleton(getProcessID())); if (commandLineProcs.getResultCount() > 0) { return WmiUtil.getString(commandLineProcs, CommandLineProperty.COMMANDLINE, 0); } return ""; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java` around lines 148 - 162, In queryCommandLine(), avoid calling getCwdCmdEnv().getB() twice by caching it in a local variable; specifically, at the top of the method assign String cwdCmd = getCwdCmdEnv().getB() and then check cwdCmd.isEmpty() and return cwdCmd if not empty, leaving the rest of the logic (USE_BATCH_COMMANDLINE -> Win32ProcessCachedJNA.getInstance().getCommandLine(getProcessID(), getStartTime()); else -> Win32ProcessJNA.queryCommandLines(...)) unchanged.oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSThread.java (1)
110-118: Nit: inconsistentthis.nameusage insideupdateAttributes.Line 115 writes
name = pcb.getName();while line 117 usesthis.name = .... Since this class has nonameparameter in scope, both are equivalent, but aligning both branches onthis.name(or both without) makes the else-if/else pair easier to scan.♻️ Proposed nit
- } else if (pcb.getName().contains("/") || procName == null || procName.isEmpty()) { - name = pcb.getName(); - } else { - this.name = procName + "/" + pcb.getName(); - } + } else if (pcb.getName().contains("/") || procName == null || procName.isEmpty()) { + this.name = pcb.getName(); + } else { + this.name = procName + "/" + pcb.getName(); + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSThread.java` around lines 110 - 118, In WindowsOSThread.updateAttributes, the assignment in the first branch uses the bare name variable while the else branch uses this.name; change the first branch to assign this.name = pcb.getName() so both branches consistently reference the instance field (keep references to pcb.getName() and procName as-is).oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java (1)
162-175: Optional: same tiny redundancy as the JNA variant.
getCwdCmdEnv().getB()is called twice; a local captures it once and keeps both implementations symmetric. Memoization in the base already makes this negligible, but parity with the JNA side is nice.♻️ Proposed refactor
protected String queryCommandLine() { - if (!getCwdCmdEnv().getB().isEmpty()) { - return getCwdCmdEnv().getB(); - } + String cmd = getCwdCmdEnv().getB(); + if (!cmd.isEmpty()) { + return cmd; + } if (USE_BATCH_COMMANDLINE) { return Win32ProcessCachedFFM.getInstance().getCommandLine(getProcessID(), getStartTime()); } var commandLineProcs = Win32ProcessFFM.queryCommandLines(Collections.singleton(getProcessID())); if (commandLineProcs.getResultCount() > 0) { return WmiUtilFFM.getString(commandLineProcs, CommandLineProperty.COMMANDLINE, 0); } return ""; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java` around lines 162 - 175, queryCommandLine() calls getCwdCmdEnv().getB() twice; capture its result in a local variable (e.g., String cwdCmdEnvB) at the top of the method and use that single variable in the first if-check to mirror the JNA variant and avoid redundant calls; leave the rest of the method (USE_BATCH_COMMANDLINE path using Win32ProcessCachedFFM.getInstance().getCommandLine(getProcessID(), getStartTime()) and the fallback using Win32ProcessFFM.queryCommandLines(...) with WmiUtilFFM.getString(..., CommandLineProperty.COMMANDLINE, 0)) unchanged.
🤖 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/main/java/oshi/software/common/os/windows/WindowsOSThread.java`:
- Around line 110-118: In WindowsOSThread.updateAttributes, the assignment in
the first branch uses the bare name variable while the else branch uses
this.name; change the first branch to assign this.name = pcb.getName() so both
branches consistently reference the instance field (keep references to
pcb.getName() and procName as-is).
In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java`:
- Around line 182-192: The getCurrentThread() method eagerly constructs the
fallback WindowsOSThreadFFM via orElse(...), causing updateAttributes(null,
null) and INVALID state to run even when findFirst() succeeds; change the
terminal call to use orElseGet(...) with a Supplier that constructs the new
WindowsOSThreadFFM(proc.getProcessID(), tid, null, null) so the fallback object
is created lazily only when needed (modify the return expression in
getCurrentThread() to call orElseGet(() -> new WindowsOSThreadFFM(...))).
In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java`:
- Around line 162-175: queryCommandLine() calls getCwdCmdEnv().getB() twice;
capture its result in a local variable (e.g., String cwdCmdEnvB) at the top of
the method and use that single variable in the first if-check to mirror the JNA
variant and avoid redundant calls; leave the rest of the method
(USE_BATCH_COMMANDLINE path using
Win32ProcessCachedFFM.getInstance().getCommandLine(getProcessID(),
getStartTime()) and the fallback using Win32ProcessFFM.queryCommandLines(...)
with WmiUtilFFM.getString(..., CommandLineProperty.COMMANDLINE, 0)) unchanged.
In `@oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java`:
- Around line 148-162: In queryCommandLine(), avoid calling
getCwdCmdEnv().getB() twice by caching it in a local variable; specifically, at
the top of the method assign String cwdCmd = getCwdCmdEnv().getB() and then
check cwdCmd.isEmpty() and return cwdCmd if not empty, leaving the rest of the
logic (USE_BATCH_COMMANDLINE ->
Win32ProcessCachedJNA.getInstance().getCommandLine(getProcessID(),
getStartTime()); else -> Win32ProcessJNA.queryCommandLines(...)) unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4db87518-7a83-4823-8c9f-a67d01adf4d0
📒 Files selected for processing (16)
CHANGELOG.mdoshi-common/src/main/java/oshi/driver/common/windows/registry/WtsInfo.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSThread.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSThreadFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessWtsData.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsInstalledAppsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsNetworkParamsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSFileStoreJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSThreadJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.java
✅ Files skipped from review due to trivial changes (3)
- oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
- CHANGELOG.md
- oshi-common/src/main/java/oshi/driver/common/windows/registry/WtsInfo.java
🚧 Files skipped from review as they are similar to previous changes (7)
- oshi-core/src/main/java/oshi/software/os/windows/WindowsOSFileStoreJNA.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsNetworkParamsJNA.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsOSThreadJNA.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsInstalledAppsJNA.java
- oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSThreadFFM.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). (7)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Analyze (java)
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
🧰 Additional context used
🧠 Learnings (13)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3173
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java:107-193
Timestamp: 2026-04-18T22:53:49.248Z
Learning: In OSHI's `WmiQueryHandlerFFM` (oshi-core-java25) and the JNA `WmiQueryHandler` (oshi-core), the `failedWmiClassNames` cache intentionally keys failures by WMI class name only (not namespace). This is a pre-existing, accepted pattern shared between both implementations. Do not flag this as a bug in future reviews — the project maintainer (dbwiddis) confirmed it does not impact callers and the added complexity of a composite namespace+class key is not warranted.
📚 Learning: 2026-04-17T23:43:33.461Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java:0-0
Timestamp: 2026-04-17T23:43:33.461Z
Learning: In `oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java`, the `PDH_RAW_COUNTER_LAYOUT` Java FFM struct layout must place `FirstValue` at byte offset 16 (not 12). The native MSVC compiler inserts 4 bytes of implicit alignment padding before the `LONGLONG FirstValue` field (after CStatus=4 bytes + FILETIME TimeStamp=8 bytes = 12 bytes), because LONGLONG requires 8-byte alignment. The total struct size is 40 bytes (with trailing padding). Do not use JAVA_LONG_UNALIGNED without explicit padding here, as that incorrectly places FirstValue at offset 12 and causes reads of garbage counter values.
Applied to files:
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java
📚 Learning: 2026-04-18T03:18:03.725Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:03.725Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).
Applied to files:
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java
📚 Learning: 2026-04-18T22:53:49.248Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3173
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java:107-193
Timestamp: 2026-04-18T22:53:49.248Z
Learning: In OSHI's `WmiQueryHandlerFFM` (oshi-core-java25) and the JNA `WmiQueryHandler` (oshi-core), the `failedWmiClassNames` cache intentionally keys failures by WMI class name only (not namespace). This is a pre-existing, accepted pattern shared between both implementations. Do not flag this as a bug in future reviews — the project maintainer (dbwiddis) confirmed it does not impact callers and the added complexity of a composite namespace+class key is not warranted.
Applied to files:
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessWtsData.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
📚 Learning: 2026-04-19T01:28:43.529Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3174
File: oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java:237-257
Timestamp: 2026-04-19T01:28:43.529Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`, the WMI comparison tests (e.g., `testProcessor`) intentionally validate only index 0 and a few representative fields per WMI data type (String, uint16, uint32, uint64). Exhaustive row-by-row comparison is deliberately avoided for numerically heavy multi-row tables. The design rationale is: matching row counts + a few selected fields covering each data type is sufficient to verify JNA vs FFM driver parity. Do not suggest looping over all rows for these tests.
Applied to files:
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
📚 Learning: 2026-03-29T20:03:00.830Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java:87-89
Timestamp: 2026-03-29T20:03:00.830Z
Learning: In the OSHI FFM codebase (oshi-core-java25), all PDH/Kernel32/COM wrapper methods in classes like PdhFFM, Kernel32FFM, etc. declare `throws Throwable` solely as a compiler artifact of `MethodHandle.invokeExact`. They are native calls and do not throw Java checked exceptions in practice. The enclosing `getOpenFileDescriptors()` method in PdhUtilFFM already has an outer `catch (Throwable t)` that covers the entire method body including any `finally` blocks, so no exception-masking concern exists for cleanup calls like `PdhCloseQuery` in `finally`.
Applied to files:
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java
📚 Learning: 2026-04-17T23:52:52.926Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java:47-58
Timestamp: 2026-04-17T23:52:52.926Z
Learning: In `oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java`, the `stopDaemon()` / `startDaemon()` lifecycle pattern (both `public synchronized` instance methods on the same monitor) is intentionally safe: `stopDaemon()` sets `loadAvgThread = null` immediately after `interrupt()`, and `startDaemon()` checks `loadAvgThread != null` under the same lock. Since both methods are synchronized on `this`, they cannot run concurrently, so no double-sampler race is possible. Do not flag this pattern as a race condition.
Applied to files:
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.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/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.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/software/common/os/windows/WindowsOSThread.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.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/WindowsOSThread.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java
📚 Learning: 2026-04-17T23:56:43.867Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java:287-298
Timestamp: 2026-04-17T23:56:43.867Z
Learning: In `oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java`, the `queryWildcardCounters` method intentionally aborts and returns an empty Pair when any `addEnglishCounter` call fails. This is by design: the returned `Pair<List<String>, Map<T, List<Long>>>` requires strict parallel alignment between the instance list and each per-property value list. Aborting on failure preserves this alignment contract. This is different from `queryCounters` (non-wildcard), which gracefully skips individual failed counters since it returns a flat `Map<T, Long>` with no alignment constraint.
Applied to files:
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.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/WindowsOSProcessJNA.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/main/java/oshi/software/common/os/windows/WindowsOSProcess.java
🔇 Additional comments (7)
oshi-core/src/main/java/oshi/driver/windows/registry/ProcessWtsData.java (1)
22-22: LGTM — clean import swap to the sharedWtsInfo.Constructor signature for the shared
oshi.driver.common.windows.registry.WtsInfomatches the previous nested type (same 7 args), so bothqueryProcessWtsMapFromWTSandqueryProcessWtsMapFromPerfMonconstruct it correctly.oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSThread.java (1)
22-46: LGTM — clean abstract-base extraction.The move to
oshi.software.common.os.windows, theprotectedconstructor, and theprotectedhookgetProcName()/updateAttributes(procName, pcb)match the JNA/FFM subclass pattern used elsewhere in this PR. All previous getters and state-mapping logic are preserved unchanged.oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java (1)
85-146: LGTM — subclass hooks wired correctly.
updateAttributes()correctly handles bothbuildProcessMapFromRegistryreturningnulland the subsequent perf-counter fallback, guardssetTcbbehindUSE_PROCSTATE_SUSPENDED, and null-checks both maps before delegating to the(pcb, wts)overload.createOSThreadandqueryMatchingThreadsmirror the FFM counterpart, preserving parity.oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java (1)
99-160: LGTM — FFM subclass hooks symmetric with the JNA version.
updateAttributes(),createOSThread, andqueryMatchingThreadstrack the JNA implementation 1:1 (registry-first with perf-counter fallback,USE_PROCSTATE_SUSPENDED-gatedsetTcb, null-safe delegation to the(pcb, wts)overload). Keeps JNA/FFM parity easy to audit.oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java (3)
36-91: LGTM — solid extraction of the Windows process common layer.A few things that stand out positively:
MAX_WINDOWS_HANDLESis now computed once in astaticblock here and used directly byget{Soft,Hard}OpenFileLimit(), eliminating the prior coupling toWindowsFileSystem.- Widening
osfromWindowsOperatingSystemtoOperatingSystemis fine — onlygetBitness()/getProcessId()are used, both on the interface — and keeps this class portable across JNA/FFM OS subclasses.- The constructor still eagerly invokes
updateAttributes(processMap.get(pid), processWtsMap.get(pid)), relying on the base overload that doesn't touch native handles — so subclasses'updateAttributes()no-arg override is only hit on explicit refresh, preserving constructor cost.
264-283: LGTM — clean abstract hook for thread creation.
getThreadDetails()now delegates per-thread instantiation tocreateOSThread(...), which is the right seam for the JNA/FFM split. The owning-process filter and parallel stream are preserved, so behavior is unchanged for callers.
362-384: LGTM — well-scoped subclass hooks.
setTcb,queryMatchingThreads, andqueryCommandLineare the minimal surface needed for the JNA/FFM subclasses to drive their native queries while the base handles the shared bookkeeping. Keeps the common class free of JNA/FFM-specific imports as intended by the refactor.
3d1eb6e to
c971cba
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java (1)
99-160:⚠️ Potential issue | 🟠 MajorMirror the
null || isEmpty()fix here too.Same concern as the JNA counterpart —
updateAttributes()at line 105 andqueryMatchingThreads()at line 156 only check== nullbefore falling back to perf-counters, whereasWindowsOperatingSystem.processMapToListusesnull || isEmpty(). Please apply the parallel fix so FFM and JNA refresh behavior stays in lock-step:🛠️ Parallel diff
- if (pcbMap == null) { + if (pcbMap == null || pcbMap.isEmpty()) { pcbMap = ProcessPerformanceDataFFM.buildProcessMapFromPerfCounters(pids); } @@ Map<Integer, ThreadPerfCounterBlock> threads = ThreadPerformanceDataFFM.buildThreadMapFromRegistry(pids); - if (threads == null) { + if (threads == null || threads.isEmpty()) { threads = ThreadPerformanceDataFFM.buildThreadMapFromPerfCounters(pids, this.getName(), -1); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java` around lines 99 - 160, The FFM implementation only checks for null before falling back to perf counters; update the null checks in updateAttributes() (use the ProcessPerformanceDataFFM.buildProcessMapFromRegistry result) and in queryMatchingThreads() (use ThreadPerformanceDataFFM.buildThreadMapFromRegistry result) to treat empty maps the same as null by testing for (map == null || map.isEmpty()) and only then call the PerfCounters fallback, ensuring parity with WindowsOperatingSystem.processMapToList.oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java (1)
85-146:⚠️ Potential issue | 🟠 MajorFallback condition differs from the batch path — consider matching
null || isEmpty().In
WindowsOperatingSystem.processMapToList(lines 302 and 311), the registry → perf-counter fallback fires onmap == null || map.isEmpty(). The per-process paths here only check== null:
- Line 91:
if (pcbMap == null)before falling back tobuildProcessMapFromPerfCounters(pids)- Line 142:
if (threads == null)before falling back tobuildThreadMapFromPerfCounters(pids, getName(), -1)Both
buildProcessMapFromRegistryandbuildThreadMapFromRegistrycan return empty (non-null) maps when the requested PID(s) are absent from the registry snapshot or when PERFDATA is disabled. If an empty map is returned, the per-processupdateAttributes()skips the WMI/perf-counter fallback, andsuper.updateAttributes(null, …)marks this processINVALIDon refresh — even though a fresh batch snapshot with the same WMI/perf-counter fallback would have recovered it.The same logic applies to
WindowsOSProcessFFM.queryMatchingThreads().🛠️ Suggested alignment with the batch path
`@Override` public boolean updateAttributes() { Set<Integer> pids = Collections.singleton(this.getProcessID()); // Get data from the registry if possible Map<Integer, ProcessPerfCounterBlock> pcbMap = ProcessPerformanceDataJNA.buildProcessMapFromRegistry(pids); // otherwise performance counters with WMI backup - if (pcbMap == null) { + if (pcbMap == null || pcbMap.isEmpty()) { pcbMap = ProcessPerformanceDataJNA.buildProcessMapFromPerfCounters(pids); } @@ `@Override` protected Map<Integer, ThreadPerfCounterBlock> queryMatchingThreads(Set<Integer> pids) { Map<Integer, ThreadPerfCounterBlock> threads = ThreadPerformanceDataJNA.buildThreadMapFromRegistry(pids); - if (threads == null) { + if (threads == null || threads.isEmpty()) { threads = ThreadPerformanceDataJNA.buildThreadMapFromPerfCounters(pids, this.getName(), -1); } return threads; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java` around lines 85 - 146, The fallback logic only checks for null, causing empty registry maps to skip perf-counter fallbacks; change the checks in WindowsOSProcessJNA.updateAttributes (where pcbMap is set via ProcessPerformanceDataJNA.buildProcessMapFromRegistry) and in queryMatchingThreads (where threads is set via ThreadPerformanceDataJNA.buildThreadMapFromRegistry) to treat empty maps the same as null (i.e., use map == null || map.isEmpty()) so you fall back to ProcessPerformanceDataJNA.buildProcessMapFromPerfCounters and ThreadPerformanceDataJNA.buildThreadMapFromPerfCounters respectively; apply the same null-or-empty check pattern to the analogous logic in WindowsOSProcessFFM.queryMatchingThreads.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java`:
- Around line 99-160: The FFM implementation only checks for null before falling
back to perf counters; update the null checks in updateAttributes() (use the
ProcessPerformanceDataFFM.buildProcessMapFromRegistry result) and in
queryMatchingThreads() (use ThreadPerformanceDataFFM.buildThreadMapFromRegistry
result) to treat empty maps the same as null by testing for (map == null ||
map.isEmpty()) and only then call the PerfCounters fallback, ensuring parity
with WindowsOperatingSystem.processMapToList.
In `@oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java`:
- Around line 85-146: The fallback logic only checks for null, causing empty
registry maps to skip perf-counter fallbacks; change the checks in
WindowsOSProcessJNA.updateAttributes (where pcbMap is set via
ProcessPerformanceDataJNA.buildProcessMapFromRegistry) and in
queryMatchingThreads (where threads is set via
ThreadPerformanceDataJNA.buildThreadMapFromRegistry) to treat empty maps the
same as null (i.e., use map == null || map.isEmpty()) so you fall back to
ProcessPerformanceDataJNA.buildProcessMapFromPerfCounters and
ThreadPerformanceDataJNA.buildThreadMapFromPerfCounters respectively; apply the
same null-or-empty check pattern to the analogous logic in
WindowsOSProcessFFM.queryMatchingThreads.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5156df4b-bc7e-4c28-bcad-35549711c61a
📒 Files selected for processing (16)
CHANGELOG.mdoshi-common/src/main/java/oshi/driver/common/windows/registry/WtsInfo.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSThread.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSThreadFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessWtsData.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsInstalledAppsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsNetworkParamsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSFileStoreJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSThreadJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.java
✅ Files skipped from review due to trivial changes (4)
- CHANGELOG.md
- oshi-core/src/main/java/oshi/software/os/windows/WindowsOSFileStoreJNA.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsNetworkParamsJNA.java
- oshi-common/src/main/java/oshi/driver/common/windows/registry/WtsInfo.java
🚧 Files skipped from review as they are similar to previous changes (7)
- oshi-core/src/main/java/oshi/software/os/windows/WindowsInstalledAppsJNA.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsOSThreadJNA.java
- oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSThreadFFM.java
- oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
- oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSThread.java
- oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.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). (6)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Analyze (java)
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Test JDK 11, macos-latest
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
🧰 Additional context used
🧠 Learnings (12)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3173
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java:107-193
Timestamp: 2026-04-18T22:53:49.248Z
Learning: In OSHI's `WmiQueryHandlerFFM` (oshi-core-java25) and the JNA `WmiQueryHandler` (oshi-core), the `failedWmiClassNames` cache intentionally keys failures by WMI class name only (not namespace). This is a pre-existing, accepted pattern shared between both implementations. Do not flag this as a bug in future reviews — the project maintainer (dbwiddis) confirmed it does not impact callers and the added complexity of a composite namespace+class key is not warranted.
📚 Learning: 2026-04-18T22:53:49.248Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3173
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java:107-193
Timestamp: 2026-04-18T22:53:49.248Z
Learning: In OSHI's `WmiQueryHandlerFFM` (oshi-core-java25) and the JNA `WmiQueryHandler` (oshi-core), the `failedWmiClassNames` cache intentionally keys failures by WMI class name only (not namespace). This is a pre-existing, accepted pattern shared between both implementations. Do not flag this as a bug in future reviews — the project maintainer (dbwiddis) confirmed it does not impact callers and the added complexity of a composite namespace+class key is not warranted.
Applied to files:
oshi-core/src/main/java/oshi/driver/windows/registry/ProcessWtsData.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.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/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
📚 Learning: 2026-04-08T00:58:10.736Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3125
File: oshi-core-java25/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java:131-133
Timestamp: 2026-04-08T00:58:10.736Z
Learning: In `oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceJNA.java` and `oshi-core-java25/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java`, the `getPowerSources()` method intentionally returns a singleton list wrapping a single `getPowerSource("System Battery")` call, and the enumeration loop short-circuits after the first eligible battery pack. This matches the longstanding JNA behavior and is not a bug. A broader refactor to support zero-or-more batteries across both implementations is planned for a later date. Do not flag this as an issue.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.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/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.java
📚 Learning: 2026-04-19T01:28:43.529Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3174
File: oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java:237-257
Timestamp: 2026-04-19T01:28:43.529Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`, the WMI comparison tests (e.g., `testProcessor`) intentionally validate only index 0 and a few representative fields per WMI data type (String, uint16, uint32, uint64). Exhaustive row-by-row comparison is deliberately avoided for numerically heavy multi-row tables. The design rationale is: matching row counts + a few selected fields covering each data type is sufficient to verify JNA vs FFM driver parity. Do not suggest looping over all rows for these tests.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java
📚 Learning: 2026-04-18T03:18:03.725Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:03.725Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java
📚 Learning: 2026-03-29T20:03:00.830Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java:87-89
Timestamp: 2026-03-29T20:03:00.830Z
Learning: In the OSHI FFM codebase (oshi-core-java25), all PDH/Kernel32/COM wrapper methods in classes like PdhFFM, Kernel32FFM, etc. declare `throws Throwable` solely as a compiler artifact of `MethodHandle.invokeExact`. They are native calls and do not throw Java checked exceptions in practice. The enclosing `getOpenFileDescriptors()` method in PdhUtilFFM already has an outer `catch (Throwable t)` that covers the entire method body including any `finally` blocks, so no exception-masking concern exists for cleanup calls like `PdhCloseQuery` in `finally`.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java
📚 Learning: 2026-04-17T23:52:52.926Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java:47-58
Timestamp: 2026-04-17T23:52:52.926Z
Learning: In `oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java`, the `stopDaemon()` / `startDaemon()` lifecycle pattern (both `public synchronized` instance methods on the same monitor) is intentionally safe: `stopDaemon()` sets `loadAvgThread = null` immediately after `interrupt()`, and `startDaemon()` checks `loadAvgThread != null` under the same lock. Since both methods are synchronized on `this`, they cannot run concurrently, so no double-sampler race is possible. Do not flag this pattern as a race condition.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
📚 Learning: 2026-04-17T23:56:43.867Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java:287-298
Timestamp: 2026-04-17T23:56:43.867Z
Learning: In `oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java`, the `queryWildcardCounters` method intentionally aborts and returns an empty Pair when any `addEnglishCounter` call fails. This is by design: the returned `Pair<List<String>, Map<T, List<Long>>>` requires strict parallel alignment between the instance list and each per-property value list. Aborting on failure preserves this alignment contract. This is different from `queryCounters` (non-wildcard), which gracefully skips individual failed counters since it returns a flat `Map<T, Long>` with no alignment constraint.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java
📚 Learning: 2026-04-17T23:43:33.461Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java:0-0
Timestamp: 2026-04-17T23:43:33.461Z
Learning: In `oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java`, the `PDH_RAW_COUNTER_LAYOUT` Java FFM struct layout must place `FirstValue` at byte offset 16 (not 12). The native MSVC compiler inserts 4 bytes of implicit alignment padding before the `LONGLONG FirstValue` field (after CStatus=4 bytes + FILETIME TimeStamp=8 bytes = 12 bytes), because LONGLONG requires 8-byte alignment. The total struct size is 40 bytes (with trailing padding). Do not use JAVA_LONG_UNALIGNED without explicit padding here, as that incorrectly places FirstValue at offset 12 and causes reads of garbage counter values.
Applied to files:
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.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/software/os/windows/WindowsOSProcessFFM.java
🔇 Additional comments (5)
oshi-core/src/main/java/oshi/driver/windows/registry/ProcessWtsData.java (1)
22-22: Clean swap to the sharedWtsInfo. 👋Nice extraction — the shared
oshi.driver.common.windows.registry.WtsInfohas an identical constructor and getter surface to the old nested class, so bothqueryProcessWtsMapFromWTSandqueryProcessWtsMapFromPerfMonkeep working unchanged. Welcome refactor.oshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.java (1)
52-52: Rename + brace reformat — LGTM.The class rename to
WindowsInternetProtocolStatsJNAand thestateLookupreformat (added braces/indentation) leave the TCP-state mappings and default identical. No behavior change.Also applies to: 219-247
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.java (1)
53-53: Factory/supplier swaps look consistent.All call sites (
installedAppsSupplier,getFileSystem,getInternetProtocolStats,getCurrentThreadfallback,getNetworkParams) now point at the new*JNAclasses, and each of those still extends the appropriate abstract base class (AbstractFileSystem,AbstractInternetProtocolStats,AbstractNetworkParams), so the return-type contracts are preserved. TheWtsInfoimport switch tooshi.driver.common.windows.registry.WtsInfoalso lines up with the updatedProcessWtsData.queryProcessWtsMapsignature.Also applies to: 120-120, 236-236, 241-241, 371-371, 446-446
oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java (1)
148-163:queryCommandLine()precedence reads cleanly — LGTM.Nice mirror of the existing Win32-process command-line logic: PEB-derived value first, cached batch lookup under
USE_BATCH_COMMANDLINE, WMI fallback with""when the result set is empty. No null-safety concerns onWmiUtil.getStringsincegetResultCount() > 0gates the access.oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java (1)
162-176: FFMqueryCommandLine()matches the JNA version — LGTM.Precedence (PEB → batch-cached → WMI →
"") is identical toWindowsOSProcessJNA.queryCommandLine, and thevarinferred type oncommandLineProcskeeps the FFM-specificWmiResulttype local.
c971cba to
60b9018
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java (1)
108-114: Minor:setTcbruns beforenameis populated on first refresh.When
USE_PROCSTATE_SUSPENDEDis set,setTcb(queryMatchingThreads(pids))executes on line 109 prior to the protectedupdateAttributes(pcb, wts)call on line 112 that populatesthis.name. The perf-counter fallback inqueryMatchingThreadsat line 157 readsthis.getName()with-1, so on the very first refresh of a freshly-constructed process where registry thread data is missing, the fallback will see an empty/stale name. The registry-first path is unaffected, and subsequent refreshes are fine — so the blast radius is narrow. Mentioning only because the JNA mirror has the same ordering and you may want to swap the order (or cachenamefrompcbMap.get(pid)first) in both if this corner matters.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java` around lines 108 - 114, The setTcb(queryMatchingThreads(pids)) call runs before updateAttributes(...) so queryMatchingThreads may call this.getName() before name is populated; to fix, populate/cache the process name first from pcbMap.get(this.getProcessID()) (or call updateAttributes(...) for name) before invoking setTcb, i.e., retrieve pcb = pcbMap == null ? null : pcbMap.get(this.getProcessID()) (or extract pcb.processName) and ensure that name is set/cached prior to calling setTcb(queryMatchingThreads(pids)); alternatively simply swap the order to call updateAttributes(pcb, wts) or at least set the name field from pcb before calling setTcb to avoid the stale-name perf-counter fallback in queryMatchingThreads.
🤖 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-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java`:
- Around line 108-114: The setTcb(queryMatchingThreads(pids)) call runs before
updateAttributes(...) so queryMatchingThreads may call this.getName() before
name is populated; to fix, populate/cache the process name first from
pcbMap.get(this.getProcessID()) (or call updateAttributes(...) for name) before
invoking setTcb, i.e., retrieve pcb = pcbMap == null ? null :
pcbMap.get(this.getProcessID()) (or extract pcb.processName) and ensure that
name is set/cached prior to calling setTcb(queryMatchingThreads(pids));
alternatively simply swap the order to call updateAttributes(pcb, wts) or at
least set the name field from pcb before calling setTcb to avoid the stale-name
perf-counter fallback in queryMatchingThreads.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0fb98c58-d5e4-4849-b7d1-aacbf6143014
📒 Files selected for processing (16)
CHANGELOG.mdoshi-common/src/main/java/oshi/driver/common/windows/registry/WtsInfo.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSThread.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSThreadFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessWtsData.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsInstalledAppsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsNetworkParamsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSFileStoreJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSThreadJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.java
✅ Files skipped from review due to trivial changes (4)
- oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
- oshi-common/src/main/java/oshi/driver/common/windows/registry/WtsInfo.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsInstalledAppsJNA.java
- CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (8)
- oshi-core/src/main/java/oshi/software/os/windows/WindowsOSFileStoreJNA.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsOSThreadJNA.java
- oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
- oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSThreadFFM.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsNetworkParamsJNA.java
- oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSThread.java
- oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.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). (5)
- 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: Analyze (java)
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
🧰 Additional context used
🧠 Learnings (11)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3173
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java:107-193
Timestamp: 2026-04-18T22:53:49.248Z
Learning: In OSHI's `WmiQueryHandlerFFM` (oshi-core-java25) and the JNA `WmiQueryHandler` (oshi-core), the `failedWmiClassNames` cache intentionally keys failures by WMI class name only (not namespace). This is a pre-existing, accepted pattern shared between both implementations. Do not flag this as a bug in future reviews — the project maintainer (dbwiddis) confirmed it does not impact callers and the added complexity of a composite namespace+class key is not warranted.
📚 Learning: 2026-04-19T01:28:43.529Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3174
File: oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java:237-257
Timestamp: 2026-04-19T01:28:43.529Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`, the WMI comparison tests (e.g., `testProcessor`) intentionally validate only index 0 and a few representative fields per WMI data type (String, uint16, uint32, uint64). Exhaustive row-by-row comparison is deliberately avoided for numerically heavy multi-row tables. The design rationale is: matching row counts + a few selected fields covering each data type is sufficient to verify JNA vs FFM driver parity. Do not suggest looping over all rows for these tests.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
📚 Learning: 2026-04-18T22:53:49.248Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3173
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java:107-193
Timestamp: 2026-04-18T22:53:49.248Z
Learning: In OSHI's `WmiQueryHandlerFFM` (oshi-core-java25) and the JNA `WmiQueryHandler` (oshi-core), the `failedWmiClassNames` cache intentionally keys failures by WMI class name only (not namespace). This is a pre-existing, accepted pattern shared between both implementations. Do not flag this as a bug in future reviews — the project maintainer (dbwiddis) confirmed it does not impact callers and the added complexity of a composite namespace+class key is not warranted.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessWtsData.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
📚 Learning: 2026-04-18T03:18:03.725Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:03.725Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.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/src/main/java/oshi/software/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/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
📚 Learning: 2026-04-17T23:43:33.461Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java:0-0
Timestamp: 2026-04-17T23:43:33.461Z
Learning: In `oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java`, the `PDH_RAW_COUNTER_LAYOUT` Java FFM struct layout must place `FirstValue` at byte offset 16 (not 12). The native MSVC compiler inserts 4 bytes of implicit alignment padding before the `LONGLONG FirstValue` field (after CStatus=4 bytes + FILETIME TimeStamp=8 bytes = 12 bytes), because LONGLONG requires 8-byte alignment. The total struct size is 40 bytes (with trailing padding). Do not use JAVA_LONG_UNALIGNED without explicit padding here, as that incorrectly places FirstValue at offset 12 and causes reads of garbage counter values.
Applied to files:
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java
📚 Learning: 2026-04-17T23:56:43.867Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java:287-298
Timestamp: 2026-04-17T23:56:43.867Z
Learning: In `oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java`, the `queryWildcardCounters` method intentionally aborts and returns an empty Pair when any `addEnglishCounter` call fails. This is by design: the returned `Pair<List<String>, Map<T, List<Long>>>` requires strict parallel alignment between the instance list and each per-property value list. Aborting on failure preserves this alignment contract. This is different from `queryCounters` (non-wildcard), which gracefully skips individual failed counters since it returns a flat `Map<T, Long>` with no alignment constraint.
Applied to files:
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
📚 Learning: 2026-03-29T20:03:00.830Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java:87-89
Timestamp: 2026-03-29T20:03:00.830Z
Learning: In the OSHI FFM codebase (oshi-core-java25), all PDH/Kernel32/COM wrapper methods in classes like PdhFFM, Kernel32FFM, etc. declare `throws Throwable` solely as a compiler artifact of `MethodHandle.invokeExact`. They are native calls and do not throw Java checked exceptions in practice. The enclosing `getOpenFileDescriptors()` method in PdhUtilFFM already has an outer `catch (Throwable t)` that covers the entire method body including any `finally` blocks, so no exception-masking concern exists for cleanup calls like `PdhCloseQuery` in `finally`.
Applied to files:
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.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/software/os/windows/WindowsOSProcessFFM.java
📚 Learning: 2026-04-17T23:52:52.926Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java:47-58
Timestamp: 2026-04-17T23:52:52.926Z
Learning: In `oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java`, the `stopDaemon()` / `startDaemon()` lifecycle pattern (both `public synchronized` instance methods on the same monitor) is intentionally safe: `stopDaemon()` sets `loadAvgThread = null` immediately after `interrupt()`, and `startDaemon()` checks `loadAvgThread != null` under the same lock. Since both methods are synchronized on `this`, they cannot run concurrently, so no double-sampler race is possible. Do not flag this pattern as a race condition.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
🔇 Additional comments (4)
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.java (1)
53-446: *LGTM — clean swap to JNA types and sharedWtsInfo.The memoizer target (
WindowsInstalledAppsJNA::queryInstalledApps), the three factory methods (getFileSystem,getInternetProtocolStats,getNetworkParams), thegetCurrentThread()fallback (WindowsOSThreadJNA), and the sharedoshi.driver.common.windows.registry.WtsInfoimport all line up with the new constructor signatures and the common-package type. Nothing functionally changes here beyond the class-name migration.oshi-core/src/main/java/oshi/driver/windows/registry/ProcessWtsData.java (1)
22-101: LGTM — migration to sharedWtsInfopreserves behavior.Both the WTS (lines 74-77) and WMI/PerfMon (lines 93-101) construction sites align with the new
oshi.driver.common.windows.registry.WtsInfo7-arg constructor ordering(name, path, threadCount, virtualSize, kernelTime, userTime, openFiles). The deletion of the nested immutable class and its@Immutableimport are consistent with the common type taking over.oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java (1)
99-176: LGTM — overrides plug cleanly into the new commonWindowsOSProcesshooks.
updateAttributes(),createOSThread(...),queryMatchingThreads(...), andqueryCommandLine()all have signatures matching the abstract declarations in the common parent, and the registry→perf-counter fallbacks plus the cwd/batch/WMI precedence inqueryCommandLine()mirror the prior concrete logic. Null handling onpcbMap.get(pid)/wts.get(pid)is safely absorbed by the protectedupdateAttributes(pcb, wts)in the parent.oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java (1)
85-163: LGTM — JNA overrides mirror the FFM side faithfully.The four new overrides (
updateAttributes(),createOSThread,queryMatchingThreads,queryCommandLine) match the abstract hooks on the commonWindowsOSProcessand reproduce the registry→perf-counter and cwd→batch→WMI fallback chains consistently withWindowsOSProcessFFM. The import trim/additions look right and the sharedWtsInfoflows through unchanged. The samesetTcb-before-name ordering observation noted on the FFM file applies here too — no need to repeat the comment.
60b9018 to
f1d3386
Compare
There was a problem hiding this comment.
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/software/common/os/windows/WindowsOSProcess.java (1)
263-271:⚠️ Potential issue | 🟡 MinorNormalize missing thread data before streaming.
queryMatchingThreads(...)is an abstract native-data hook and the JNA/FFM implementations can propagate an unavailable helper result. If it returnsnull,getThreadDetails()throws instead of returning an empty thread list.🛡️ Proposed null-safe fallback
public List<OSThread> getThreadDetails() { Map<Integer, ThreadPerfCounterBlock> threads = tcb == null ? queryMatchingThreads(Collections.singleton(this.getProcessID())) : tcb; + if (threads == null || threads.isEmpty()) { + return Collections.emptyList(); + } return threads.entrySet().stream().parallel() .filter(entry -> entry.getValue().getOwningProcessID() == this.getProcessID()) .map(entry -> createOSThread(getProcessID(), entry.getKey(), this.name, entry.getValue()))🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java` around lines 263 - 271, getThreadDetails currently assumes queryMatchingThreads (the native-data hook) returns a non-null Map and will NPE if it returns null; update getThreadDetails so that when tcb is null and queryMatchingThreads(...) returns null you treat it as an empty Map (or emptyCollection) before streaming. Concretely, in getThreadDetails check the result of queryMatchingThreads(Collections.singleton(this.getProcessID())) and replace null with Collections.emptyMap() (or an empty Map local variable), then proceed to filter/map using that safe Map (references: getThreadDetails, tcb, queryMatchingThreads, ThreadPerfCounterBlock, createOSThread).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In
`@oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java`:
- Around line 263-271: getThreadDetails currently assumes queryMatchingThreads
(the native-data hook) returns a non-null Map and will NPE if it returns null;
update getThreadDetails so that when tcb is null and queryMatchingThreads(...)
returns null you treat it as an empty Map (or emptyCollection) before streaming.
Concretely, in getThreadDetails check the result of
queryMatchingThreads(Collections.singleton(this.getProcessID())) and replace
null with Collections.emptyMap() (or an empty Map local variable), then proceed
to filter/map using that safe Map (references: getThreadDetails, tcb,
queryMatchingThreads, ThreadPerfCounterBlock, createOSThread).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4f76109e-bf4f-44ee-844f-267223944078
📒 Files selected for processing (16)
CHANGELOG.mdoshi-common/src/main/java/oshi/driver/common/windows/registry/WtsInfo.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSThread.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSThreadFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessWtsData.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsInstalledAppsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsNetworkParamsJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSFileStoreJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSThreadJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.java
✅ Files skipped from review due to trivial changes (3)
- CHANGELOG.md
- oshi-common/src/main/java/oshi/driver/common/windows/registry/WtsInfo.java
- oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSThread.java
🚧 Files skipped from review as they are similar to previous changes (8)
- oshi-core/src/main/java/oshi/software/os/windows/WindowsOSFileStoreJNA.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsInstalledAppsJNA.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsNetworkParamsJNA.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
- oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsOSThreadJNA.java
- oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSThreadFFM.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). (8)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 11, windows-latest
- GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (14)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3173
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java:107-193
Timestamp: 2026-04-18T22:53:49.248Z
Learning: In OSHI's `WmiQueryHandlerFFM` (oshi-core-java25) and the JNA `WmiQueryHandler` (oshi-core), the `failedWmiClassNames` cache intentionally keys failures by WMI class name only (not namespace). This is a pre-existing, accepted pattern shared between both implementations. Do not flag this as a bug in future reviews — the project maintainer (dbwiddis) confirmed it does not impact callers and the added complexity of a composite namespace+class key is not warranted.
📚 Learning: 2026-04-08T00:58:10.736Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3125
File: oshi-core-java25/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java:131-133
Timestamp: 2026-04-08T00:58:10.736Z
Learning: In `oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceJNA.java` and `oshi-core-java25/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java`, the `getPowerSources()` method intentionally returns a singleton list wrapping a single `getPowerSource("System Battery")` call, and the enumeration loop short-circuits after the first eligible battery pack. This matches the longstanding JNA behavior and is not a bug. A broader refactor to support zero-or-more batteries across both implementations is planned for a later date. Do not flag this as an issue.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.java
📚 Learning: 2026-04-19T01:28:43.529Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3174
File: oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java:237-257
Timestamp: 2026-04-19T01:28:43.529Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`, the WMI comparison tests (e.g., `testProcessor`) intentionally validate only index 0 and a few representative fields per WMI data type (String, uint16, uint32, uint64). Exhaustive row-by-row comparison is deliberately avoided for numerically heavy multi-row tables. The design rationale is: matching row counts + a few selected fields covering each data type is sufficient to verify JNA vs FFM driver parity. Do not suggest looping over all rows for these tests.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java
📚 Learning: 2026-04-18T22:53:49.248Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3173
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java:107-193
Timestamp: 2026-04-18T22:53:49.248Z
Learning: In OSHI's `WmiQueryHandlerFFM` (oshi-core-java25) and the JNA `WmiQueryHandler` (oshi-core), the `failedWmiClassNames` cache intentionally keys failures by WMI class name only (not namespace). This is a pre-existing, accepted pattern shared between both implementations. Do not flag this as a bug in future reviews — the project maintainer (dbwiddis) confirmed it does not impact callers and the added complexity of a composite namespace+class key is not warranted.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessWtsData.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java
📚 Learning: 2026-04-18T03:18:03.725Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:03.725Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.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/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.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/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
📚 Learning: 2026-03-29T20:03:00.830Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java:87-89
Timestamp: 2026-03-29T20:03:00.830Z
Learning: In the OSHI FFM codebase (oshi-core-java25), all PDH/Kernel32/COM wrapper methods in classes like PdhFFM, Kernel32FFM, etc. declare `throws Throwable` solely as a compiler artifact of `MethodHandle.invokeExact`. They are native calls and do not throw Java checked exceptions in practice. The enclosing `getOpenFileDescriptors()` method in PdhUtilFFM already has an outer `catch (Throwable t)` that covers the entire method body including any `finally` blocks, so no exception-masking concern exists for cleanup calls like `PdhCloseQuery` in `finally`.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java
📚 Learning: 2026-04-17T23:52:52.926Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java:47-58
Timestamp: 2026-04-17T23:52:52.926Z
Learning: In `oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java`, the `stopDaemon()` / `startDaemon()` lifecycle pattern (both `public synchronized` instance methods on the same monitor) is intentionally safe: `stopDaemon()` sets `loadAvgThread = null` immediately after `interrupt()`, and `startDaemon()` checks `loadAvgThread != null` under the same lock. Since both methods are synchronized on `this`, they cannot run concurrently, so no double-sampler race is possible. Do not flag this pattern as a race condition.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
📚 Learning: 2026-04-17T23:56:43.867Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java:287-298
Timestamp: 2026-04-17T23:56:43.867Z
Learning: In `oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java`, the `queryWildcardCounters` method intentionally aborts and returns an empty Pair when any `addEnglishCounter` call fails. This is by design: the returned `Pair<List<String>, Map<T, List<Long>>>` requires strict parallel alignment between the instance list and each per-property value list. Aborting on failure preserves this alignment contract. This is different from `queryCounters` (non-wildcard), which gracefully skips individual failed counters since it returns a flat `Map<T, Long>` with no alignment constraint.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.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/main/java/oshi/software/common/os/windows/WindowsOSProcess.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/WindowsOSProcess.java
📚 Learning: 2026-04-17T23:43:33.461Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java:0-0
Timestamp: 2026-04-17T23:43:33.461Z
Learning: In `oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java`, the `PDH_RAW_COUNTER_LAYOUT` Java FFM struct layout must place `FirstValue` at byte offset 16 (not 12). The native MSVC compiler inserts 4 bytes of implicit alignment padding before the `LONGLONG FirstValue` field (after CStatus=4 bytes + FILETIME TimeStamp=8 bytes = 12 bytes), because LONGLONG requires 8-byte alignment. The total struct size is 40 bytes (with trailing padding). Do not use JAVA_LONG_UNALIGNED without explicit padding here, as that incorrectly places FirstValue at offset 12 and causes reads of garbage counter values.
Applied to files:
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.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/software/os/windows/WindowsOSProcessFFM.java
🔇 Additional comments (8)
oshi-core/src/main/java/oshi/driver/windows/registry/ProcessWtsData.java (1)
21-23: SharedWtsInfowiring looks good.The JNA WTS query now depends on the common immutable holder, and the constructor/accessor shape matches the existing call sites.
oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java (1)
274-393: Good common/JNA/FFM extension seam.The thread factory, matching-thread query, and command-line query hooks keep native-specific work out of the shared process base while preserving the common getters/update flow.
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.java (2)
119-120: JNA class renames are wired consistently.Installed apps, file system, IP stats, and network params now point at their JNA-specific implementations as expected.
Also applies to: 235-241, 444-446
317-326: Process/thread construction now uses the JNA implementations.The shared
WtsInfomap feedsWindowsOSProcessJNA, and the current-thread fallback correctly instantiatesWindowsOSThreadJNA.Also applies to: 367-371
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java (2)
152-180: FFM hook implementations align with the common base.Thread creation, matching-thread lookup, and command-line precedence are implemented through the new abstract hooks without duplicating the shared process getters.
99-118: The publicupdateAttributes()implementation follows a valid pattern for Windows process queries. Unlike hardware-level FFM operations that manage native resources (like MacHWDiskStoreFFM's CFStringRef/DASessionRef cleanup), the process data helpers (ProcessPerformanceDataFFM.buildProcessMapFromRegistry/buildProcessMapFromPerfCounters,ProcessWtsData.queryProcessWtsMap) gracefully handle errors internally by returning null or empty Maps rather than throwing. This design is consistent with the JNA implementation (WindowsOSProcessJNA.updateAttributes()) and relies on the protectedupdateAttributes(pcb, wts)to determine final success/failure. No wrapper try-catch is needed here.> Likely an incorrect or invalid review comment.oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java (2)
85-104: JNA attribute refresh follows the new common flow.The registry-first/perf-counter fallback path now feeds the shared
updateAttributes(pcb, wts)implementation and refreshes thread data only when suspended-state detection is enabled.
138-167: JNA-specific hooks are cleanly isolated.The thread factory, matching-thread query, and command-line query supply the platform details expected by the common base.
- Rename WindowsFileSystem, WindowsInstalledApps, WindowsInternetProtocolStats, WindowsNetworkParams to *JNA suffix in oshi-core - Extract WindowsOSThread common superclass to oshi-common with shared fields, getters, and state mapping logic; create WindowsOSThreadJNA and WindowsOSThreadFFM - Extract WindowsOSProcess common superclass to oshi-common with shared fields, getters, and update logic; make native-dependent methods abstract - Extract WtsInfo from ProcessWtsData inner class to standalone class in oshi-common - Rewrite WindowsOSProcessJNA and WindowsOSProcessFFM to extend common superclass - Add getCurrentThread() override to WindowsOperatingSystemFFM
f1d3386 to
1bab2e4
Compare
Summary
Migrates the remaining Windows software OS classes (OSThread, OSProcess, and supporting classes) to the three-tier common/JNA/FFM architecture pattern.
Changes
oshi-common (new/modified)
oshi-core (new/modified)
oshi-core-java25 (new/modified)
getCurrentThread()override to WindowsOperatingSystemFFMSmoke Test
Removing the
build-helper-maven-pluginsource copy from oshi-core-java25 now leaves only 5 remaining dependencies on oshi-core:WindowsOperatingSystem— FFM extends it (needs common superclass extraction)ProcessWtsData— JNA-dependent registry readerPlatformEnum(deprecated) — can switch tooshi.util.PlatformEnumoshi.driver.mac.disk.Fsstat— JNA-basedoshi.driver.mac.net.NetStat— JNA-basedTesting
Summary by CodeRabbit
Refactor
New Features