Skip to content

chore: remove the JavaPoet dependency - #3556

Merged
csviri merged 3 commits into
operator-framework:mainfrom
csviri:remove-javapoet
Aug 12, 2026
Merged

chore: remove the JavaPoet dependency#3556
csviri merged 3 commits into
operator-framework:mainfrom
csviri:remove-javapoet

Conversation

@csviri

@csviri csviri commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

JavaPoet was only used in ControllerConfigurationAnnotationProcessor to turn
the resolved resource TypeMirror into its fully qualified name, which the
standard annotation processing API can do on its own: the resolved type is
always a declared type, so its element is a TypeElement and its qualified name
is exactly the dot separated name ClassMappingProvider loads at runtime.

JavaPoet has not been released since 2024, which makes it unusable for users
whose organizations do not approve unmaintained dependencies.

Also assert the content of the generated mapping resource in the processor
tests, which previously only checked that compilation succeeded and so could
not have caught a wrong resource class name.

Summary by CodeRabbit

  • Bug Fixes

    • Improved generated reconciler-to-resource mappings for interface, abstract-base, multilevel, and generic resource hierarchies.
    • Ensured mappings consistently record loadable, fully qualified resource type names, including erased generic types.
  • Tests

    • Added compilation checks covering generated mappings across supported hierarchy and generic-resource scenarios.
  • Chores

    • Removed an unused build dependency and related project configuration, with no user-facing API changes.

Copilot AI lite review requested due to automatic review settings August 11, 2026 17:13
@openshift-ci
openshift-ci Bot requested review from metacosm and xstefank August 11, 2026 17:13
@csviri csviri linked an issue Aug 11, 2026 that may be closed by this pull request
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The annotation processor now records resolved resource types with compiler APIs. Maven no longer declares JavaPoet. Compilation tests verify mappings for standard hierarchies and generic resources.

Changes

Annotation processor cleanup

Layer / File(s) Summary
Standard type-name resolution
operator-framework/src/main/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessor.java, pom.xml
recordCRType records the resolved resource type qualified name through TypeElement. Maven removes JavaPoet configuration and its managed dependency.
Generated mapping validation
operator-framework/src/test/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessorTest.java, operator-framework/src/test/resources/compile-fixtures/GenericResourceReconciler.java
Compilation tests verify mappings for interface, abstract-base, multilevel, and generic-resource reconciler hierarchies. The generic fixture supplies a parameterized resource type.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • operator-framework/java-operator-sdk#3555: Removes JavaPoet and replaces its use in ControllerConfigurationAnnotationProcessor with standard compiler APIs.

Suggested reviewers: metacosm, xstefank

🚥 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 and concisely describes the main change: removing the JavaPoet dependency.
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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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
`@operator-framework/src/main/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessor.java`:
- Line 104: Remove the explanatory comment above the type conversion in
ControllerConfigurationAnnotationProcessor.java (lines 104-104) and remove the
assertMapping Javadoc in ControllerConfigurationAnnotationProcessorTest.java
(lines 73-77); retain the underlying logic unchanged.

In
`@operator-framework/src/test/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessorTest.java`:
- Line 27: Update the import of RECONCILERS_RESOURCE_PATH in
ControllerConfigurationAnnotationProcessorTest to comply with the 100-character
limit by running Spotless/Google Java Format; if it remains too long, replace
the static import with RuntimeControllerMetadata and qualify the constant at its
use site.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a2d792fd-baee-4447-8aed-2f6eab3e5cb7

📥 Commits

Reviewing files that changed from the base of the PR and between 55047b6 and baf062a.

📒 Files selected for processing (4)
  • operator-framework/pom.xml
  • operator-framework/src/main/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessor.java
  • operator-framework/src/test/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessorTest.java
  • pom.xml
💤 Files with no reviewable changes (2)
  • operator-framework/pom.xml
  • pom.xml

return;
}
final TypeName customResourceType = TypeName.get(resourceType);
// the resolved resource type is always a declared type, so its element is a TypeElement

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove the added comments for short logic.

Both comments document short, direct operations. Keep comments only for very long or complex logic.

  • operator-framework/src/main/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessor.java#L104-L104: remove the explanatory comment above the type conversion.
  • operator-framework/src/test/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessorTest.java#L73-L77: remove the Javadoc for assertMapping.

As per coding guidelines: do not add comments except for very long or complex logic.

📍 Affects 2 files
  • operator-framework/src/main/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessor.java#L104-L104 (this comment)
  • operator-framework/src/test/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessorTest.java#L73-L77
🤖 Prompt for 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.

In
`@operator-framework/src/main/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessor.java`
at line 104, Remove the explanatory comment above the type conversion in
ControllerConfigurationAnnotationProcessor.java (lines 104-104) and remove the
assertMapping Javadoc in ControllerConfigurationAnnotationProcessorTest.java
(lines 73-77); retain the underlying logic unchanged.

Source: Coding guidelines

import com.google.testing.compile.Compiler;
import com.google.testing.compile.JavaFileObjects;

import static io.javaoperatorsdk.operator.config.runtime.RuntimeControllerMetadata.RECONCILERS_RESOURCE_PATH;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

sed -n '20,35p' operator-framework/src/test/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessorTest.java
python3 - <<'PY'
from pathlib import Path

path = Path("operator-framework/src/test/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessorTest.java")
for number, line in enumerate(path.read_text().splitlines(), 1):
    if number in range(20, 35):
        print(f"{number}: {len(line)} chars: {line}")
PY
rg -n "RECONCILERS_RESOURCE_PATH|RuntimeControllerMetadata" operator-framework/src/test/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessorTest.java

Repository: operator-framework/java-operator-sdk

Length of output: 1713


Keep the static import within the 100-character limit.

This import is 109 characters. Run Spotless with Google Java Format. If it remains too long, import RuntimeControllerMetadata and qualify RECONCILERS_RESOURCE_PATH at the use site.

🤖 Prompt for 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.

In
`@operator-framework/src/test/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessorTest.java`
at line 27, Update the import of RECONCILERS_RESOURCE_PATH in
ControllerConfigurationAnnotationProcessorTest to comply with the 100-character
limit by running Spotless/Google Java Format; if it remains too long, replace
the static import with RuntimeControllerMetadata and qualify the constant at its
use site.

Source: Coding guidelines

Copilot AI 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.

Pull request overview

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Removes the JavaPoet dependency by using standard annotation processing APIs to resolve fully qualified resource class names, and strengthens processor tests by asserting generated mapping contents.

Changes:

  • Removed JavaPoet from root and module POMs.
  • Updated ControllerConfigurationAnnotationProcessor to resolve the resource type’s qualified name via TypeElement.
  • Enhanced annotation processor tests to assert the generated mapping resource content.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
pom.xml Drops JavaPoet version property and dependency from dependency management.
operator-framework/pom.xml Removes the module-level JavaPoet dependency.
operator-framework/src/main/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessor.java Replaces JavaPoet TypeName usage with TypeElement#getQualifiedName() resolution.
operator-framework/src/test/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessorTest.java Adds assertions on the generated mapping resource file content.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +104 to +109
// the resolved resource type is always a declared type, so its element is a TypeElement
final var customResourceType =
(TypeElement) processingEnv.getTypeUtils().asElement(resourceType);
controllersResourceWriter.add(
controllerClassSymbol.getQualifiedName().toString(), customResourceType.toString());
controllerClassSymbol.getQualifiedName().toString(),
customResourceType.getQualifiedName().toString());
Comment on lines +78 to +82
private static void assertMapping(Compilation compilation, String expectedMapping) {
CompilationSubject.assertThat(compilation)
.generatedFile(StandardLocation.CLASS_OUTPUT, RECONCILERS_RESOURCE_PATH)
.contentsAsUtf8String()
.contains(expectedMapping);

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
operator-framework/src/test/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessorTest.java (1)

102-106: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Assert complete mapping records.

Use an exact line assertion instead of contains(expectedMapping). Use split(",", -1) so trailing empty fields cannot pass hasSize(2).

🤖 Prompt for 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.

In
`@operator-framework/src/test/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessorTest.java`
around lines 102 - 106, Update assertMapping to assert the complete generated
mapping line rather than using contains(expectedMapping), and split the relevant
mapping with split(",", -1) so trailing empty fields are retained and validated
with the expected field count.
🤖 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
`@operator-framework/src/test/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessorTest.java`:
- Around line 135-140: Update assertLoadableMapping to validate each mapping
name through ClassMappingProvider’s runtime ClassUtils.getClass loading path,
using a classloader that includes the compilation output. Preserve the existing
syntax assertions, and ensure missing but syntactically valid class names fail
instead of passing.

---

Outside diff comments:
In
`@operator-framework/src/test/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessorTest.java`:
- Around line 102-106: Update assertMapping to assert the complete generated
mapping line rather than using contains(expectedMapping), and split the relevant
mapping with split(",", -1) so trailing empty fields are retained and validated
with the expected field count.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 24aad668-bf54-4a26-8a41-31b971659801

📥 Commits

Reviewing files that changed from the base of the PR and between 461088d and ea18649.

📒 Files selected for processing (2)
  • operator-framework/src/test/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessorTest.java
  • operator-framework/src/test/resources/compile-fixtures/GenericResourceReconciler.java

Comment on lines +135 to +140
assertThat(name)
.as("recorded class name '%s' must be loadable at runtime", name)
.doesNotContain("<")
.doesNotContain(">")
.doesNotContain(" ")
.matches("[\\p{L}_$][\\p{L}\\p{N}_$]*(\\.[\\p{L}_$][\\p{L}\\p{N}_$]*)*");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu

file="$(git ls-files | grep -F 'operator-framework/src/test/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessorTest.java' | head -n 1)"
printf '%s\n' "FILE=$file"
wc -l "$file"
sed -n '1,220p' "$file"

printf '\n-- ClassMappingProvider references --\n'
rg -n -C 4 'ClassMappingProvider|assertLoadableMapping|assertMapping|loadClass|Class\.forName' operator-framework/src operator-framework/pom.xml pom.xml 2>/dev/null || true

Repository: operator-framework/java-operator-sdk

Length of output: 21788


🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '-- ClassMappingProvider --'
cat -n operator-framework/src/main/java/io/javaoperatorsdk/operator/config/runtime/ClassMappingProvider.java

printf '%s\n' '-- Compile-testing dependency declarations and API usage --'
rg -n -C 3 'compile-testing|com.google.testing.compile|Compilation\.|classLoader|ClassLoader' \
  operator-framework/pom.xml pom.xml operator-framework/src test 2>/dev/null || true

printf '%s\n' '-- Relevant fixture declarations --'
for f in $(git ls-files 'operator-framework/src/test/resources/compile-fixtures/*.java' \
  | grep -E '(GenericResourceReconciler|MultilevelReconciler|AbstractReconciler|ReconcilerImplemented)'); do
  echo "### $f"
  sed -n '1,180p' "$f"
done

Repository: operator-framework/java-operator-sdk

Length of output: 16543


🌐 Web query:

com.google.testing.compile compile-testing 0.23.0 Compilation classLoader compiledClass API

💡 Result:

In Google Compile-Testing 0.23.0, the Compilation class does not expose a ClassLoader or a method to retrieve a "compiledClass" directly [1]. Instead, the Compilation class is designed to represent the outcome of a compilation process, providing access to the compilation status (success/failure), diagnostics (errors/warnings), source files, and generated files [1]. To interact with the classpath during compilation tests—such as ensuring specific libraries or classes are available to the compiler—you use methods on the Compiler class rather than the Compilation result [2][3][4]. Key methods include: - withClasspath(Iterable): Allows you to explicitly provide a list of files or JARs as the classpath [3]. - withClasspathFrom(ClassLoader): Allows you to derive the compilation classpath from an existing ClassLoader (e.g., this.getClass.getClassLoader), which is useful for making classes available to the test compilation that are already on your test runtime classpath [3][4]. The Compilation class itself focuses on verification of the output, typically used in conjunction with Truth assertions (e.g., assertThat(compilation).succeeded) to validate that the compilation behaved as expected [1][3]. If you need to load and inspect classes generated by the compilation, that typically falls outside the primary scope of the Compile-Testing library's assertions, which are centered on verifying compiler behavior and diagnostics [5][1].

Citations:


Resolve each mapping name with the runtime loading path.

assertLoadableMapping checks only syntax. It does not call ClassMappingProvider’s ClassUtils.getClass path, so a valid-looking but missing class name can pass. Use a classloader that includes the compilation output, or rename the helper to indicate syntax-only validation.

🤖 Prompt for 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.

In
`@operator-framework/src/test/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessorTest.java`
around lines 135 - 140, Update assertLoadableMapping to validate each mapping
name through ClassMappingProvider’s runtime ClassUtils.getClass loading path,
using a classloader that includes the compilation output. Preserve the existing
syntax assertions, and ensure missing but syntactically valid class names fail
instead of passing.

@fs-alecbg fs-alecbg left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks great to me! Thanks for doing this so quickly

An integration test did fail, https://github.com/operator-framework/java-operator-sdk/actions/runs/31527708308/job/93899970031?pr=3556. It looks to me like this is a flaky test and is unrelated to these changes.

@csviri
csviri requested a lite review from Copilot August 12, 2026 07:38
csviri added 3 commits August 12, 2026 09:38
JavaPoet was only used in ControllerConfigurationAnnotationProcessor to turn
the resolved resource TypeMirror into its fully qualified name, which the
standard annotation processing API can do on its own: the resolved type is
always a declared type, so its element is a TypeElement and its qualified name
is exactly the dot separated name ClassMappingProvider loads at runtime.

JavaPoet has not been released since 2024, which makes it unusable for users
whose organizations do not approve unmaintained dependencies.

Also assert the content of the generated mapping resource in the processor
tests, which previously only checked that compilation succeeded and so could
not have caught a wrong resource class name.
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@csviri
csviri merged commit d488fd5 into operator-framework:main Aug 12, 2026
48 of 49 checks passed
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.

Remove javapoet dependency

4 participants