Skip to content

Wire Error Prone into the build as groundwork for jSpecify - #3594

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:error-prone-groundwork
Aug 12, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:error-prone-groundwork

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Aug 12, 2026 •

Copy link
Copy Markdown
Member

Summary

Groundwork for the jSpecify nullability-annotations proposal, without adding any @Nullable/@NonNull markers yet. NullAway — the Error Prone check that will eventually enforce jSpecify annotations — requires Error Prone as its host platform, so this PR wires Error Prone into the build now so any pre-existing findings can be triaged ahead of the follow-on jSpecify/NullAway PR.

  • Adds an opt-in error-prone Maven profile (repo-wide, one block in the root pom.xml) that activates -Xplugin:ErrorProne via error_prone_core:2.50.0. Not active on a normal build.
  • Adds .mvn/jvm.config with the --add-exports/--add-opens JPMS flags Error Prone's in-process javac plugin needs (JEP 396).
  • Excludes annotation-processor-generated sources (-XepExcludedPaths) so findings in JMH's auto-generated benchmark harness (not code we own) don't show up.
  • Disables InlineMeSuggester/DoNotCallSuggester — they suggest Google-specific @InlineMe/@DoNotCall annotations this project doesn't use.
  • Fixes a real wiring bug in oshi-benchmark/pom.xml: its own annotationProcessorPaths (for JMH's processor) was silently replacing rather than merging with the profile's error_prone_core path; fixed with combine.children="append".
  • Splits the CI lint job into lint-format (Spotless/Checkstyle) and lint-verify (ForbiddenAPIs/SLF4J), since it was growing long, and swaps javadoc:javadoc for the stricter release-profile javadoc check (-Prelease install -Dgpg.skip=true) that RELEASING.md notes catches unresolved {@link}s the normal gate tolerates — this project has been bitten by javadoc errors that only surfaced at release:perform time.
  • Adds a new error-prone CI job, informational only (continue-on-error: true) — nothing here blocks the PR check yet, including the small number of real ERROR-severity findings the tool already surfaced (BanJNDI, MemorySegmentReferenceEquality, ReturnValueIgnored). No fixing in this PR; that's follow-on work.

No CHANGELOG entry — pure CI/build tooling, no user-visible change.

Next steps (follow-on PRs, not this one)

  1. Fix the small set of real ERROR-severity findings and drop continue-on-error: true, so ERROR-severity findings block (javac's own default) while WARNING-severity findings stay non-blocking for ongoing triage.
  2. Add org.jspecify:jspecify + com.uber.nullaway:nullaway, start marking packages @NullMarked beginning with oshi-common's shared interfaces/abstract classes, then push outward to oshi-core/oshi-core-ffm keeping twins in sync.
  3. Batch-fix the remaining WARNING-severity backlog (~200 findings, mostly StringSplitter, MissingSummary, EnumOrdinal, MixedMutabilityReturnType), by module or by check.

Test plan

  • ./mvnw clean install -DskipTests (no profile) — unaffected, confirms Error Prone stays fully opt-in
  • ./mvnw clean install -DskipTests -Perror-prone -fn (whole reactor) — plugin activates on every module, findings are real code (not generated sources), no false "plug-in not found" errors
  • ./mvnw -Prelease install -DskipTests -Dgpg.skip=true — succeeds without a signing key, produces *-javadoc.jar/*-sources.jar for every module
  • ./mvnw clean spotless:apply sortpom:sort checkstyle:check install forbiddenapis:check javadoc:javadoc — full gate passes, no reformatting needed
  • .github/workflows/pr.yaml parses as valid YAML

Summary by CodeRabbit

  • Quality Improvements

    • Added optional Error Prone static analysis for detecting potential Java issues.
    • Improved validation coverage for formatting, style, forbidden APIs, release compatibility, and SLF4J usage.
    • Added compiler configuration required for broader Java analysis compatibility.
  • Build Improvements

    • Preserved inherited annotation processors while adding benchmark-specific processors.
    • Streamlined documentation validation through the release build profile.

NullAway, the Error Prone check that will enforce jSpecify nullability
annotations once they land, requires Error Prone as its host platform.
This adds Error Prone behind an opt-in, non-blocking error-prone
profile/CI job so pre-existing findings can be triaged ahead of next
week's jSpecify/NullAway PR, and splits the lint job into parallel
jobs so static analysis doesn't run as one long sequential chain.
@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The Maven build now supports opt-in Error Prone analysis with required JDK compiler access. Benchmark annotation processors append to inherited paths. Pull-request validation separates formatting, verification, and non-blocking Error Prone jobs.

Changes

Build validation

Layer / File(s) Summary
Error Prone build profile
.mvn/jvm.config, pom.xml
The root build defines the Error Prone version and profile. Maven gains access to selected jdk.compiler internals.
Annotation processor inheritance
oshi-benchmark/pom.xml
The benchmark module appends JMH processors to inherited annotation processor paths.
Pull-request validation jobs
.github/workflows/pr.yaml
The workflow separates formatting, verification, and informational Error Prone execution. Javadoc runs through release-profile installation.

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

Possibly related PRs

  • oshi/oshi#3127: Updates the benchmark annotation-processor configuration.
  • oshi/oshi#3217: Modifies Maven compiler configuration in the benchmark and root builds.

Suggested reviewers: wolfs

Poem

A rabbit reviews the compiler trail,
Where Error Prone hops without fail.
Lint paths divide, processors align,
JDK doors open in a tidy line.
CI checks sparkle, green and bright.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding Error Prone to the build to support future jSpecify integration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

@codecov

codecov Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.87%. Comparing base (d4defba) to head (eacb941).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3594      +/-   ##
============================================
- Coverage     79.93%   79.87%   -0.07%     
- Complexity     3870     4230     +360     
============================================
  Files           710      710              
  Lines         24242    24242              
  Branches       4052     4052              
============================================
- Hits          19379    19364      -15     
- Misses         2711     2729      +18     
+ Partials       2152     2149       -3     
Flag Coverage Δ
freebsd 33.50% <ø> (+<0.01%) ⬆️
linux 37.66% <ø> (+0.01%) ⬆️
macos 38.42% <ø> (-0.03%) ⬇️
openbsd 32.67% <ø> (+<0.01%) ⬆️
solaris 34.17% <ø> (+<0.01%) ⬆️
windows 45.37% <ø> (+<0.01%) ⬆️

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.

@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 `@pom.xml`:
- Around line 1219-1222: Add the ten JPMS access flags from .mvn/jvm.config to
the compilerArgs in the profile containing -XDcompilePolicy=simple, prefixing
each flag with -J so they are forwarded to the forked compiler while preserving
the existing arguments.
🪄 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: db93de13-332f-4962-b09d-f89d80064e48

📥 Commits

Reviewing files that changed from the base of the PR and between d4defba and eacb941.

📒 Files selected for processing (4)
  • .github/workflows/pr.yaml
  • .mvn/jvm.config
  • oshi-benchmark/pom.xml
  • pom.xml
📜 Review details
⏰ Context from checks skipped due to timeout. (12)
  • 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 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 26, ubuntu-latest
  • GitHub Check: Lint (ForbiddenAPIs, Javadoc, SLF4J)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle)
  • GitHub Check: Error Prone (informational)
  • GitHub Check: Analyze (java)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{java,xml}

📄 CodeRabbit inference engine (AGENTS.md)

Do not add line-range Checkstyle suppressions. Prefer declaration-level @SuppressWarnings, scoped Checkstyle comments, or file/package suppressions without line ranges; use Sonar @SuppressWarnings("java:Sxxxx") where possible and keep statement-level suppression comments short and justified.

Files:

  • pom.xml
  • oshi-benchmark/pom.xml
**/pom.xml

📄 CodeRabbit inference engine (AGENTS.md)

Do not add dependencies without discussion or manually bump dependency versions; Renovate manages dependency updates.

Files:

  • pom.xml
  • oshi-benchmark/pom.xml
🧠 Learnings (10)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:26:05.716Z
Learning: In oshi/oshi, `oshi-common/src/main/java/oshi/util/ExceptionUtil.java`'s private `logAtLevel(Logger, Level, String, Throwable)` helper (and the similar pattern in `oshi-core-ffm/src/main/java/oshi/ffm/ForeignFunctions.java` and `oshi-core/src/main/java/oshi/util/platform/windows/PerfDataUtil.java`) intentionally calls SLF4J 1.x-compatible methods like `log.error(msg, t.getMessage(), t)` with a single `{}` placeholder in `msg` and the `Throwable t` as the trailing argument. This is not a bug: SLF4J's implicit-cause handling (since 1.6.0) detects a trailing `Throwable` argument and attaches it as the log event's cause with full stack trace, equivalent to the SLF4J 2.x-only `.atLevel(level).setCause(t).log(...)` fluent API that this PR deliberately avoids for SLF4J 1.x runtime compatibility. Do not flag these calls as losing the throwable cause/stack trace.
📚 Learning: 2026-08-05T23:44:09.936Z
Learnt from: CR
Repo: oshi/oshi PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-08-05T23:44:09.936Z
Learning: Applies to **/src/main/java/module-info.java : Keep external imports consistent with `config/import-control.xml` and the module's `module-info.java`; adding an external dependency may also require updating the module POM.

Applied to files:

  • .mvn/jvm.config
  • pom.xml
📚 Learning: 2026-08-05T23:44:09.936Z
Learnt from: CR
Repo: oshi/oshi PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-08-05T23:44:09.936Z
Learning: Applies to **/src/test/java/module-info.test : When adding a test package not already used, add the corresponding `--add-opens` entry to that module's `module-info.test`; use the correct module name for the module under test.

Applied to files:

  • .mvn/jvm.config
📚 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:

  • .mvn/jvm.config
📚 Learning: 2026-08-05T23:44:09.936Z
Learnt from: CR
Repo: oshi/oshi PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-08-05T23:44:09.936Z
Learning: Applies to **/*.{java,md} : When changing a JNA or FFM implementation, apply the equivalent behavior change to its counterpart, or document why the implementations intentionally differ; prefer hoisting non-native-specific logic into `oshi-common`.

Applied to files:

  • oshi-benchmark/pom.xml
📚 Learning: 2026-07-26T23:06:49.011Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3530
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:43-48
Timestamp: 2026-07-26T23:06:49.011Z
Learning: In the oshi/oshi repository, `oshi.util.ExceptionUtil` is intentionally outside the binary-compatibility surface: japicmp enforces compatibility only for types annotated `oshi.annotation.PublicApi`, and `ExceptionUtil` is not annotated. Therefore, do not flag in-place public method descriptor changes in `ExceptionUtil` merely because precompiled third-party callers could receive `NoSuchMethodError`; source compatibility and lockstep module releases are the applicable expectations. If this guarantee is desired later, annotating `ExceptionUtil` with `PublicApi` is the policy mechanism rather than adding numerous forwarding overloads.

Applied to files:

  • oshi-benchmark/pom.xml
📚 Learning: 2026-08-05T23:44:09.936Z
Learnt from: CR
Repo: oshi/oshi PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-08-05T23:44:09.936Z
Learning: Applies to oshi-common/src/main/java/**/*.java : Keep `oshi-common` pure Java 8: do not reference JNA, FFM, `System.load`, or `System.loadLibrary`; shared parsing, conversion, filtering, caching, and sentinel/range logic belongs here.

Applied to files:

  • oshi-benchmark/pom.xml
📚 Learning: 2026-08-05T23:44:09.936Z
Learnt from: CR
Repo: oshi/oshi PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-08-05T23:44:09.936Z
Learning: Applies to oshi-common/src/main/java/**/*.java : Do not import `com.sun.jna`, `java.lang.foreign`, or use `System.load`/`System.loadLibrary` in `oshi-common`.

Applied to files:

  • oshi-benchmark/pom.xml
📚 Learning: 2026-07-21T20:38:16.728Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3509
File: oshi-demo/pom.xml:72-80
Timestamp: 2026-07-21T20:38:16.728Z
Learning: For the OSHI Maven/Jacoco CI workflows, coverage aggregation/report upload steps should run only when the test job succeeds (e.g., guard with conditions like `if: success()`). Do not add logic to generate/upload or preserve aggregate coverage artifacts after test failures, and avoid fragile/over-engineered handling of exit status unless there is an explicit separate project requirement.

Applied to files:

  • .github/workflows/pr.yaml
📚 Learning: 2026-05-31T05:53:04.246Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3311
File: .github/workflows/site.yaml:21-21
Timestamp: 2026-05-31T05:53:04.246Z
Learning: When a GitHub Actions workflow verifies that a pinned commit SHA matches a version tag, dereference annotated tags before comparing to a commit SHA. The API `GET /repos/{owner}/{repo}/git/refs/tags/{tag}` returns the tag *object* SHA for annotated tags (not the underlying commit SHA), so comparing it directly to a commit SHA will cause false mismatches. Instead: (1) fetch the tag object SHA via `GET /repos/{owner}/{repo}/git/refs/tags/{tag}`; (2) resolve that tag object to the underlying commit by calling `GET /repos/{owner}/{repo}/git/tags/{tag_object_sha}`; (3) compare the pinned commit SHA to the resolved commit at `.object.sha`.

Applied to files:

  • .github/workflows/pr.yaml
🔇 Additional comments (8)
.github/workflows/pr.yaml (3)

59-85: LGTM!


87-115: LGTM!


117-140: LGTM!

pom.xml (3)

111-114: LGTM!


1223-1227: 🎯 Functional Correctness

Verify the generated-source exclusion for test compilation.

The pattern matches target/generated-sources only. The Maven Compiler Plugin uses target/generated-test-sources/test-annotations for test-generated sources. If test annotation processors run, Error Prone will still inspect their generated code. (maven.apache.org)

If all generated sources must be excluded, use generated-(test-)?sources.

Possible pattern
-<arg>-Xplugin:ErrorProne -XepExcludedPaths:.*/target/generated-sources/.*
+<arg>-Xplugin:ErrorProne -XepExcludedPaths:.*/target/generated-(test-)?sources/.*

Source: MCP tools


1229-1235: 🗄️ Data Integrity & Integration

No annotation-processing change is needed. The configured paths cover Error Prone and JMH. Maven Compiler Plugin 3.15.0 defaults <proc> to full, so the effective compiler arguments already include -proc:full.

			> Likely an incorrect or invalid review comment.
.mvn/jvm.config (1)

1-10: 🩺 Stability & Availability

Verify the supported Maven JDK range before making these options global.

.mvn/jvm.config applies these options before Maven evaluates profiles. The root POM still activates a [1.8,16) profile. --add-exports and --add-opens belong to the JDK 9 module system and are unavailable to a JDK 8 launcher. If JDK 8 remains a supported Maven runtime, normal builds fail before -Perror-prone is selected. (openjdk.org)

Scope these options to the Error Prone invocation, or explicitly raise and document the minimum JDK for every Maven build. Verify both paths with the supported JDK matrix.

Source: MCP tools

oshi-benchmark/pom.xml (1)

126-129: LGTM!

Comment thread pom.xml Resolved
@dbwiddis
dbwiddis merged commit 7e430d8 into oshi:master Aug 12, 2026
18 checks passed
@dbwiddis
dbwiddis deleted the error-prone-groundwork branch August 12, 2026 17:24
dbwiddis added a commit that referenced this pull request Aug 13, 2026
…mary, escalate cleared checks to ERROR (#3606)

* Fix remaining Error Prone javadoc-shape findings

Closes out every WARNING-severity finding except MissingSummary
(explicitly deprioritized, see next commit): EscapedEntity (HTML
entities inside {@code}/{@literal} render literally, so use the bare
characters instead), NotJavadoc (four oshi-demo main() methods had a
stale duplicate /** block left over from an older doc pass, sandwiched
around @SuppressForbidden), AlmostJavadoc (three private helper
methods had genuine @return-bearing doc comments opened with /* rather
than /**), InvalidInlineTag (a stray "@PARAM patterns}" instead of
"{@code patterns}"), and InlineFormatString (a single-use format
string constant, inlined into its one call site).

* Suppress MissingSummary, escalate cleared checks to ERROR severity

MissingSummary demands a summary fragment distinct from the @return
block; Checkstyle's javadoc checks don't require that phrasing, and
the project doesn't want a separate Error Prone rule for it either.

Separately, every other WARNING-severity check with findings across
the #3594-3605 triage and the previous commit is now at zero. Escalate
each of them individually to ERROR so a regression fails the build,
using the same javac mechanism that already blocks on Error Prone's
own ERROR-severity checks - narrower than -Werror, which would also
fail on every other javac warning category this project has never
triaged.

* Fix InlineFormatString in GlobalConfigTest

Missed in the prior commit: I'd only verified 'mvn compile', which
skips test sources. The escalation to ERROR surfaced these on CI.
Inline both single-use message-template constants, same fix as
FreeBsdSensorsJNA's InlineFormatString earlier in this PR.
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