Repository navigation
Decode macOS IORegistry byte properties as NUL-terminated on both backends - #3579
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
🚧 Files skipped from review as they are similar to previous changes (9)
📜 Recent review details⏰ Context from checks skipped due to timeout. (10)
📝 WalkthroughWalkthroughThe change adds ChangesNUL-terminated string decoding
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 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
📒 Files selected for processing (12)
CHANGELOG.mdoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacBaseboard.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.javaoshi-common/src/main/java/oshi/util/ParseUtil.javaoshi-common/src/test/java/oshi/util/ParseUtilTest.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCardFFM.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.javaoshi-core/src/main/java/oshi/jna/platform/windows/Adl.javaoshi-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: Keeposhi-commonpure Java: do not reference JNA, FFM (java.lang.foreign), orSystem.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, checkoshi.util.ParseUtil; use its existing parsing methods or add shared primitives there rather than duplicating parsers in platform drivers.
Read runtime configuration fromoshi-common/src/main/resources/oshi.propertiesthroughGlobalConfigor Java system properties; do not introduce a separate configuration mechanism.
Files:
oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.javaoshi-common/src/main/java/oshi/util/ParseUtil.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.javaoshi-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.javaoshi-core/src/main/java/oshi/jna/platform/windows/Adl.javaoshi-common/src/main/java/oshi/util/ParseUtil.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.javaoshi-core/src/main/java/oshi/util/gpu/AdlUtilJNA.javaoshi-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 asInteger.parseInt,Long.parseLong,Double.parseDouble, orInteger.decode; use the corresponding tolerantParseUtilmethods.
Do not importorg.slf4j.event.**; useoshi.util.LogLevelinstead.
Files:
oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.javaoshi-core/src/main/java/oshi/jna/platform/windows/Adl.javaoshi-common/src/main/java/oshi/util/ParseUtil.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCardFFM.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.javaoshi-common/src/test/java/oshi/util/ParseUtilTest.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.javaoshi-core/src/main/java/oshi/util/gpu/AdlUtilJNA.javaoshi-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 withconfig/import-control.xml, the module'smodule-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 withoshi.util.Memoizer.memoize, generally using aSupplier<T>anddefaultExpiration()when refresh is required.
Do not duplicate non-native logic between platform implementations; hoist parsing, conversion, filtering, caching, validation, and sentinel handling intooshi-commonwhere possible.
Files:
oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.javaoshi-core/src/main/java/oshi/jna/platform/windows/Adl.javaoshi-common/src/main/java/oshi/util/ParseUtil.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCardFFM.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.javaoshi-core/src/main/java/oshi/util/gpu/AdlUtilJNA.javaoshi-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.javaoshi-core/src/main/java/oshi/jna/platform/windows/Adl.javaoshi-common/src/main/java/oshi/util/ParseUtil.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCardFFM.javaCHANGELOG.mdoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.javaoshi-common/src/test/java/oshi/util/ParseUtilTest.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.javaoshi-core/src/main/java/oshi/util/gpu/AdlUtilJNA.javaoshi-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-coreimplementation, apply the equivalent behavior change to its correspondingoshi-core-ffmtwin, or explain why the implementations intentionally differ.
Files:
oshi-core/src/main/java/oshi/jna/platform/windows/Adl.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.javaoshi-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 anoshi-core-ffmimplementation, apply the equivalent behavior change to its correspondingoshi-coretwin, or explain why the implementations intentionally differ.
Do not referencecom.sun.jnafrom FFM implementation sources.
Files:
oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCardFFM.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.java
CHANGELOG.md
📄 CodeRabbit inference engine (AGENTS.md)
Add a
Next Releasechangelog 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.javaoshi-common/src/main/java/oshi/util/ParseUtil.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.javaoshi-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.javaoshi-core/src/main/java/oshi/jna/platform/windows/Adl.javaoshi-common/src/main/java/oshi/util/ParseUtil.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCardFFM.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.javaoshi-core/src/main/java/oshi/util/gpu/AdlUtilJNA.javaoshi-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.javaoshi-core/src/main/java/oshi/jna/platform/windows/Adl.javaoshi-common/src/main/java/oshi/util/ParseUtil.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCardFFM.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.javaoshi-core/src/main/java/oshi/util/gpu/AdlUtilJNA.javaoshi-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.javaoshi-core/src/main/java/oshi/jna/platform/windows/Adl.javaoshi-common/src/main/java/oshi/util/ParseUtil.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCardFFM.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.javaoshi-common/src/test/java/oshi/util/ParseUtilTest.javaoshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmwareJNA.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacFirmwareFFM.javaoshi-core/src/main/java/oshi/util/gpu/AdlUtilJNA.javaoshi-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.javaoshi-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 CorrectnessNo change needed. The JNA implementation already keeps
remainingDxgiavailable 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.
a9985d2 to
ee3b9cd
Compare
Codecov Report❌ Patch coverage is 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…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.
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.toUtf8did:which strips every NUL rather than stopping at the first.
MacFirmwareJNAusedNative.toString(byte[], Charset), which stops at the first NUL and does not trim. Verified against real JNA 5.18:"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 sharedoshi-commonclasses —MacBaseboard,MacComputerSystem,MacCentralProcessor— carried the same strip-all-NULs code, affecting both backends.Changes
ParseUtil.decodeNulTerminated(byte[], Charset), matchingNative.toString(byte[], Charset)'s semantics (and additionally null- and empty-tolerant, returning""), with unit tests.MacFirmwareFFM,MacFirmwareJNA,MacBaseboard,MacComputerSystem, andMacCentralProcessor. Both twins now call the same code for this decode rather than reimplementing it, so they cannot drift apart again.AixOSProcess.nulTerminatedToString, whose javadoc said it mirroredNative.toString(byte[])and whose body is identical to the new method.MacFirmwareJNAgives up nothing by droppingNative.toString. Per JNA's own source (Native.java:453) thebyte[]overload is pure Java — a scan for NUL plus aStringconstructor, no JNI transition. It is the pointer overloads that read native memory, and none were used here: every call site receives abyte[]thatIOKit.getByteArrayPropertyalready copied out of native memory viap.getByteArray(0, length).MacCentralProcessor.ioRegStringis deliberately left alone — it maps NUL to a space to keep the multi-stringcompatibleproperty'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) plusjavadoc:javadoc.oshi.SystemInfoTestandoshi.ffm.SystemInfoTestproduce byte-identical firmware/baseboard/computer-system output, andNativeComparisonTestpassescomputerSystemandfirmware. 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