Repository navigation
Add PerfCounterWildcardQueryFFM with PdhEnumObjectItems FFM binding; refactor LoadAverage - #3168
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (20)
✅ Files skipped from review due to trivial changes (9)
🚧 Files skipped from review as they are similar to previous changes (7)
📜 Recent 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)
🧰 Additional context used🧠 Learnings (10)📓 Common learnings📚 Learning: 2026-04-17T23:52:52.926ZApplied to files:
📚 Learning: 2026-04-10T22:44:36.786ZApplied to files:
📚 Learning: 2026-04-12T19:34:59.050ZApplied to files:
📚 Learning: 2026-04-11T05:51:52.684ZApplied to files:
📚 Learning: 2026-04-17T23:43:33.461ZApplied to files:
📚 Learning: 2026-04-12T19:22:09.716ZApplied to files:
📚 Learning: 2026-04-17T23:56:43.867ZApplied to files:
📚 Learning: 2026-03-29T20:03:00.830ZApplied to files:
📚 Learning: 2026-04-03T02:07:47.621ZApplied to files:
🔇 Additional comments (11)
📝 WalkthroughWalkthroughMoves LoadAverage to a common abstract instance-based class and adds JNA/FFM concrete implementations; replaces formatted PDH reads with raw reads; adds PDH wildcard enumeration with PDH→WMI fallback and failure cache; introduces multiple FFM perfmon wrappers and REG_MULTI_SZ registry support; updates tests and bindings. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as PerfCounterWildcardQueryFFM
participant Cache as FAILED_PDH_CACHE
participant PDH as PerfDataUtilFFM (PDH)
participant WMI as WmiQueryHandlerFFM
Client->>Cache: is perfObject cached?
alt cached (PDH known to fail)
Client->>WMI: queryInstancesAndValuesFromWMI(...)
WMI-->>Client: (instances, values)
else not cached
Client->>PDH: queryInstancesAndValuesFromPDH(...)
PDH->>PDH: PdhEnumObjectItemsW -> build query -> PdhCollectQueryData
PDH-->>Client: (instances, values)
alt instances empty
Client->>Cache: mark perfObject failed
Client->>WMI: queryInstancesAndValuesFromWMI(...)
WMI-->>Client: (instances, values)
end
end
Client-->>Client: return (instances, values)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 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🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3168 +/- ##
==========================================
+ Coverage 58.02% 58.12% +0.09%
==========================================
Files 326 333 +7
Lines 17417 17652 +235
Branches 3072 3121 +49
==========================================
+ Hits 10107 10261 +154
- Misses 5820 5871 +51
- Partials 1490 1520 +30
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.
Actionable comments posted: 6
🧹 Nitpick comments (1)
oshi-core/src/main/java/oshi/driver/windows/perfmon/LoadAverageJNA.java (1)
37-47: Guard counter lists before indexing them.If the wildcard query returns instances but a missing or shorter value list, this loop can throw and stop load-average sampling. Returning
(0, 0)matches the existing “no data” fallback behavior.Proposed defensive guard
List<Long> proctimeTicks = valueMap.get(IdleProcessorTimeProperty.PERCENTPROCESSORTIME); List<Long> proctimeBase = valueMap.get(IdleProcessorTimeProperty.ELAPSEDTIME); + if (proctimeTicks == null || proctimeBase == null || proctimeTicks.size() < instances.size() + || proctimeBase.size() < instances.size()) { + return new Pair<>(0L, 0L); + } long nonIdleTicks = 0L; long nonIdleBase = 0L;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-core/src/main/java/oshi/driver/windows/perfmon/LoadAverageJNA.java` around lines 37 - 47, The loop in LoadAverageJNA that iterates over instances reads proctimeTicks.get(i) and proctimeBase.get(i) without ensuring those lists are non-null and long enough; add defensive guards: check that valueMap contains IdleProcessorTimeProperty.PERCENTPROCESSORTIME and ELAPSEDTIME and that proctimeTicks and proctimeBase are non-null and have size > i before indexing inside the for loop over instances; if either list is missing or too short, bail out and return the existing “no data” fallback (0, 0) to avoid throwing an IndexOutOfBoundsException.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/ProcessInformationFFM.java`:
- Around line 40-44: The JavaDoc on the method in ProcessInformationFFM that
"Returns cooked idle process performance counters" is incorrect—update the
summary and `@return` to state these are raw idle process counters (e.g., change
"cooked" to "raw" and reword to "Returns raw idle process performance counters"
and "@return Raw performance counters for idle process.") to accurately reflect
that the method returns raw values.
In `@oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java`:
- Around line 54-57: PDH_RAW_COUNTER_LAYOUT is misaligned (extra padding after
CStatus) and treats TimeStamp incorrectly; remove the explicit
MemoryLayout.paddingLayout(4) after CStatus, represent the FILETIME TimeStamp as
the two DWORDs rather than a single aligned JAVA_LONG, and mark non‑standard
aligned wide fields as unaligned; specifically update PDH_RAW_COUNTER_LAYOUT so
CStatus remains JAVA_INT.withName("CStatus"), TimeStamp is two DWORDs (e.g., two
JAVA_INT_UNALIGNED fields or a single JAVA_LONG_UNALIGNED named "TimeStamp"),
FirstValue and SecondValue use
ValueLayout.JAVA_LONG_UNALIGNED.withName("FirstValue"/"SecondValue"), and
MultiCount uses JAVA_INT_UNALIGNED.withName("MultiCount") to match native
offsets 0x00,0x04,0x0C,0x14,0x1C.
In
`@oshi-core-java25/src/main/java/oshi/util/platform/windows/Advapi32UtilFFM.java`:
- Around line 219-237: The call to RegQueryValueEx (in Advapi32UtilFFM.java)
treats ERROR_INSUFFICIENT_BUFFER as the only undersized-buffer return, but
RegQueryValueExW can return ERROR_MORE_DATA (234); add ERROR_MORE_DATA = 234 to
WinErrorFFM.java, import/use it in Advapi32UtilFFM.java, and change the second
RegQueryValueEx result handling to treat ERROR_MORE_DATA like
ERROR_INSUFFICIENT_BUFFER (i.e., retry with a resized buffer or fail
immediately) by checking for ERROR_MORE_DATA when deciding to reallocate or
throw, and use lpcbData to drive the correct new allocation size before the
retry.
In
`@oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java`:
- Around line 146-149: readRawCounterValue currently returns FirstValue without
validating the PDH_RAW_COUNTER.CStatus field; update it to read the CStatus from
the allocated PDH_RAW_COUNTER_LAYOUT MemorySegment (using the RAW_CSTATUS
offset) after PdhGetRawCounterValue succeeds and only return FirstValue when
CStatus equals PDH_CSTATUS_VALID_DATA (0) or PDH_CSTATUS_NEW_DATA (1); if
CStatus is any other value, throw or propagate an exception (or return a
sentinel) to avoid returning stale/invalid data. Add the two constants
PDH_CSTATUS_VALID_DATA and PDH_CSTATUS_NEW_DATA in PdhFFM and reference them in
readRawCounterValue, and use the existing PDH_RAW_COUNTER_LAYOUT,
RAW_FIRST_VALUE_OFFSET and the corresponding RAW_CSTATUS offset to locate the
fields.
In
`@oshi-core-java25/src/test/java/oshi/driver/windows/perfmon/LoadAverageFFMTest.java`:
- Around line 27-33: The test currently starts the shared LoadAverageFFM daemon
with loadAvg.startDaemon() and may skip loadAvg.stopDaemon() if an assertion
fails; wrap the test body that calls startDaemon(), Util.sleep(...),
queryLoadAverage(...), and the assertions in a try block and call
loadAvg.stopDaemon() in a finally block so the LoadAverageFFM singleton is
always stopped; reference the LoadAverageFFM instance (loadAvg), its
startDaemon() and stopDaemon() methods and the queryLoadAverage(...) call when
making the change.
In `@oshi-core/src/test/java/oshi/driver/windows/perfmon/LoadAverageTest.java`:
- Around line 27-33: The test starts a shared daemon via loadAvg.startDaemon()
but only calls loadAvg.stopDaemon() after assertions, so the daemon may remain
running if an assertion fails; wrap the work after startDaemon in a try/finally
(e.g., after calling loadAvg.startDaemon(), run Util.sleep(...) and
loadAvg.queryLoadAverage(...) and the assertions inside try { ... } finally {
loadAvg.stopDaemon(); }) to ensure loadAvg.stopDaemon() always executes;
reference the LoadAverageTest test harness and the loadAvg.startDaemon(),
loadAvg.queryLoadAverage(...), and loadAvg.stopDaemon() methods when making the
change.
---
Nitpick comments:
In `@oshi-core/src/main/java/oshi/driver/windows/perfmon/LoadAverageJNA.java`:
- Around line 37-47: The loop in LoadAverageJNA that iterates over instances
reads proctimeTicks.get(i) and proctimeBase.get(i) without ensuring those lists
are non-null and long enough; add defensive guards: check that valueMap contains
IdleProcessorTimeProperty.PERCENTPROCESSORTIME and ELAPSEDTIME and that
proctimeTicks and proctimeBase are non-null and have size > i before indexing
inside the for loop over instances; if either list is missing or too short, bail
out and return the existing “no data” fallback (0, 0) to avoid throwing an
IndexOutOfBoundsException.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5a0a4732-bfee-4266-a199-ccfebda04dd8
📒 Files selected for processing (18)
CHANGELOG.mdoshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/LoadAverageFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/MemoryInformationFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/PagingFileFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/ProcessInformationFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/ProcessorInformationFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/SystemInformationFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/WinNTFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/Advapi32UtilFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/PerfCounterWildcardQueryFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.javaoshi-core-java25/src/test/java/module-info.testoshi-core-java25/src/test/java/oshi/driver/windows/perfmon/LoadAverageFFMTest.javaoshi-core/src/main/java/oshi/driver/windows/perfmon/LoadAverageJNA.javaoshi-core/src/main/java/oshi/hardware/platform/windows/WindowsCentralProcessor.javaoshi-core/src/test/java/oshi/driver/windows/perfmon/LoadAverageTest.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 21, macos-latest
- GitHub Check: Test JDK 11, macos-latest
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 11, windows-latest
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (8)
📚 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/ffm/windows/WinNTFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/PagingFileFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/MemoryInformationFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/ProcessInformationFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/SystemInformationFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/ProcessorInformationFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/LoadAverageFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/Advapi32UtilFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/PerfCounterWildcardQueryFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java
📚 Learning: 2026-03-29T20:01:06.452Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java11/src/main/java/module-info.java:10-17
Timestamp: 2026-03-29T20:01:06.452Z
Learning: In the oshi project, `oshi-core-java25/src/main/java/module-info.java` intentionally does NOT export `oshi.util.platform.unix.freebsd`, `oshi.util.platform.unix.openbsd`, or `oshi.util.platform.unix.solaris`, because the FFM (Foreign Function & Memory) implementation only supports Windows, macOS, and Linux. This differs from `oshi-core-java11/src/main/java/module-info.java` which exports all Unix platform packages. The asymmetry is by design.
Applied to files:
oshi-core-java25/src/test/java/module-info.testoshi-core-java25/src/main/java/oshi/util/platform/windows/Advapi32UtilFFM.java
📚 Learning: 2026-04-06T04:45:51.516Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:51.516Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.
Applied to files:
oshi-core-java25/src/test/java/module-info.testoshi-core-java25/src/main/java/oshi/util/platform/windows/Advapi32UtilFFM.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/test/java/module-info.testoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/SystemInformationFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/ProcessorInformationFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/PerfCounterWildcardQueryFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java
📚 Learning: 2026-04-10T22:44:36.786Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3136
File: oshi-core-java25/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java:46-53
Timestamp: 2026-04-10T22:44:36.786Z
Learning: In OSHI's `AuxvFFM.queryAuxv()` (oshi-core-java25/src/main/java/oshi/driver/linux/proc/AuxvFFM.java), the do-while loop is safe even when `/proc/self/auxv` cannot be read: `FileUtil.readAllBytesAsBuffer` returns an empty ByteBuffer on failure, and `FileUtil.readLongFromBuffer`/`readIntFromBuffer` return 0L when reading past the buffer limit. This 0L equals AT_NULL, causing the loop to exit immediately with an empty map, which triggers the `getconf`/hardcoded-default fallback in callers like `LinuxOperatingSystemFFM`. Do not flag this do-while loop or the static initializer that calls `AuxvFFM.queryAuxv()` as unsafe.
Applied to files:
oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/SystemInformationFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/ProcessorInformationFFM.java
📚 Learning: 2026-04-12T19:34:59.050Z
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:34:59.050Z
Learning: The counterintuitive naming of `PhysicalProcessor.getEfficiency()` / `EfficiencyClass` in OSHI (where a higher value means MORE performance and LESS efficiency, so P-cores get higher values than E-cores) is intentionally inherited from Microsoft's `PROCESSOR_RELATIONSHIP.EfficiencyClass` Win32 API: "A core with a higher value for the efficiency class has intrinsically greater performance and less efficiency." OSHI follows this same convention for cross-platform consistency. Do not flag P-cores being assigned higher efficiency values as a bug.
Applied to files:
oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/ProcessorInformationFFM.javaoshi-core/src/main/java/oshi/hardware/platform/windows/WindowsCentralProcessor.java
📚 Learning: 2026-04-06T04:45:47.644Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:47.644Z
Learning: In the oshi/oshi project, only interfaces and classes in the root packages `oshi`, `oshi.hardware`, and `oshi.software.os` are considered the public API. Code in subpackages that represent specific implementations/platforms (e.g., `oshi.software.os.linux`, `oshi.hardware.platform.linux`, and similar subpackages) is implementation detail. When reviewing, do not treat changes to classes in these platform-specific subpackages as public API breaks (for example: making `LinuxOperatingSystem` abstract, narrowing constructor visibility, or adding/removing abstract methods should not be flagged as breaking public API).
Applied to files:
oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsCentralProcessor.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/perfmon/LoadAverage.java
🔇 Additional comments (15)
CHANGELOG.md (1)
33-33: Looks good — changelog entry is clear and scoped appropriately.This accurately captures the wildcard PDH/FFM addition and the LoadAverage refactor in the same style as surrounding entries.
oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/MemoryInformationFFM.java (1)
16-32: LGTM — clean FFM perfmon utility wrapper.The class is stateless, the private constructor/final utility pattern is appropriate, and
queryPageSwaps()matches thePerfCounterQueryFFM.queryValues(...)contract shown in the related context.oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/PagingFileFFM.java (1)
30-33: LGTM — consistent FFM perf counter wrapper.
querySwapUsed()uses the sharedPerfCounterQueryFFM.queryValues(...)contract correctly with the paging-file enum, PDH object, and WMI fallback class.oshi-core-java25/src/test/java/module-info.test (1)
13-14: LGTM!Opening the new Windows perfmon package for JUnit reflection matches the added
LoadAverageFFMTest.oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/ProcessorInformationFFM.java (2)
31-34: LGTM!
querySystemCounters()correctly reuses the common processor tick properties and total-processor raw counter selector.
41-44: LGTM!The interrupts query mirrors the JNA-style wrapper shape and uses the expected
InterruptsPropertyenum.oshi-core-java25/src/main/java/oshi/ffm/windows/WinNTFFM.java (1)
27-27: LGTM!
REG_MULTI_SZbelongs with the existing registry value type constants and enables explicit multi-string type checks.oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsCentralProcessor.java (1)
73-76: LGTM!The singleton-based delegation preserves the existing config-gated daemon startup and
nelemvalidation behavior.Also applies to: 317-321
oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/ProcessInformationFFM.java (1)
45-48: LGTM!The wildcard query uses the shared idle-process property enum and the expected
IDPROCESS = 0selector.oshi-core/src/main/java/oshi/driver/windows/perfmon/LoadAverageJNA.java (2)
22-29: LGTM!The static-final singleton keeps daemon state centralized and avoids repeated
LoadAverageJNAinstances.
52-56: LGTM!The queue-length lookup preserves a safe
0Lfallback when the counter is unavailable.oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/SystemInformationFFM.java (1)
31-42: LGTM.The FFM wrapper mirrors the common perfmon property definitions and keeps both system counter queries consistently routed through
PerfCounterQueryFFM.oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/LoadAverageFFM.java (1)
31-56: LGTM.The FFM implementation cleanly supplies the two platform hooks required by the common
LoadAveragebase and keeps missing queue-length data safely defaulted to0L.oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfCounterWildcardQueryFFM.java (1)
50-113: LGTM.The PDH-first/WMI-fallback flow matches the wildcard enum contract, and the failed-query cache is thread-safe.
oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java (1)
27-122: LGTM.The common base cleanly separates daemon/smoothing logic from the platform-specific perfmon queries while preserving the existing load-average lifecycle.
8952e46 to
3f7b8cb
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
♻️ Duplicate comments (1)
oshi-core-java25/src/main/java/oshi/util/platform/windows/Advapi32UtilFFM.java (1)
229-238:⚠️ Potential issue | 🟠 MajorRetry instead of parsing after an undersized-buffer result.
Line 236 still treats
ERROR_MORE_DATA/ERROR_INSUFFICIENT_BUFFERas readable data. If the value grows between the size probe and the read, this can parse a truncatedREG_MULTI_SZ. Only parse afterERROR_SUCCESS; otherwise resize fromlpcbDataand retry.Proposed fix
- int size = lpcbData.get(JAVA_INT, 0); - // Allocate extra for double-null terminator - MemorySegment data = arena.allocate(size + 4); - data.fill((byte) 0); - lpcbData.set(JAVA_INT, 0, size + 4); - - rc = RegQueryValueEx(hKey, toWideString(arena, valueName), 0, lpType, data, lpcbData); - if (rc != ERROR_SUCCESS && rc != ERROR_INSUFFICIENT_BUFFER && rc != ERROR_MORE_DATA) { + int size = lpcbData.get(JAVA_INT, 0); + MemorySegment data; + do { + // Allocate extra for double-null terminator + data = arena.allocate(size + 4L); + data.fill((byte) 0); + lpcbData.set(JAVA_INT, 0, size + 4); + + rc = RegQueryValueEx(hKey, toWideString(arena, valueName), 0, lpType, data, lpcbData); + if (rc == ERROR_INSUFFICIENT_BUFFER || rc == ERROR_MORE_DATA) { + size = lpcbData.get(JAVA_INT, 0); + } + } while (rc == ERROR_INSUFFICIENT_BUFFER || rc == ERROR_MORE_DATA); + + if (rc != ERROR_SUCCESS) { throw new Win32Exception(rc); }Microsoft RegQueryValueExW documentation ERROR_MORE_DATA buffer too small lpcbData required size🤖 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/util/platform/windows/Advapi32UtilFFM.java` around lines 229 - 238, The code currently treats ERROR_MORE_DATA / ERROR_INSUFFICIENT_BUFFER as readable data after the RegQueryValueEx call; change the logic in the RegQueryValueEx handling (around variables rc, lpcbData, data and the RegQueryValueEx call) so that you only parse the buffer when rc == ERROR_SUCCESS, and on rc == ERROR_MORE_DATA or ERROR_INSUFFICIENT_BUFFER use the updated size in lpcbData to reallocate data and retry the RegQueryValueEx call (loop until ERROR_SUCCESS or a true error), then parse only on success; keep throwing Win32Exception for other error codes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java`:
- Around line 47-58: The stop/start race can create two sampler threads because
stopDaemon() sets loadAvgThread = null immediately after interrupting; change
the lifecycle so the worker clears the shared loadAvgThread reference when it
exits and stopDaemon() only nulls the field after confirming termination (use
Thread.join with a bounded timeout) to avoid races. Specifically: in
stopDaemon(), call interrupt() and then join(timeout) on the existing
loadAvgThread and only set loadAvgThread = null after join returns (or the
thread has otherwise terminated); in the Thread body started by startDaemon()
ensure the thread clears loadAvgThread upon normal exit (and respects
interruption while performing perfmon queries) and that startDaemon() still
checks loadAvgThread == null before creating a new thread. Ensure the shared
variable loadAvgThread is only cleared by the worker on exit or by stopDaemon
after join to prevent double samplers.
In
`@oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java`:
- Around line 287-298: The loop that fills counterHandles aborts the entire
wildcard query on the first addEnglishCounter failure, which is too strict;
change PerfDataUtilFFM so that when addEnglishCounter(path) throws you skip that
specific counter add instead of returning an empty Pair — e.g., for each
props[p] catch exceptions, log them, insert a null sentinel (or simply do not
add to counterHandles[p-1] for that instance) and continue; ensure later code
that reads handles treats nulls as missing (0L reads) so a single transient
failure won’t close the whole query (align behavior with queryCounters and
prevent PerfCounterWildcardQueryFFM.queryInstancesAndValues from disabling PDH
for the whole perfObject).
- Around line 188-201: The retry loop currently overwrites PDH-returned buffer
sizes with the previous input sizes plus 1024, which discards the authoritative
required-size written by PdhEnumObjectItemsW; change the logic in the loop that
handles PDH_MORE_DATA so that after PdhEnumObjectItemsW returns PDH_MORE_DATA
you read the updated values from counterLen and instanceLen (these contain the
required TCHAR counts), allocate counterBuf and instanceBuf based on those
returned sizes (and optionally add a fixed headroom like +1024), and only then
retry the call; also add a small max-iteration cap (e.g., 5) around the do/while
to guarantee termination under pathological churn.
---
Duplicate comments:
In
`@oshi-core-java25/src/main/java/oshi/util/platform/windows/Advapi32UtilFFM.java`:
- Around line 229-238: The code currently treats ERROR_MORE_DATA /
ERROR_INSUFFICIENT_BUFFER as readable data after the RegQueryValueEx call;
change the logic in the RegQueryValueEx handling (around variables rc, lpcbData,
data and the RegQueryValueEx call) so that you only parse the buffer when rc ==
ERROR_SUCCESS, and on rc == ERROR_MORE_DATA or ERROR_INSUFFICIENT_BUFFER use the
updated size in lpcbData to reallocate data and retry the RegQueryValueEx call
(loop until ERROR_SUCCESS or a true error), then parse only on success; keep
throwing Win32Exception for other error codes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 981d9235-7b18-4368-a81e-a4c2e3d44783
📒 Files selected for processing (20)
CHANGELOG.mdoshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/LoadAverageFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/MemoryInformationFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/PagingFileFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/ProcessInformationFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/ProcessorInformationFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/SystemInformationFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/WinErrorFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/WinNTFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/Advapi32UtilFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/PerfCounterWildcardQueryFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.javaoshi-core-java25/src/test/java/module-info.testoshi-core-java25/src/test/java/oshi/driver/windows/perfmon/LoadAverageFFMTest.javaoshi-core/src/main/java/oshi/driver/windows/perfmon/LoadAverageJNA.javaoshi-core/src/main/java/oshi/driver/windows/perfmon/ProcessInformationJNA.javaoshi-core/src/main/java/oshi/hardware/platform/windows/WindowsCentralProcessor.javaoshi-core/src/test/java/oshi/driver/windows/perfmon/LoadAverageTest.java
✅ Files skipped from review due to trivial changes (8)
- oshi-core/src/main/java/oshi/driver/windows/perfmon/ProcessInformationJNA.java
- oshi-core-java25/src/main/java/oshi/ffm/windows/WinErrorFFM.java
- oshi-core-java25/src/test/java/module-info.test
- oshi-core-java25/src/main/java/oshi/ffm/windows/WinNTFFM.java
- CHANGELOG.md
- oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/MemoryInformationFFM.java
- oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/SystemInformationFFM.java
- oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/LoadAverageFFM.java
🚧 Files skipped from review as they are similar to previous changes (6)
- oshi-core/src/test/java/oshi/driver/windows/perfmon/LoadAverageTest.java
- oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsCentralProcessor.java
- oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/PagingFileFFM.java
- oshi-core-java25/src/test/java/oshi/driver/windows/perfmon/LoadAverageFFMTest.java
- oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/ProcessInformationFFM.java
- oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/ProcessorInformationFFM.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: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (7)
📚 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/util/platform/windows/Advapi32UtilFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/PerfCounterWildcardQueryFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java
📚 Learning: 2026-03-29T20:01:06.452Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java11/src/main/java/module-info.java:10-17
Timestamp: 2026-03-29T20:01:06.452Z
Learning: In the oshi project, `oshi-core-java25/src/main/java/module-info.java` intentionally does NOT export `oshi.util.platform.unix.freebsd`, `oshi.util.platform.unix.openbsd`, or `oshi.util.platform.unix.solaris`, because the FFM (Foreign Function & Memory) implementation only supports Windows, macOS, and Linux. This differs from `oshi-core-java11/src/main/java/module-info.java` which exports all Unix platform packages. The asymmetry is by design.
Applied to files:
oshi-core-java25/src/main/java/oshi/util/platform/windows/Advapi32UtilFFM.java
📚 Learning: 2026-04-06T04:45:51.516Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:51.516Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.
Applied to files:
oshi-core-java25/src/main/java/oshi/util/platform/windows/Advapi32UtilFFM.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/util/platform/windows/Advapi32UtilFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/PerfCounterWildcardQueryFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java
📚 Learning: 2026-04-11T05:51:52.684Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3139
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxGpuStatsFFM.java:36-58
Timestamp: 2026-04-11T05:51:52.684Z
Learning: In OSHI's `LinuxGpuStats` (oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxGpuStats.java), the abstract `nvml*` methods (nvmlGetVramUsed, nvmlGetCoreClockMhz, nvmlGetMemoryClockMhz, nvmlGetTemperature, nvmlGetPowerDraw, nvmlGetFanSpeedPercent) are contractually expected to return `-1` (long or double) on failure. The base class applies `if (val >= 0)` guards before using any NVML result and falls through to sysfs/hwmon paths when negative. Subclasses (LinuxGpuStatsJNA, LinuxGpuStatsFFM) correctly pass through the -1 sentinel unchanged — do not flag this as a missing clamp or contract violation.
Applied to files:
oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java
📚 Learning: 2026-04-10T22:44:36.786Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3136
File: oshi-core-java25/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java:46-53
Timestamp: 2026-04-10T22:44:36.786Z
Learning: In OSHI's `AuxvFFM.queryAuxv()` (oshi-core-java25/src/main/java/oshi/driver/linux/proc/AuxvFFM.java), the do-while loop is safe even when `/proc/self/auxv` cannot be read: `FileUtil.readAllBytesAsBuffer` returns an empty ByteBuffer on failure, and `FileUtil.readLongFromBuffer`/`readIntFromBuffer` return 0L when reading past the buffer limit. This 0L equals AT_NULL, causing the loop to exit immediately with an empty map, which triggers the `getconf`/hardcoded-default fallback in callers like `LinuxOperatingSystemFFM`. Do not flag this do-while loop or the static initializer that calls `AuxvFFM.queryAuxv()` as unsafe.
Applied to files:
oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.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/perfmon/LoadAverage.java
🔇 Additional comments (7)
oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java (1)
27-45: The abstract query hooks and synchronized snapshotting look good.The common daemon now cleanly delegates platform-specific counter collection while keeping load-average state protected behind the existing monitor.
Also applies to: 62-105
oshi-core/src/main/java/oshi/driver/windows/perfmon/LoadAverageJNA.java (1)
20-62: LGTM.The JNA singleton cleanly preserves the existing perfmon flow, handles missing counter maps safely, and keeps queue-length fallback behavior consistent with the driver contract.
oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfCounterWildcardQueryFFM.java (2)
50-61: Approve: PDH→WMI fallback with failed-query cache faithfully mirrors the JNA implementation.Gate logic, one-shot
LOG.infoon disable, and idempotent cache add viaConcurrentHashMap.newKeySet()are correct. Note thatFAILED_QUERY_CACHEis process-lifetime (never cleared) — that matches the JNA class's behavior, so intentional, but worth noting for long-running processes where perf counters are rebuilt externally (e.g.,lodctr /r).
92-113: No null-safety issue:IWbemClassObjectFFM.getString()andgetLong()never return null.Both methods explicitly document they return
""and0Lrespectively on missing/null property values. The implementation confirms this: every code path returns a non-null value. No coalescing is needed; lines 108 and 110 are safe as written.> Likely an incorrect or invalid review comment.oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java (1)
46-82: Approve: raw-counter layout and new PDH bindings match the native ABI.
PDH_RAW_COUNTER_LAYOUTnow matches the 32-byte native struct with correct offsets (CStatus@0, TimeStampLow@4, TimeStampHigh@8, FirstValue@12, SecondValue@20, MultiCount@28).JAVA_LONG_UNALIGNED/JAVA_INT_UNALIGNEDcorrectly account for the 4-byte-aligned FirstValue/SecondValue positions.PdhGetRawCounterValue,PdhLookupPerfNameByIndexW, andPdhEnumObjectItemsWsignatures and arities match the Win32 PDH ABI.PDH_CSTATUS_VALID_DATA/PDH_CSTATUS_NEW_DATAmatch MS documentation.Previous struct-layout concern is correctly resolved.
oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java (2)
146-158: Approve: raw-counter read now validatesCStatusbefore consumingFirstValue.Previous review concern about returning data without checking
PDH_RAW_COUNTER.CStatusis fully addressed. The use ofJAVA_LONG_UNALIGNEDatRAW_FIRST_VALUE_OFFSETcorrectly matches the 4-byte-aligned field position in the 32-byte native struct. TheIllegalStateExceptionpropagates up to the callingtry { ... } catch (Throwable t)blocks inqueryCounters/queryWildcardCounters, which correctly log and substitute default values — preserving per-counter fault tolerance.
335-390: Approve: English→localized object-name resolution via Perflib registry +PdhLookupPerfNameByIndexW.The lookup strategy is correct: it reads
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009\Counter(always English regardless of system locale) to resolve the English name to its index, then usesPdhLookupPerfNameByIndexWto get the localized name thatPdhEnumObjectItemsWexpects. Two-call size probing onPdhLookupPerfNameByIndexWis handled correctly, andLOCALIZE_CACHEamortizes the registry read (theCountermultistring is large, so caching is important). Fallback to the English name on any failure degrades gracefully.
3f7b8cb to
f3b7173
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (3)
oshi-core-java25/src/main/java/oshi/util/platform/windows/Advapi32UtilFFM.java (3)
225-227: Avoid rawRuntimeException; use a more specific type.Throwing a bare
RuntimeExceptionfor a type mismatch is a minor smell.IllegalStateException(orWin32Exception-style domain type) conveys intent better, even though the outercatch (Throwable)makes this functionally equivalent.🤖 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/util/platform/windows/Advapi32UtilFFM.java` around lines 225 - 227, Replace the raw RuntimeException thrown in Advapi32UtilFFM when the registry type mismatches with a more specific exception (e.g., IllegalStateException or a Win32-specific exception type); update the throw that currently builds "Unexpected registry type " + lpType.get(JAVA_INT, 0) + ", expected REG_MULTI_SZ" to instead throw IllegalStateException (or a Win32Exception) with the same message to convey intent more clearly.
261-263:RegCloseKeyreturn value is silently discarded.Other methods in this file (e.g.,
registryGetKeysat lines 144–147) treat a failed close as a fatal error. Here the return code is ignored. Since this is in afinally, throwing would mask the original exception, so silently ignoring is arguably the better choice — consider at least logging at debug level on non-success for consistency.- } finally { - RegCloseKey(hKey); - } + } finally { + int closeRc = RegCloseKey(hKey); + if (closeRc != ERROR_SUCCESS) { + LOG.debug("RegCloseKey failed for {}\\{}: rc={}", keyPath, valueName, closeRc); + } + }🤖 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/util/platform/windows/Advapi32UtilFFM.java` around lines 261 - 263, The RegCloseKey(hKey) call in Advapi32UtilFFM's finally block currently discards the return value; change it to capture the return code and, if it indicates failure (non-success), emit a debug-level log message (consistent with how registryGetKeys handles RegCloseKey failures) rather than throwing, so the original exception isn’t masked—use the same logger/format used elsewhere in this class for consistency.
247-258: Bound the multi-sz parse loop by the actual bytes returned, not buffer capacity.
data.byteSize()is the allocated buffer size (size + 4), not the bytes actually written byRegQueryValueEx. The explicit zero-fill at line 235 plus the empty-string break at line 252 keeps this safe today, but if the zero-fill is ever removed, or ifreadWideStringis changed to scan past embedded nulls, the loop could read uninitialized tail bytes. Prefer bounding by the value returned inlpcbDatafor clarity and defensiveness.♻️ Proposed refactor
- // Parse multi-sz: null-delimited wide strings, double-null terminated - List<String> result = new ArrayList<>(); - long offset = 0; - while (offset < data.byteSize()) { + // Parse multi-sz: null-delimited wide strings, double-null terminated + List<String> result = new ArrayList<>(); + long dataBytes = Integer.toUnsignedLong(lpcbData.get(JAVA_INT, 0)); + long offset = 0; + while (offset < dataBytes) { String s = readWideString(data.asSlice(offset)); if (s.isEmpty()) { break; } result.add(s); offset += ((long) s.length() + 1) * 2; // chars + null, 2 bytes each }🤖 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/util/platform/windows/Advapi32UtilFFM.java` around lines 247 - 258, The multi-sz parsing loop in Advapi32UtilFFM currently bounds by data.byteSize() (the allocated buffer) which can exceed the actual bytes written; change the loop to use the actual byte count returned by RegQueryValueEx (lpcbData) as the upper bound, ensure each slice/read of readWideString is limited to the remaining bytes (e.g., asSlice(offset, lpcbData - offset) or equivalent), and stop when offset >= lpcbData or when an empty string is encountered; update uses of offset arithmetic to compare against lpcbData (not data.byteSize()) so the loop never reads past the returned data.
🤖 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/util/platform/windows/Advapi32UtilFFM.java`:
- Around line 225-227: Replace the raw RuntimeException thrown in
Advapi32UtilFFM when the registry type mismatches with a more specific exception
(e.g., IllegalStateException or a Win32-specific exception type); update the
throw that currently builds "Unexpected registry type " + lpType.get(JAVA_INT,
0) + ", expected REG_MULTI_SZ" to instead throw IllegalStateException (or a
Win32Exception) with the same message to convey intent more clearly.
- Around line 261-263: The RegCloseKey(hKey) call in Advapi32UtilFFM's finally
block currently discards the return value; change it to capture the return code
and, if it indicates failure (non-success), emit a debug-level log message
(consistent with how registryGetKeys handles RegCloseKey failures) rather than
throwing, so the original exception isn’t masked—use the same logger/format used
elsewhere in this class for consistency.
- Around line 247-258: The multi-sz parsing loop in Advapi32UtilFFM currently
bounds by data.byteSize() (the allocated buffer) which can exceed the actual
bytes written; change the loop to use the actual byte count returned by
RegQueryValueEx (lpcbData) as the upper bound, ensure each slice/read of
readWideString is limited to the remaining bytes (e.g., asSlice(offset, lpcbData
- offset) or equivalent), and stop when offset >= lpcbData or when an empty
string is encountered; update uses of offset arithmetic to compare against
lpcbData (not data.byteSize()) so the loop never reads past the returned data.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e7a5574b-ea89-404f-a5ce-267adacfd0fb
📒 Files selected for processing (20)
CHANGELOG.mdoshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/LoadAverageFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/MemoryInformationFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/PagingFileFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/ProcessInformationFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/ProcessorInformationFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/perfmon/SystemInformationFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/WinErrorFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/WinNTFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/Advapi32UtilFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/PerfCounterWildcardQueryFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.javaoshi-core-java25/src/test/java/module-info.testoshi-core-java25/src/test/java/oshi/driver/windows/perfmon/LoadAverageFFMTest.javaoshi-core/src/main/java/oshi/driver/windows/perfmon/LoadAverageJNA.javaoshi-core/src/main/java/oshi/driver/windows/perfmon/ProcessInformationJNA.javaoshi-core/src/main/java/oshi/hardware/platform/windows/WindowsCentralProcessor.javaoshi-core/src/test/java/oshi/driver/windows/perfmon/LoadAverageTest.java
✅ Files skipped from review due to trivial changes (9)
- oshi-core-java25/src/test/java/module-info.test
- oshi-core-java25/src/main/java/oshi/ffm/windows/WinNTFFM.java
- oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/MemoryInformationFFM.java
- oshi-core-java25/src/test/java/oshi/driver/windows/perfmon/LoadAverageFFMTest.java
- oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/SystemInformationFFM.java
- oshi-core-java25/src/main/java/oshi/ffm/windows/WinErrorFFM.java
- oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/LoadAverageFFM.java
- CHANGELOG.md
- oshi-core/src/main/java/oshi/driver/windows/perfmon/ProcessInformationJNA.java
🚧 Files skipped from review as they are similar to previous changes (6)
- oshi-core/src/test/java/oshi/driver/windows/perfmon/LoadAverageTest.java
- oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/PagingFileFFM.java
- oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/ProcessInformationFFM.java
- oshi-core-java25/src/main/java/oshi/driver/windows/perfmon/ProcessorInformationFFM.java
- oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfCounterWildcardQueryFFM.java
- oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.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). (10)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 11, windows-latest
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 11, macos-latest
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 25, macos-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: 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.
📚 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/hardware/platform/windows/WindowsCentralProcessor.javaoshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.javaoshi-core/src/main/java/oshi/driver/windows/perfmon/LoadAverageJNA.java
📚 Learning: 2026-04-12T19:34:59.050Z
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:34:59.050Z
Learning: The counterintuitive naming of `PhysicalProcessor.getEfficiency()` / `EfficiencyClass` in OSHI (where a higher value means MORE performance and LESS efficiency, so P-cores get higher values than E-cores) is intentionally inherited from Microsoft's `PROCESSOR_RELATIONSHIP.EfficiencyClass` Win32 API: "A core with a higher value for the efficiency class has intrinsically greater performance and less efficiency." OSHI follows this same convention for cross-platform consistency. Do not flag P-cores being assigned higher efficiency values as a bug.
Applied to files:
oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsCentralProcessor.javaoshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java
📚 Learning: 2026-04-06T04:45:47.644Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:47.644Z
Learning: In the oshi/oshi project, only interfaces and classes in the root packages `oshi`, `oshi.hardware`, and `oshi.software.os` are considered the public API. Code in subpackages that represent specific implementations/platforms (e.g., `oshi.software.os.linux`, `oshi.hardware.platform.linux`, and similar subpackages) is implementation detail. When reviewing, do not treat changes to classes in these platform-specific subpackages as public API breaks (for example: making `LinuxOperatingSystem` abstract, narrowing constructor visibility, or adding/removing abstract methods should not be flagged as breaking public API).
Applied to files:
oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsCentralProcessor.java
📚 Learning: 2026-04-10T22:44:36.786Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3136
File: oshi-core-java25/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java:46-53
Timestamp: 2026-04-10T22:44:36.786Z
Learning: In OSHI's `AuxvFFM.queryAuxv()` (oshi-core-java25/src/main/java/oshi/driver/linux/proc/AuxvFFM.java), the do-while loop is safe even when `/proc/self/auxv` cannot be read: `FileUtil.readAllBytesAsBuffer` returns an empty ByteBuffer on failure, and `FileUtil.readLongFromBuffer`/`readIntFromBuffer` return 0L when reading past the buffer limit. This 0L equals AT_NULL, causing the loop to exit immediately with an empty map, which triggers the `getconf`/hardcoded-default fallback in callers like `LinuxOperatingSystemFFM`. Do not flag this do-while loop or the static initializer that calls `AuxvFFM.queryAuxv()` as unsafe.
Applied to files:
oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java
📚 Learning: 2026-04-11T05:51:52.684Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3139
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxGpuStatsFFM.java:36-58
Timestamp: 2026-04-11T05:51:52.684Z
Learning: In OSHI's `LinuxGpuStats` (oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxGpuStats.java), the abstract `nvml*` methods (nvmlGetVramUsed, nvmlGetCoreClockMhz, nvmlGetMemoryClockMhz, nvmlGetTemperature, nvmlGetPowerDraw, nvmlGetFanSpeedPercent) are contractually expected to return `-1` (long or double) on failure. The base class applies `if (val >= 0)` guards before using any NVML result and falls through to sysfs/hwmon paths when negative. Subclasses (LinuxGpuStatsJNA, LinuxGpuStatsFFM) correctly pass through the -1 sentinel unchanged — do not flag this as a missing clamp or contract violation.
Applied to files:
oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.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-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/Advapi32UtilFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.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/perfmon/LoadAverage.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-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.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/util/platform/windows/Advapi32UtilFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java
📚 Learning: 2026-03-29T20:01:06.452Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java11/src/main/java/module-info.java:10-17
Timestamp: 2026-03-29T20:01:06.452Z
Learning: In the oshi project, `oshi-core-java25/src/main/java/module-info.java` intentionally does NOT export `oshi.util.platform.unix.freebsd`, `oshi.util.platform.unix.openbsd`, or `oshi.util.platform.unix.solaris`, because the FFM (Foreign Function & Memory) implementation only supports Windows, macOS, and Linux. This differs from `oshi-core-java11/src/main/java/module-info.java` which exports all Unix platform packages. The asymmetry is by design.
Applied to files:
oshi-core-java25/src/main/java/oshi/util/platform/windows/Advapi32UtilFFM.java
📚 Learning: 2026-04-06T04:45:51.516Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:51.516Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.
Applied to files:
oshi-core-java25/src/main/java/oshi/util/platform/windows/Advapi32UtilFFM.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/util/platform/windows/Advapi32UtilFFM.javaoshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java
📚 Learning: 2026-04-06T22:30:07.083Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3122
File: oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.java:215-234
Timestamp: 2026-04-06T22:30:07.083Z
Learning: In `oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.java`, the `found` flag in `getControllerIdByLocation` is intentionally set to `true` as soon as either `vendor-id` or `device-id` is found in a matching service's parent. This is a deliberate design choice: a partial match (one of the two IDs) is preferred over continuing to iterate, because iterating further risks pairing IDs from two different and potentially mismatched services. Do not flag this as a bug or suggest splitting into separate `foundVendor`/`foundProduct` flags.
Applied to files:
oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java
🔇 Additional comments (7)
oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsCentralProcessor.java (1)
38-38: JNA load-average integration looks consistent.The import, daemon startup, and query path now consistently use the
LoadAverageJNAsingleton while preserving the existingnelemvalidation.Also applies to: 75-75, 321-321
oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java (1)
5-17: Common load-average abstraction looks sound.The shared daemon/smoothing logic is cleanly separated from backend-specific perfmon queries, and the synchronized lifecycle/state access remains consistent. Based on learnings, the synchronized
stopDaemon()/startDaemon()pattern here is intentional and should not be flagged as a race.Also applies to: 20-22, 27-44, 47-122
oshi-core/src/main/java/oshi/driver/windows/perfmon/LoadAverageJNA.java (1)
22-62: JNA backend implementation looks good.The singleton is safely initialized, and both perfmon hooks provide defensive fallbacks for missing counter data.
oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java (4)
146-158: LGTM: raw counter reads now validateCStatus.Using layout-derived offsets for
CStatusandFirstValueavoids hard-coded struct offset drift and prevents invalid raw samples from leaking to callers. Based on learnings,PDH_RAW_COUNTER_LAYOUTmust preserve native alignment soFirstValueis read from the aligned layout offset.
167-217: LGTM: instance enumeration handles PDH buffer churn safely.The
PDH_MORE_DATApath now reuses PDH-returned lengths, adds headroom, and caps retries, which is a good fit for changing process/thread instance lists.
289-298: LGTM: aborting on wildcard counter-add failure preserves alignment.Returning an empty result here is safer than partially filling per-property lists because callers rely on strict index alignment between
instancesand every values list. Based on learnings,queryWildcardCountersintentionally aborts onaddEnglishCounterfailure to preserve the parallel-list contract.
337-392: LGTM: localized object lookup has safe fallbacks.The English-index lookup and localized-name resolution fall back to the original object name on missing registry/API data, keeping PDH fallback behavior non-fatal.
refactor LoadAverage Wildcard query infrastructure: - Add PdhEnumObjectItemsW, PdhLookupPerfNameByIndexW, and PdhGetRawCounterValue FFM bindings to PdhFFM - Add enumInstances (two-call pattern with PDH_MORE_DATA retry) and queryWildcardCounters to PerfDataUtilFFM - Add object name localization (PdhEnumObjectItemsW requires localized names) with registry-based English-to-index lookup - Add registryGetStringArray to Advapi32UtilFFM for REG_MULTI_SZ - Create PerfCounterWildcardQueryFFM with PDH-first/WMI-fallback pattern - Use raw counters exclusively (matching JNA), removing formatted counter bindings LoadAverage refactoring: - Extract abstract LoadAverage to oshi-common with daemon thread logic, exponential smoothing, and two abstract query methods - Create LoadAverageJNA in oshi-core implementing queries via JNA drivers - Create LoadAverageFFM in oshi-core-java25 implementing queries via FFM drivers - Add LoadAverageFFMTest mirroring existing JNA test FFM perfmon drivers: - Add queryIdleProcessCounters() to ProcessInformationFFM (wildcard) - Add MemoryInformationFFM, PagingFileFFM, ProcessorInformationFFM, SystemInformationFFM non-wildcard drivers
f3b7173 to
d9d852d
Compare
Wildcard Query Infrastructure
Adds FFM-based wildcard PDH counter query support, enabling enumeration of performance counter instances and querying per-instance values:
PdhEnumObjectItemsW,PdhLookupPerfNameByIndexW, andPdhGetRawCounterValueFFM bindings; remove unused formatted counter bindings (PdhGetFormattedCounterValue,PdhGetFormattedCounterArray,PDH_FMT_COUNTERVALUE_*layouts)enumInstances(two-call pattern withPDH_MORE_DATAretry),queryWildcardCounters, object name localization (required byPdhEnumObjectItemsW), andparseMultiSzfor REG_MULTI_SZ parsing. Both wildcard and non-wildcard paths now use raw counters exclusively, matching JNA behaviorregistryGetStringArrayfor REG_MULTI_SZ registry values (used for English→index counter name lookup)REG_MULTI_SZconstantPerfCounterWildcardQueryLoadAverage Refactoring
LoadAveragetooshi-commonwith daemon thread logic, exponential smoothing,startDaemon/stopDaemon/queryLoadAverage, and two abstract methods:queryNonIdleTicks()andqueryQueueLength()LoadAverageJNAsingleton inoshi-coreusing JNA perfmon driversLoadAverageFFMsingleton inoshi-core-java25using FFM perfmon driversLoadAverageFFMTestmirroring existing JNA test structureFFM Perfmon Drivers
ProcessInformationFFM: AddqueryIdleProcessCounters()(wildcard query)MemoryInformationFFM,PagingFileFFM,ProcessorInformationFFM,SystemInformationFFMSummary by CodeRabbit
Bug Fixes / Improvements
New Features
Tests
Chores