Skip to content

Start claiming the annotations we process + New option inheritRecordAnnotations#276

Merged
Randgalt merged 1 commit into
masterfrom
jordanz/class-annotations
Jun 23, 2026
Merged

Start claiming the annotations we process + New option inheritRecordAnnotations#276
Randgalt merged 1 commit into
masterfrom
jordanz/class-annotations

Conversation

@Randgalt

@Randgalt Randgalt commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Augments inheritComponentAnnotations by supplying a list of record-level
annotations that should be copied. Nominally this is for SuppressWarnings
but it can be used for any set of annotations.

Fixes #273

@Randgalt

Copy link
Copy Markdown
Owner Author

attn: @remal and @semyon-levin-workato

Augments `inheritComponentAnnotations` by supplying a list of record-level
annotations that should be copied. Nominally this is for `SuppressWarnings`
but it can be used for any set of annotations.
@Randgalt Randgalt force-pushed the jordanz/class-annotations branch from 320b6d7 to 9913e7d Compare June 20, 2026 07:17
@Randgalt Randgalt added this to the v53 milestone Jun 20, 2026
.forEach(annotation -> roundEnv.getElementsAnnotatedWith(annotation)
.forEach(element -> process(annotation, element)));
return false;
return annotationWasProcessed;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

getSupportedAnnotationTypes() returns "*", so when process() returns true, javac removes all annotations from the processing round. Subsequent processors (Immutables in my case) never see their annotations.

From JavacProcessingEnvironment.java (JDK 24):

// line 860: "*" matches every annotation, so matchedNames = all annotations in the round
for (Map.Entry<String, TypeElement> entry: unmatchedAnnotations.entrySet()) {
    if (ps.annotationSupported(unmatchedAnnotationName)) {
        matchedNames.add(unmatchedAnnotationName);
    }
}

// line 882: process() returned true -> remove all matched names
if (processingResult) {
    unmatchedAnnotations.keySet().removeAll(matchedNames);
}
// unmatchedAnnotations is now empty, loop exits, no more processors run

Either revert to return false or narrow getSupportedAnnotationTypes() to the specific annotations record-builder handles.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Yeah, I was unsure about that part. I'll remove it.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@semyon-levin-workato I've removed it. Try now.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

works good

@Randgalt Randgalt force-pushed the jordanz/class-annotations branch from 9913e7d to 2b9d868 Compare June 23, 2026 09:11

@semyon-levin-workato semyon-levin-workato 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.

@Randgalt , the solution works for me. What would you suggest we do next?

  1. I close my PR
  2. You release this one
    Do I get this right?

@Randgalt

Copy link
Copy Markdown
Owner Author

Yes, I'll do that.

@Randgalt Randgalt merged commit 335d2e2 into master Jun 23, 2026
3 checks passed
@Randgalt Randgalt deleted the jordanz/class-annotations branch June 23, 2026 09:58
@Randgalt

Copy link
Copy Markdown
Owner Author

v53 is released

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.

Add @SuppressWarnings to all generated classes

2 participants