Repository navigation
Split WindowsOSProcess into superclass with JNA/FFM subclasses - #3141
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 (8)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
📜 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). (9)
🧰 Additional context used🧠 Learnings (3)📚 Learning: 2026-03-29T20:01:06.452ZApplied to files:
📚 Learning: 2026-04-03T02:07:47.621ZApplied to files:
📚 Learning: 2026-04-06T04:45:47.644ZApplied to files:
🔇 Additional comments (15)
📝 WalkthroughWalkthroughConverted WindowsOSProcess into an abstract superclass and added JNA and FFM concrete subclasses; added FFM downcalls for VerSetConditionMask/VerifyVersionInfoW, a VersionHelpersFFM utility, OSVERSIONINFOEX layout and version constants, and updated process instantiation to use the JNA backend. Changes
Sequence Diagram(s)sequenceDiagram
participant App as Caller
participant VH as VersionHelpersFFM
participant Arena as Arena
participant WinNT as WinNTFFM
participant K32 as Kernel32FFM
App->>VH: IsWindowsVersionOrGreater(major, minor, sp)
VH->>Arena: allocate OSVERSIONINFOEX, zero-fill
VH->>WinNT: set dwOSVersionInfoSize, major, minor, servicePack
VH->>K32: VerSetConditionMask(condMask, VER_MAJORVERSION, VER_GREATER_EQUAL)
K32-->>VH: updatedCond
VH->>K32: VerSetConditionMask(... VER_MINORVERSION ...)
K32-->>VH: updatedCond
VH->>K32: VerSetConditionMask(... VER_SERVICEPACKMAJOR ...)
K32-->>VH: updatedCond
VH->>K32: VerifyVersionInfoW(lpVersionInformation, dwTypeMask, dwlConditionMask)
K32-->>VH: success/fail
VH-->>App: boolean result
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 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✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3141 +/- ##
============================================
+ Coverage 62.00% 62.21% +0.21%
Complexity 12 12
============================================
Files 39 39
Lines 2329 2329
Branches 407 407
============================================
+ Hits 1444 1449 +5
+ Misses 776 770 -6
- Partials 109 110 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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/ffm/windows/VersionHelpersFFM.java`:
- Around line 108-117: In IsWindowsServer(), after calling
Kernel32FFM.VerifyVersionInfoW(osvi, VER_PRODUCT_TYPE, dwlConditionMask) do not
unconditionally negate the result; instead, when VerifyVersionInfoW returns
false call Kernel32FFM.GetLastError() and compare it to ERROR_OLD_WIN_VERSION
(0x47E) — only interpret ERROR_OLD_WIN_VERSION as indicating the system is a
server and return true, otherwise treat it as an API failure and return a safe
fallback (false) and/or log the unexpected error code; update the logic around
VerifyVersionInfoW, GetLastError, and the ERROR_OLD_WIN_VERSION check in the
IsWindowsServer method.
In `@oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java`:
- Around line 92-98: The catch block in WindowsOSProcessJNA around
Kernel32Util.QueryFullProcessImageName is incorrectly marking the process
INVALID on failure; change it to treat the path lookup as best-effort by
removing the setState(State.INVALID) call and leaving the process state
untouched (optionally clear or leave the path as-is via setPath only on
success). Locate the try/catch that calls Kernel32Util.QueryFullProcessImageName
in WindowsOSProcessJNA (the block that follows super.updateAttributes(...)) and
ensure Win32Exception is caught but does not call setState; instead simply skip
setting the path or log/debug the exception.
- Around line 150-171: The queryGroupInfo() method can leak handles if an
exception occurs between OpenProcessToken(...) and the manual CloseHandle(...)
calls; update queryGroupInfo() to mirror queryUserInfo() by wrapping the token
operations in a try/catch/finally so that both the token handle and the process
handle are always closed (call Kernel32.INSTANCE.CloseHandle(token) and
Kernel32.INSTANCE.CloseHandle(pHandle) in finally), preserve existing error
logging (including checking for ERROR_ACCESS_DENIED) in the catch, and ensure
phToken resources are still closed via CloseableHANDLEByReference.
🪄 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: 441cef99-e1f2-46bc-b599-96e4416e72d5
📒 Files selected for processing (8)
CHANGELOG.mdoshi-core-java25/src/main/java/oshi/ffm/windows/Kernel32FFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/VersionHelpersFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/WinNTFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.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). (10)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Test JDK 25, windows-latest
- GitHub Check: Test JDK 11, windows-latest
- GitHub Check: Test JDK 25, ubuntu-latest
- GitHub Check: Test JDK 11, macos-latest
- GitHub Check: Test JDK 25, macos-latest
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (5)
📚 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.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.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-java25/src/main/java/oshi/ffm/windows/VersionHelpersFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/WinNTFFM.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:
CHANGELOG.mdoshi-core-java25/src/main/java/oshi/ffm/windows/VersionHelpersFFM.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/ffm/windows/Kernel32FFM.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/ffm/windows/Kernel32FFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/VersionHelpersFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/WinNTFFM.java
aaa593e to
a912a56
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java (1)
127-132:⚠️ Potential issue | 🟡 Minor
GetLastError()called twice - second call may return stale or zero value.On Line 127, the error code is correctly stored in
error, but Line 130-131 callsGetLastError()again in the log statement. After the first call,GetLastError()is typically reset, so the second call may return 0 or a different value.Suggested fix
} else { int error = Kernel32.INSTANCE.GetLastError(); // Access denied errors are common. Fail silently. if (error != WinError.ERROR_ACCESS_DENIED) { LOG.error("Failed to get process token for process {}: {}", getProcessID(), - Kernel32.INSTANCE.GetLastError()); + error); } }🤖 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 127 - 132, The code in WindowsOSProcessJNA reads Kernel32.INSTANCE.GetLastError() into the local variable error but then calls GetLastError() again in the LOG.error message; replace the second call with the saved error variable to avoid a stale/cleared value. Update the LOG.error invocation that currently references Kernel32.INSTANCE.GetLastError() to use the existing error variable (named error) and keep the access-denied check using WinError.ERROR_ACCESS_DENIED unchanged.
🤖 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/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java`:
- Around line 160-165: In queryGroupInfo within WindowsOSProcessJNA the code
calls Kernel32.INSTANCE.GetLastError() twice; capture the error once (already
assigned to the local variable error) and use that variable in the LOG.error
call instead of calling GetLastError() again so the logged value matches the
checked condition; update the LOG.error invocation that currently passes
Kernel32.INSTANCE.GetLastError() to pass the error variable.
---
Duplicate comments:
In `@oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java`:
- Around line 127-132: The code in WindowsOSProcessJNA reads
Kernel32.INSTANCE.GetLastError() into the local variable error but then calls
GetLastError() again in the LOG.error message; replace the second call with the
saved error variable to avoid a stale/cleared value. Update the LOG.error
invocation that currently references Kernel32.INSTANCE.GetLastError() to use the
existing error variable (named error) and keep the access-denied check using
WinError.ERROR_ACCESS_DENIED unchanged.
🪄 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: c5acb6da-0214-44e7-83aa-4c279b2e4f6d
📒 Files selected for processing (8)
CHANGELOG.mdoshi-core-java25/src/main/java/oshi/ffm/windows/Kernel32FFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/VersionHelpersFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/WinNTFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.java
✅ Files skipped from review due to trivial changes (1)
- CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (2)
- oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.java
- oshi-core-java25/src/main/java/oshi/ffm/windows/VersionHelpersFFM.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: Test JDK 11, macos-latest
- GitHub Check: Test JDK 25, ubuntu-latest
- GitHub Check: Test JDK 25, windows-latest
- GitHub Check: Test JDK 11, windows-latest
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 25, macos-latest
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Analyze (java)
- GitHub Check: Codacy Static Code Analysis
🧰 Additional context used
🧠 Learnings (8)
📚 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/ffm/windows/Kernel32FFM.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-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/Kernel32FFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/WinNTFFM.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-java25/src/main/java/oshi/ffm/windows/WinNTFFM.java
📚 Learning: 2026-04-10T22:44:32.055Z
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:32.055Z
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/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
📚 Learning: 2026-04-05T05:39:21.126Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceFFM.java:62-65
Timestamp: 2026-04-05T05:39:21.126Z
Learning: In OSHI's Linux FFM/JNA udev code, a null guard on `udev_enumerate_new()` is unnecessary if `udev_new()` has already been guarded: per libudev semantics, `udev_enumerate_new()` only returns NULL when udev itself is broken (e.g. OOM), so a successful `udev_new()` implies `udev_enumerate_new()` will succeed as well. Do not flag missing null checks on `udev_enumerate_new()` as an issue.
Applied to files:
oshi-core/src/main/java/oshi/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/WindowsOSProcessJNA.java
📚 Learning: 2026-04-05T05:40:45.797Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceFFM.java:62-65
Timestamp: 2026-04-05T05:40:45.797Z
Learning: In OSHI's Linux FFM and JNA udev code, a null guard on `udev_enumerate_new()` is intentionally absent and should not be flagged. This is consistent across all four FFM classes (LinuxPowerSourceFFM, LinuxHWDiskStoreFFM, LinuxLogicalVolumeGroupFFM, LinuxUsbDeviceFFM) and the JNA implementation (which also does not guard `enumerateNew()` for null). Per libudev semantics, `udev_enumerate_new()` only returns NULL when udev itself is broken (e.g. OOM), so a successful `udev_new()` (which is guarded) implies `udev_enumerate_new()` will succeed. Adding a null guard would be both redundant and inconsistent with the established pattern.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.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.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.java
🔇 Additional comments (16)
oshi-core-java25/src/main/java/oshi/ffm/windows/Kernel32FFM.java (1)
487-531: LGTM!The new
VerSetConditionMaskandVerifyVersionInfoWbindings follow the established patterns in this class: proper downcall setup, catch-all exception handling with debug logging, and safe default return values (0L and false respectively). TheJAVA_BYTEimport is correctly added to support the condition parameter.oshi-core-java25/src/main/java/oshi/ffm/windows/WinNTFFM.java (1)
46-81: LGTM!The version constants and
OSVERSIONINFOEXstruct layout are correctly defined:
- VER_* flags match Windows SDK definitions
- WIN32_WINNT_* constants correctly encode
(major << 8 | minor)- The struct layout accounts for all 284 bytes with proper field types
- Offset computations use the correct MemoryLayout API
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java (5)
27-27: Good improvement replacing magic number with constant.Using
TOKEN_QUERYconstant import instead of the magic0x0008improves readability and maintainability.
59-70: LGTM!The class properly extends
WindowsOSProcessand the constructor correctly delegates to the superclass, eliminating duplicated initialization logic.
91-123: LGTM!The
updateAttributesimplementation correctly:
- Delegates to
super.updateAttributes(pcb, wts)first for shared logic- Performs FFM-specific WOW64 bitness detection and path lookup only on success
- Uses protected setters (
setBitness,setPath) to update state- Returns validity based on state check
This follows the established failure-handling pattern per project learnings.
125-196: LGTM!The protected method implementations (
queryArguments,queryUserInfo,queryGroupInfo) properly:
- Use the
TOKEN_QUERYconstant consistently- Return
defaultPair()on failure paths- Handle resource cleanup in finally blocks
- Log appropriate warnings for non-access-denied errors
261-346: LGTM!The
queryCwdCommandlineEnvironmentimplementation correctly handles memory reading with proper cleanup and falls back todefaultCwdCommandlineEnvironment()on any failure path.oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java (4)
1-57: LGTM!The class structure, imports, and constructor properly set up the JNA-based implementation extending the abstract
WindowsOSProcesssuperclass.
59-73: LGTM!The
getAffinityMaskimplementation correctly opens the process handle, queries the affinity mask, and ensures cleanup via the finally block.
75-105: LGTM!The
updateAttributesimplementation correctly:
- Calls
super.updateAttributes(pcb, wts)first- Performs JNA-specific WOW64 and path lookup
- Uses empty catch for
Win32Exceptionas best-effort (per past review feedback)- Ensures handle cleanup in finally
182-257: LGTM!The
queryCwdCommandlineEnvironmentandreadUnicodeStringimplementations correctly handle process memory reading with proper resource management via try-with-resources and finally blocks.oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.java (5)
38-48: LGTM!The refactoring to an abstract class with protected constructor and configuration flags is well-structured. Per project conventions, platform-specific subpackages are implementation detail, so this is not a breaking API change.
80-88: LGTM!The protected constructor properly initializes shared state and delegates to
updateAttributes. Subclasses will extend this with their native-specific initialization.
288-336: LGTM!The
updateAttributesimplementation correctly:
- Returns false immediately when
pcbis null, marking state as INVALID- Populates WTS-derived fields only when
wtsis not null- Sets state based on thread performance data when available
- Returns validity based on final state
This provides a clean contract for subclasses to extend with native-specific updates.
338-372: LGTM!The protected setters and
queryMatchingThreadshelper provide appropriate hooks for subclasses to update process attributes after native queries.
389-436: LGTM!The abstract method declarations clearly define the contract that subclasses must implement. The protected static default helpers (
defaultCwdCommandlineEnvironment,defaultPair) provide consistent fallback values.
…ersionHelpersFFM; remove TOKEN_DUPLICATE
a912a56 to
305379f
Compare
WindowsOSProcessabstract superclass with shared fields (private + setters), getters, and non-native methods (queryCommandLine,queryCwd,queryMatchingThreads,getThreadDetails,updateAttributes)WindowsOSProcesstoWindowsOSProcessJNAextending the new superclassWindowsOSProcessFFMto extend the new superclassVersionHelpersFFM— FFM port of JNA'sVersionHelpersusing nativeVerSetConditionMask/VerifyVersionInfoWfrom kernel32, replacing theos.versionstring-parsing workaroundOSVERSIONINFOEXstruct layout andVER_*/WIN32_WINNT_*constants toWinNTFFMVerSetConditionMaskandVerifyVersionInfoWbindings toKernel32FFMTOKEN_DUPLICATEfromOpenProcessTokencalls in both JNA and FFM — onlyTOKEN_QUERYis needed forGetTokenInformation0x0008withTOKEN_QUERYconstant import in FFMSummary by CodeRabbit
New Features
Refactor