Skip to content

Migrate Windows FFM classes to arena call helpers - #3289

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:migrate-windows-arena-calls
May 23, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:migrate-windows-arena-calls

Conversation

@dbwiddis

@dbwiddis dbwiddis commented May 23, 2026 •

Copy link
Copy Markdown
Member

Migrate simple try (Arena) { ... } catch (Throwable) patterns in Windows FFM classes to use the centralized arena call helpers from ForeignFunctions, consistent with the Linux (#3285) and macOS (#3287) migrations.

Migrated methods:

  • WindowsGlobalMemoryFFM.readPerfInfo() → callInArenaOrDefault
  • WindowsVirtualMemoryFFM.querySwapTotalVirtMaxVirtUsed() → callInArenaOrDefault
  • WindowsNetworkIfFFM.updateAttributes() → callInArenaBooleanOrDefault
  • WindowsOperatingSystemFFM.getPerformanceInfoField() → callInArenaIntOrDefault

Methods requiring handle/resource closing in finally blocks are deferred for a future refactoring pass.

Summary by CodeRabbit

  • Refactor
    • Streamlined Windows system information collection code through improved error handling and resource management patterns.

Review Change Stack

Migrate simple try-Arena-catch-Throwable patterns in Windows FFM
classes to use the centralized arena call helpers from
ForeignFunctions, consistent with the Linux (#3285) and macOS (#3287)
migrations.

Migrated methods:
- WindowsGlobalMemoryFFM.readPerfInfo() -> callInArenaOrDefault
- WindowsVirtualMemoryFFM.querySwapTotalVirtMaxVirtUsed() -> callInArenaOrDefault
- WindowsNetworkIfFFM.updateAttributes() -> callInArenaBooleanOrDefault
- WindowsOperatingSystemFFM.getPerformanceInfoField() -> callInArenaIntOrDefault

Methods requiring handle/resource closing in finally blocks are
deferred for a future refactoring pass.
@coderabbitai

coderabbitai Bot commented May 23, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fc846cd6-e7de-4dc7-89a7-a56f342f8403

📥 Commits

Reviewing files that changed from the base of the PR and between 0e9dfba and ca3ba09.

📒 Files selected for processing (4)
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGlobalMemoryFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsNetworkIfFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsVirtualMemoryFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
📜 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). (13)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 11, windows-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 11, macos-latest
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: JMH Benchmarks, ubuntu-latest
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Analyze (java)
🔇 Additional comments (4)
oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGlobalMemoryFFM.java (1)

7-8: LGTM!

Also applies to: 109-127

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

7-8: LGTM!

Also applies to: 88-104

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

9-10: LGTM!

Also applies to: 267-280

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

7-9: LGTM!

Also applies to: 84-121


📝 Walkthrough

Walkthrough

Four Windows FFM platform classes standardize arena allocation and error handling by replacing manual Arena.ofConfined() try-with-resources blocks and catch-all exception handlers with three typed helpers: callInArenaOrDefault (returning Triplet), callInArenaIntOrDefault (returning int), and callInArenaBooleanOrDefault (returning boolean). Each refactors one method to centralize arena lifetime, failure logging at ERROR level, and default fallback values.

Changes

FFM Arena Helper Refactoring

Layer / File(s) Summary
Global and Virtual Memory Performance Info
oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGlobalMemoryFFM.java, WindowsVirtualMemoryFFM.java
readPerfInfo() and querySwapTotalVirtMaxVirtUsed() are refactored to use callInArenaOrDefault, replacing explicit Arena.ofConfined() try-with-resources and manual exception catching with helper-driven arena management, ERROR-level logging on failure, and default Triplet<>(0L,0L,0L) fallback. Static imports updated to include Level.ERROR.
Operating System Performance Field
oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
getPerformanceInfoField() is refactored to use callInArenaIntOrDefault, delegating arena allocation and exception handling to the helper while preserving default integer return behavior and ERROR-level logging. Static imports added for Level.ERROR and the helper method.
Network Interface Attributes
oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsNetworkIfFFM.java
updateAttributes() is refactored to use callInArenaBooleanOrDefault, capturing a success boolean from the arena-scoped callback and conditionally updating the timestamp only on success. Failure handling and logging now route through the helper with ERROR-level messages. Static imports updated to remove direct Arena usage and add helper and Level.ERROR imports.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • oshi/oshi#3284: Introduces the new ForeignFunctions.callInArena*OrDefault arena-execution helpers that these refactored Windows FFM call sites now adopt.

Poem

🐰 Arenas contained, errors logged true,
Foreign calls now follow one helper through,
Triplets, booleans, and ints find their way,
Windows FFM refactored today! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: migrating Windows FFM classes to use centralized arena call helpers, which is the primary focus across all four modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dbwiddis
dbwiddis merged commit 71596de into oshi:master May 23, 2026
17 of 18 checks passed
@dbwiddis
dbwiddis deleted the migrate-windows-arena-calls branch May 23, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant