Skip to content

Decode macOS IORegistry byte properties as NUL-terminated on both backends - #3579

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:hoist-nul-terminated-decode
Aug 4, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:hoist-nul-terminated-decode

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Aug 4, 2026 •

Copy link
Copy Markdown
Member

Summary

macOS IORegistry byte properties are C strings NUL-terminated inside a fixed-width buffer, and a single property may hold several NUL-separated strings. The JNA and FFM backends disagreed on how to decode them.

MacFirmwareFFM.toUtf8 did:

return new String(data, StandardCharsets.UTF_8).trim().replace("\0", "");

which strips every NUL rather than stopping at the first. MacFirmwareJNA used Native.toString(byte[], Charset), which stops at the first NUL and does not trim. Verified against real JNA 5.18:

input JNA FFM
"apple,t8103\0arm,v8\0" "apple,t8103" "apple,t8103arm,v8"
" EFI \0" " EFI " "EFI"

So a multi-string property came back with its entries concatenated, and the trim() discarded significant leading/trailing spaces. Three shared oshi-common classes — MacBaseboard, MacComputerSystem, MacCentralProcessor — carried the same strip-all-NULs code, affecting both backends.

Changes

  • Add ParseUtil.decodeNulTerminated(byte[], Charset), matching Native.toString(byte[], Charset)'s semantics (and additionally null- and empty-tolerant, returning ""), with unit tests.
  • Decode through it in MacFirmwareFFM, MacFirmwareJNA, MacBaseboard, MacComputerSystem, and MacCentralProcessor. Both twins now call the same code for this decode rather than reimplementing it, so they cannot drift apart again.
  • Delete AixOSProcess.nulTerminatedToString, whose javadoc said it mirrored Native.toString(byte[]) and whose body is identical to the new method.

MacFirmwareJNA gives up nothing by dropping Native.toString. Per JNA's own source (Native.java:453) the byte[] overload is pure Java — a scan for NUL plus a String constructor, no JNI transition. It is the pointer overloads that read native memory, and none were used here: every call site receives a byte[] that IOKit.getByteArrayProperty already copied out of native memory via p.getByteArray(0, length).

MacCentralProcessor.ioRegString is deliberately left alone — it maps NUL to a space to keep the multi-string compatible property's entries separated, which is a different operation.

Verification

Tested on macOS (Mac15,7, Apple M3 Pro). Full gate green: clean spotless:apply sortpom:sort checkstyle:check install forbiddenapis:check (0 tests failed across all modules) plus javadoc:javadoc. oshi.SystemInfoTest and oshi.ffm.SystemInfoTest produce byte-identical firmware/baseboard/computer-system output, and NativeComparisonTest passes computerSystem and firmware. Fork CI green on macOS and Linux.

This machine's IORegistry does not happen to expose a multi-string or space-padded value on the affected properties, so the divergence table above is from a direct behavior test against JNA rather than from live hardware.

Summary by CodeRabbit

  • Bug Fixes
    • Improved macOS hardware, firmware, and platform information decoding.
    • Fixed handling of NUL-terminated system strings, including EFI and IORegistry data.
    • Improved AIX process command-line and executable-name decoding.
  • Tests
    • Added coverage for padded, empty, missing, and multi-string NUL-terminated values.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2dfe3153-c6d9-41ff-8f61-6c2a29444a0b

📥 Commits

Reviewing files that changed from the base of the PR and between a9985d2 and ee3b9cd.

📒 Files selected for processing (9)
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.java
🚧 Files skipped from review as they are similar to previous changes (9)
  • CHANGELOG.md
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java
  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.java
📜 Recent review details
⏰ Context from checks skipped due to timeout. (10)
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 26, ubuntu-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Analyze (java)

📝 Walkthrough

Walkthrough

The change adds ParseUtil.decodeNulTerminated and replaces local byte-array string conversion in macOS hardware, FFM, JNA, and AIX process code. Tests cover terminators, padding, empty input, null input, and alternate character sets.

Changes

NUL-terminated string decoding

Layer / File(s) Summary
Shared decoder contract and validation
oshi-common/src/main/java/oshi/util/ParseUtil.java, oshi-common/src/test/java/oshi/util/ParseUtilTest.java, CHANGELOG.md
Adds ParseUtil.decodeNulTerminated and tests its terminator, empty-input, null-input, padding, multi-string, and charset behavior.
macOS hardware property decoding
oshi-common/src/main/java/oshi/hardware/common/platform/mac/*
Uses the shared UTF-8 decoder for baseboard, processor, and computer system properties while preserving existing fallback behavior.
Firmware and process property decoding
oshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.java, oshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.java, oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.java
Uses the shared decoder for firmware and AIX process byte arrays and removes obsolete local conversion helpers.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • oshi/oshi#3437: Both changes add and adopt ParseUtil decoding helpers with corresponding tests.

Poem

A rabbit hops through bytes of snow,
Finds the first NUL, then stops the flow.
Mac strings shine, AIX paths clear,
FFM and JNA decode without fear.
Shared utility, tidy and bright—
Thump, thump, the strings read right!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 31.25% 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 clearly and concisely describes the main change: NUL-terminated decoding for macOS IORegistry byte properties in both backends.
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.
✨ 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCardFFM.java`:
- Around line 157-159: Update the graphics-card discovery flow around the
registry result check and getGraphicsCardsFromWmi so the WMI fallback also runs
when remainingDxgi contains adapters after partial registry success, not only
when result is empty. Merge fallback cards for unconsumed adapters into result
while preserving existing ordering and deduplication behavior.
🪄 Autofix

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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 52854257-b364-47b2-8954-ad77268aa200

📥 Commits

Reviewing files that changed from the base of the PR and between 74b015c and a9985d2.

📒 Files selected for processing (12)
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCardFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.java
  • oshi-core/src/main/java/oshi/jna/platform/windows/Adl.java
  • oshi-core/src/main/java/oshi/util/gpu/AdlUtilJNA.java
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Codacy Static Code Analysis
⚠️ CI failures not shown inline (1)

Commit Status: continuous-integration/appveyor/pr: continuous-integration/appveyor/pr

Conclusion: failure

AppVeyor was unable to build non-mergeable pull request
🧰 Additional context used
📓 Path-based instructions (10)
oshi-common/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

oshi-common/src/main/java/**/*.java: Keep oshi-common pure Java: do not reference JNA, FFM (java.lang.foreign), or System.load/loadLibrary; place parsing, conversion, validation, caching, and shared implementation logic here when it is not native-API-specific.
Before adding a general parsing helper, check oshi.util.ParseUtil; use its existing parsing methods or add shared primitives there rather than duplicating parsers in platform drivers.
Read runtime configuration from oshi-common/src/main/resources/oshi.properties through GlobalConfig or Java system properties; do not introduce a separate configuration mechanism.

Files:

  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.java
{oshi-common,oshi-core}/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

Use Java 8 language and API compatibility: do not use var, records, switch expressions, text blocks, List.of, Stream.toList(), or other post-Java-8 features.

Files:

  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.java
  • oshi-core/src/main/java/oshi/jna/platform/windows/Adl.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.java
  • oshi-core/src/main/java/oshi/util/gpu/AdlUtilJNA.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.java
**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

**/*.java: Do not use banned numeric parsing APIs such as Integer.parseInt, Long.parseLong, Double.parseDouble, or Integer.decode; use the corresponding tolerant ParseUtil methods.
Do not import org.slf4j.event.**; use oshi.util.LogLevel instead.

Files:

  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.java
  • oshi-core/src/main/java/oshi/jna/platform/windows/Adl.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCardFFM.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.java
  • oshi-core/src/main/java/oshi/util/gpu/AdlUtilJNA.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.java
**/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

**/src/main/java/**/*.java: Keep external imports synchronized with config/import-control.xml, the module's module-info.java, and, when necessary, its Maven configuration.
Provide Javadoc for every public and protected type and method; use imported simple class names rather than fully qualified names in code and Javadoc links.
Use the repository's concurrency annotation (@ThreadSafe, @Immutable, @NotThreadSafe, or @GuardedBy) on new classes, matching the modeled class where appropriate.
Memoize constant or expensive, slowly changing system values with oshi.util.Memoizer.memoize, generally using a Supplier<T> and defaultExpiration() when refresh is required.
Do not duplicate non-native logic between platform implementations; hoist parsing, conversion, filtering, caching, validation, and sentinel handling into oshi-common where possible.

Files:

  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.java
  • oshi-core/src/main/java/oshi/jna/platform/windows/Adl.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCardFFM.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.java
  • oshi-core/src/main/java/oshi/util/gpu/AdlUtilJNA.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.java
**/*.{java,xml,properties,md}

📄 CodeRabbit inference engine (AGENTS.md)

Do not commit generated output, target/, or IDE files.

Files:

  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.java
  • oshi-core/src/main/java/oshi/jna/platform/windows/Adl.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCardFFM.java
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.java
  • oshi-core/src/main/java/oshi/util/gpu/AdlUtilJNA.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.java
oshi-core/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

For changes to an oshi-core implementation, apply the equivalent behavior change to its corresponding oshi-core-ffm twin, or explain why the implementations intentionally differ.

Files:

  • oshi-core/src/main/java/oshi/jna/platform/windows/Adl.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.java
  • oshi-core/src/main/java/oshi/util/gpu/AdlUtilJNA.java
oshi-core-ffm/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

oshi-core-ffm/src/main/java/**/*.java: For changes to an oshi-core-ffm implementation, apply the equivalent behavior change to its corresponding oshi-core twin, or explain why the implementations intentionally differ.
Do not reference com.sun.jna from FFM implementation sources.

Files:

  • oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCardFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.java
CHANGELOG.md

📄 CodeRabbit inference engine (AGENTS.md)

Add a Next Release changelog entry only for user-visible changes; omit pure refactors, deduplication, test-only changes, and CI configuration changes.

Files:

  • CHANGELOG.md
**/src/test/java/**/*Test.java

📄 CodeRabbit inference engine (AGENTS.md)

Write tests against parsing and transformation methods using fixture data; keep acquisition methods thin. Do not add Mockito, and use JUnit 5 with Hamcrest.

Files:

  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
**/*Test.java

📄 CodeRabbit inference engine (AGENTS.md)

Test hardware-dependent behavior using invariants, plausible ranges, correct types, and ordering rather than fixed machine-specific values; treat zero and empty results as valid where applicable.

Files:

  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
🧠 Learnings (7)
📚 Learning: 2026-04-12T19:22:09.716Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:22:09.716Z
Learning: When reviewing OSHI hardware platform code that uses or implements `CentralProcessor`/`PhysicalProcessor.getEfficiency()`, remember the API’s counterintuitive semantics: a *higher* efficiency-class value indicates *greater performance* (lower efficiency). P-cores/“performance cores” should therefore have higher values (e.g., 1) than E-cores/“efficiency cores” (e.g., 0), as documented in the `CentralProcessor` Javadoc. Do not flag code as incorrect solely because ARM_P_CORES or Intel P-cores are assigned higher efficiency values.

Applied to files:

  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.java
📚 Learning: 2026-07-06T19:25:59.225Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:25:59.225Z
Learning: In this repo’s SLF4J 1.x-compatible logging code, do not flag cases where a logger call uses SLF4J 1.6+ implicit-cause handling—e.g., `log.error("...{}", value, t)` (or similar with a single `{}` placeholder) where `t` is passed as the final/trailing argument. SLF4J will attach `t` as the log event’s cause with the full stack trace; this is equivalent to SLF4J 2.x’s fluent `atLevel(...).setCause(t).log(...)` and is intentionally used to preserve SLF4J 1.x runtime compatibility.

Applied to files:

  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.java
  • oshi-core/src/main/java/oshi/jna/platform/windows/Adl.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCardFFM.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.java
  • oshi-core/src/main/java/oshi/util/gpu/AdlUtilJNA.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.java
📚 Learning: 2026-07-30T00:35:22.638Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3547
File: oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdFirmware.java:82-82
Timestamp: 2026-07-30T00:35:22.638Z
Learning: In OSHI, treat changes as “API-breaking” only when they affect classes (or relevant API surface) annotated with `PublicAPI`. Public classes/members that are not annotated with `PublicAPI` should be reviewed as internal implementation details, even if they are public (e.g., classes like `oshi.hardware.common.platform.unix.BsdFirmware`). Also, respect intentional visibility decisions used for tests—e.g., methods like `BsdFirmware.parseDmesg(List<String>)` may be intentionally package-private to support tests within the same package; avoid widening visibility or altering signatures unless the related `PublicAPI` contract requires it.

Applied to files:

  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.java
  • oshi-core/src/main/java/oshi/jna/platform/windows/Adl.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCardFFM.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.java
  • oshi-core/src/main/java/oshi/util/gpu/AdlUtilJNA.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.java
📚 Learning: 2026-08-03T00:46:14.953Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3566
File: oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdNetworkParams.java:18-22
Timestamp: 2026-08-03T00:46:14.953Z
Learning: In the OSHI Java codebase, do not require duplicate Javadoc on public methods annotated with Override when the inherited Javadoc from the parent declaration adequately documents the method. The general public-member Javadoc requirement should not flag these overrides solely because they lack redundant documentation.

Applied to files:

  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.java
  • oshi-core/src/main/java/oshi/jna/platform/windows/Adl.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCardFFM.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.java
  • oshi-core/src/main/java/oshi/util/gpu/AdlUtilJNA.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.java
📚 Learning: 2026-08-02T23:56:23.866Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3565
File: oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/PosixLibcFunctions.java:51-56
Timestamp: 2026-08-02T23:56:23.866Z
Learning: For Java FFM bindings in the oshi-core-ffm module, assume a 64-bit JVM and 64-bit operating system. Do not flag 32-bit native ABI or memory-layout compatibility concerns, consistent with the project's JDK 25 support policy, unless that policy changes.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCardFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.java
📚 Learning: 2026-04-12T19:34:56.879Z
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:56.879Z
Learning: In OSHI’s Java platform implementations, `PhysicalProcessor.getEfficiency()` / `EfficiencyClass` follow the same convention as Windows `PROCESSOR_RELATIONSHIP.EfficiencyClass`: a *higher* numeric efficiency class value represents *greater performance* and *less efficiency* (typically P-cores higher than E-cores). When reviewing, do not treat cases where P-cores are assigned higher efficiency/class values as a bug—this is intentional cross-platform consistency.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.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/mac/MacFirmwareJNA.java
🔇 Additional comments (12)
oshi-common/src/main/java/oshi/util/ParseUtil.java (1)

1602-1621: LGTM!

oshi-common/src/test/java/oshi/util/ParseUtilTest.java (1)

1067-1091: LGTM!

oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.java (1)

15-15: LGTM!

Also applies to: 68-74, 89-90

oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java (1)

158-158: LGTM!

oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.java (1)

15-15: LGTM!

Also applies to: 70-72

oshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.java (1)

15-15: LGTM!

Also applies to: 48-71, 89-101

oshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.java (1)

16-16: LGTM!

Also applies to: 50-73, 95-107

oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.java (1)

159-163: LGTM!

CHANGELOG.md (1)

14-15: LGTM!

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

157-159: 🎯 Functional Correctness

No change needed. The JNA implementation already keeps remainingDxgi available for WMI fallback when no card is constructed.

oshi-core/src/main/java/oshi/jna/platform/windows/Adl.java (1)

13-13: LGTM!

Also applies to: 23-23

oshi-core/src/main/java/oshi/util/gpu/AdlUtilJNA.java (1)

94-94: LGTM!

Also applies to: 144-156, 186-198, 319-320, 334-336

…kends

IORegistry byte properties are C strings NUL-terminated inside a
fixed-width buffer, and may hold several NUL-separated strings in one
property. The FFM firmware path decoded them with

    new String(data, UTF_8).trim().replace("\0", "")

which strips every NUL rather than stopping at the first, so a
multi-string property came back with its entries concatenated
("apple,t8103\0arm,v8\0" -> "apple,t8103arm,v8"), and the trim discarded
significant leading and trailing spaces (" EFI \0" -> "EFI"). The JNA
twin used Native.toString(byte[], Charset), which stops at the first NUL
and does not trim. Three shared oshi-common classes carried the same
strip-all-NULs code as the FFM path.

Add ParseUtil.decodeNulTerminated, matching Native.toString's semantics
(and additionally null-tolerant), and decode through it everywhere:
MacFirmwareFFM, MacFirmwareJNA, MacBaseboard, MacComputerSystem, and
MacCentralProcessor. Both twins now share the decode rather than
reimplementing it, so they cannot drift again.

Also replaces AixOSProcess.nulTerminatedToString, whose javadoc said it
mirrored Native.toString(byte[]) and whose body is identical to the new
method.

MacCentralProcessor.ioRegString is deliberately left alone: it maps NUL
to a space to keep the multi-string "compatible" property's entries
separated, which is not the same operation.
@dbwiddis
dbwiddis force-pushed the hoist-nul-terminated-decode branch from a9985d2 to ee3b9cd Compare August 4, 2026 20:34
@codecov

codecov Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 54.54545% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.96%. Comparing base (74b015c) to head (ee3b9cd).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ava/oshi/hardware/platform/mac/MacFirmwareFFM.java 37.50% 5 Missing ⚠️
...ava/oshi/hardware/platform/mac/MacFirmwareJNA.java 37.50% 5 Missing ⚠️
...ardware/common/platform/mac/MacComputerSystem.java 0.00% 0 Missing and 2 partials ⚠️
...oshi/software/common/os/unix/aix/AixOSProcess.java 0.00% 2 Missing ⚠️
...dware/common/platform/mac/MacCentralProcessor.java 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3579      +/-   ##
============================================
- Coverage     80.00%   79.96%   -0.05%     
- Complexity       76      200     +124     
============================================
  Files           709      709              
  Lines         24206    24205       -1     
  Branches       4048     4048              
============================================
- Hits          19367    19355      -12     
- Misses         2688     2697       +9     
- Partials       2151     2153       +2     
Flag Coverage Δ
freebsd 33.49% <18.18%> (+0.03%) ⬆️
linux 37.60% <18.18%> (+0.02%) ⬆️
macos 38.42% <54.54%> (-0.03%) ⬇️
openbsd 32.68% <18.18%> (+0.04%) ⬆️
solaris 34.17% <18.18%> (+0.03%) ⬆️
windows 45.38% <18.18%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dbwiddis
dbwiddis merged commit bf7f178 into oshi:master Aug 4, 2026
17 checks passed
@dbwiddis
dbwiddis deleted the hoist-nul-terminated-decode branch August 4, 2026 20:42
dbwiddis added a commit that referenced this pull request Aug 4, 2026
…tor (#3581)

HERTZ_PATTERN's decimals group is "(.\d+)?" with an unescaped dot, so it
matches any separator, not a decimal point. A frequency written with a
comma -- which a localized string can carry -- put "2,40" in the value
group, and Double.valueOf then threw NumberFormatException out of a method
documented to return -1 when it cannot parse. parseHertz is reached from
ProcessorIdentifier's vendor frequency, MacGlobalMemory's speed, and the
Linux, NetBSD, OpenBSD and AIX CPU frequency parsers, all of which read
strings OSHI does not control.

Parse through ParseUtil.parseDoubleOrDefault, the existing soft-fail
helper, and require the unit multiplier to be positive rather than
inferring failure from a negative product.

The unescaped dot is left as is, and a comment now says why: matching any
separator pulls the malformed number into the value group whole, where the
parse fails and the documented -1 is returned. Escaping it looks like a
cleanup but is a regression -- the match re-anchors on a fragment, so
"2 40GHz" is reported as a 40 GHz processor and "2X00MHz" as 0 rather than
as unparseable. The inline comment claiming the pattern made a
NumberFormatException impossible was simply wrong, and is gone.

testParseHertzNonDecimalSeparator covers the comma, space and letter
separators along with the decimal cases that must keep working. It fails
both ways: restoring Double.valueOf throws, and escaping the dot returns
40000000000.

Also narrows the #3579 changelog entry. It claimed the macOS FFM strings
were mangled; probing every affected field on an Apple Silicon host before
and after that change gives byte-identical output, because those fields are
single-string and unpadded there. The entry now says it aligns the backends
and describes the conditions under which the old decode would corrupt.
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