Start claiming the annotations we process + New option inheritRecordAnnotations#276
Conversation
|
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.
320b6d7 to
9913e7d
Compare
| .forEach(annotation -> roundEnv.getElementsAnnotatedWith(annotation) | ||
| .forEach(element -> process(annotation, element))); | ||
| return false; | ||
| return annotationWasProcessed; |
There was a problem hiding this comment.
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 runEither revert to return false or narrow getSupportedAnnotationTypes() to the specific annotations record-builder handles.
There was a problem hiding this comment.
Yeah, I was unsure about that part. I'll remove it.
There was a problem hiding this comment.
@semyon-levin-workato I've removed it. Try now.
9913e7d to
2b9d868
Compare
semyon-levin-workato
left a comment
There was a problem hiding this comment.
@Randgalt , the solution works for me. What would you suggest we do next?
- I close my PR
- You release this one
Do I get this right?
|
Yes, I'll do that. |
|
v53 is released |
Augments
inheritComponentAnnotationsby supplying a list of record-levelannotations that should be copied. Nominally this is for
SuppressWarningsbut it can be used for any set of annotations.
Fixes #273