Repository navigation
Expand JaCoCo coverage scope and extract DxgiUtilJNA - #3159
Conversation
Remove JaCoCo excludes for common, driver, and Abstract classes so they appear in coverage reports. Add benchmark exclude. Replace blanket unix exclude with granular excludes for untested platforms (aix, freebsd, openbsd, solaris). Extract static helper methods from Dxgi (JNA mapping) to new DxgiUtilJNA in oshi.util.gpu so they are visible to coverage. Rename AdlUtil to AdlUtilJNA for consistency.
📝 WalkthroughWalkthroughThis PR refactors Windows GPU utility classes by extracting utility methods from JNA platform classes into dedicated utility classes, renaming ADL utility from Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pom.xml`:
- Around line 811-814: The coverage exclude pattern **/unix/*Bsd* is too broad
and unintentionally excludes shared helper BsdNetworkIF.java; remove that
specific pattern from the excludes list and keep the existing platform-specific
excludes (**/unix/freebsd/**, **/unix/openbsd/** and the file-level patterns
**/unix/*FreeBsd*, **/unix/*OpenBsd*) so only actual FreeBSD/OpenBSD
implementations remain excluded and BsdNetworkIF stays covered.
🪄 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: e1e02a05-b9f7-407c-b43c-cb5028d575e1
📒 Files selected for processing (8)
oshi-core/src/main/java/oshi/driver/windows/DxgiAdapterInfo.javaoshi-core/src/main/java/oshi/hardware/platform/windows/WindowsGpuStats.javaoshi-core/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCard.javaoshi-core/src/main/java/oshi/jna/platform/windows/Dxgi.javaoshi-core/src/main/java/oshi/util/gpu/AdlUtilJNA.javaoshi-core/src/main/java/oshi/util/gpu/DxgiUtilJNA.javaoshi-core/src/test/java/oshi/util/gpu/DxgiUtilTest.javapom.xml
📜 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). (12)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 11, windows-latest
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
- GitHub Check: Test JDK 11, macos-latest
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 11, ubuntu-latest
- GitHub Check: Test JDK 21, ubuntu-latest
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (3)
📚 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/util/gpu/AdlUtilJNA.java
📚 Learning: 2026-04-11T05:51:49.185Z
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:49.185Z
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/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCard.javaoshi-core/src/main/java/oshi/hardware/platform/windows/WindowsGpuStats.javaoshi-core/src/test/java/oshi/util/gpu/DxgiUtilTest.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/WindowsGraphicsCard.javaoshi-core/src/main/java/oshi/hardware/platform/windows/WindowsGpuStats.java
🔇 Additional comments (8)
pom.xml (1)
803-810: Coverage-scope update looks aligned with the stated intent.Adding benchmark and platform-targeted Unix excludes while keeping shared areas in scope is a good direction for more meaningful JaCoCo reporting.
Also applies to: 815-815
oshi-core/src/main/java/oshi/util/gpu/AdlUtilJNA.java (1)
44-46: Rename is consistent and safe.Type name, logger binding, and private constructor were updated coherently with no behavioral drift.
Also applies to: 89-89
oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsGpuStats.java (1)
205-206: ADL backend migration is clean and behavior-preserving.Delegation to
AdlUtilJNAkeeps the same availability checks, cached index lookup, and sentinel-based fallback flow.Also applies to: 225-226, 249-250, 270-271, 291-292, 353-357
oshi-core/src/main/java/oshi/driver/windows/DxgiAdapterInfo.java (1)
13-14: Javadoc reference update is correct.The link now points to the current DXGI binding entry point.
oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCard.java (1)
140-140: DXGI utility extraction is wired consistently across paths.All key operations (enumeration, matching, normalization, VRAM conversion) now route through
DxgiUtilJNAin both main and fallback flows.Also applies to: 191-191, 218-219, 264-264, 311-311, 326-327, 365-365
oshi-core/src/test/java/oshi/util/gpu/DxgiUtilTest.java (1)
5-5: Test migration looks complete for the extracted utility API.The suite now validates
DxgiUtilJNAmatching, normalization, VRAM conversion, and adapter enumeration behavior.Also applies to: 23-23, 37-37, 51-51, 64-64, 75-75, 81-81, 92-92, 102-103, 107-108, 112-113, 122-123, 128-129, 135-136, 140-141, 150-150
oshi-core/src/main/java/oshi/jna/platform/windows/Dxgi.java (1)
49-52: Class rename updates are internally consistent.
Dxgitype, logger binding, and constructor naming align cleanly.Also applies to: 60-60
oshi-core/src/main/java/oshi/util/gpu/DxgiUtilJNA.java (1)
18-31: New utility extraction is cohesive and correctly scoped.The helper methods are cleanly centralized and match how callers/tests now consume DXGI-related logic.
Also applies to: 53-73, 82-97, 105-110
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3159 +/- ##
============================================
- Coverage 56.31% 56.06% -0.26%
============================================
Files 212 362 +150
Lines 13491 20222 +6731
Branches 2195 3307 +1112
============================================
+ Hits 7598 11337 +3739
- Misses 4739 7287 +2548
- Partials 1154 1598 +444
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:
|
JaCoCo exclude changes
Remove excludes that were hiding tested code from coverage reports:
**/common/**- oshi-common classes now have direct tests**/driver/**- driver classes are exercised by platform tests**/Abstract*- abstract base classes are tested via subclassesAdd new exclude:
**/benchmark/**- benchmark harness code, not production logicReplace blanket
**/unix/**exclude with granular excludes for platforms with limited CI coverage:**/unix/aix/**,**/unix/freebsd/**,**/unix/openbsd/**,**/unix/solaris/****/unix/*Aix*,**/unix/*Bsd*,**/unix/*FreeBsd*,**/unix/*OpenBsd*,**/unix/*Solaris***/unix/UnixBaseboard*This preserves coverage for shared unix classes used on macOS (e.g. UnixPrinter, Cups).
DxgiUtilJNA extraction
Extract four static helper methods from the JNA mapping class
Dxgi(formerlyWindowsDxgi) to newDxgiUtilJNAinoshi.util.gpuso they are visible to JaCoCo (**/jna/**is excluded):queryAdapters()(delegates toDxgi)findMatch()registryValueToVram()normalizeName()Rename
AdlUtiltoAdlUtilJNAfor consistency withNvmlUtilJNAandDxgiUtilJNA.Summary by CodeRabbit
Refactor
Tests