Skip to content

feat: Support custom Error Prone plugin injection in JavaBuilder#30140

Open
JonathanPerry651 wants to merge 3 commits into
bazelbuild:masterfrom
JonathanPerry651:custom-javabuilder-support
Open

feat: Support custom Error Prone plugin injection in JavaBuilder#30140
JonathanPerry651 wants to merge 3 commits into
bazelbuild:masterfrom
JonathanPerry651:custom-javabuilder-support

Conversation

@JonathanPerry651

@JonathanPerry651 JonathanPerry651 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Description

Refactors Bazel's JavaBuilder compilation wrapper to dynamically load Error Prone and its plugins at runtime via java.util.ServiceLoader rather than linking them at compile-time.

To support Javac's classloader masking/isolation, ClassloaderMaskingFileManager dynamically scans for registered BugChecker services on the classpath and automatically whitelists and delegates their package prefixes to the parent classloader. This ensures custom checkers and any helper/utility classes packaged alongside them load successfully without version conflict issues or classloader blocks.

Motivation

Injecting custom Error Prone plugins (or using a customized version of Error Prone) in Bazel was previously extremely difficult because JavaBuilder compile-time linked the bundled Error Prone core and enforced a strict, whitelisted classloader masking filter that blocked custom plugin packages. Decoupling this allows users to seamlessly define and run custom checkers in their Java toolchains.

This PR implements the core JavaBuilder runtime loading changes for Bazel Issue #29910.

Note: This PR depends on the rules_java Starlark macro changes in bazelbuild/rules_java#364.

Build API Changes

No

Checklist

  • I have added tests for the new use cases (if any).
  • I have updated the documentation (if applicable).

Release Notes

RELNOTES: None

@JonathanPerry651 JonathanPerry651 requested a review from a team as a code owner July 6, 2026 08:57
@github-actions github-actions Bot added team-Rules-Java Issues for Java rules awaiting-review PR is awaiting review from an assigned reviewer labels Jul 6, 2026
@JonathanPerry651 JonathanPerry651 force-pushed the custom-javabuilder-support branch from a184391 to 73c305f Compare July 6, 2026 10:28
@JonathanPerry651 JonathanPerry651 force-pushed the custom-javabuilder-support branch 2 times, most recently from 8cde081 to 15f6c4e Compare July 6, 2026 15:35
@JonathanPerry651 JonathanPerry651 force-pushed the custom-javabuilder-support branch from 15f6c4e to bd402ba Compare July 6, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR is awaiting review from an assigned reviewer team-Rules-Java Issues for Java rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant