Closed timonzi closed 1 year ago
If anyone has the same problem: It can be solved, when the a value of the default value annotation is overridden.
Example:
AnnotationB b() default @AnnotationB(dummyValue = "someValue");
It does not work with
AnnotationB b() default @AnnotationB;
I'm not clear what JavaPoet has to do with all of this.
Yeah, me neither in the meantime. I thought JavaPoet would do more here, but after looking at the code more closely I don't think JavaPoet has anything to do with it either.
That's why I'm closing the issue again.
We currently switch to Java 17 and have the problem with the following constellation:
An object
Obj
is annotated with Annotation@ObjectAnnotation
. This is processed by our annotation processor. A property within the object is annotated with@AnnotationA
.AnnotationA
contains a propertyb
with typeAnnotationB
and default value@AnnotationB
.AnnotationB
contains a propertyc
with typeAnnotationC
and default value@AnnotationC
.When not trying to access the property
b
, I get an exception:This does not happen when:
AnnotationB
in the class (Obj
)c
fromAnnotationB
When I use the "normal" reflection mechanism I don't have any problem to resolve the values. But this is not possible in the annotation processor.
The strange thing is also: When I would add another object which looks like the same like
Obj
and I would catch the exception for the first processed object, it works like expected for the second one. Here I don't get an exception.Is there any advice how to handle the exception? Is there a compatibility issue with Java 17?
I created reproducer projects for this: https://github.com/timonzi/annotation-processor-jdk17 Reproduction steps: Execute a (clean) install on...