You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For such annotations, StandardAnnotationDescriptor#buildUsagesMap can be problematic, as it will, during the creation of an annotation descriptor, create a map of meta-annotations (annotations on the current annotation)... using annotation descriptors.
You can see how this can be a problem for recursive annotation: creating the annotation descriptor will trigger the creation of the annotation descriptor, recursively.
Fortunately, for some recursive annotations, this is already avoided with a simple if:
Unfortunately, that if doesn't cover all possible recursive annotations. Any time hibernate-models will hit any of the following, it will trigger a StackOverflowError:
Disclaimer: I only tested the first one, because it's blocking the upgrade of Quarkus to Hibernate ORM 7: quarkusio/quarkus#41310. But I'm pretty sure the others would lead to the same behavior.
Suggested solution: delay the building of StandardAnnotationDescriptor#usagesMap. Maybe initialize it lazily?
The text was updated successfully, but these errors were encountered:
Java annotations can be recursive, i.e. can be annotated with themselves.
One such annotation is
java.lang.annotation.Target
:For such annotations,
StandardAnnotationDescriptor#buildUsagesMap
can be problematic, as it will, during the creation of an annotation descriptor, create a map of meta-annotations (annotations on the current annotation)... using annotation descriptors.You can see how this can be a problem for recursive annotation: creating the annotation descriptor will trigger the creation of the annotation descriptor, recursively.
Fortunately, for some recursive annotations, this is already avoided with a simple
if
:hibernate-models/hibernate-models/src/main/java/org/hibernate/models/internal/StandardAnnotationDescriptor.java
Lines 86 to 95 in 9be40cb
Unfortunately, that
if
doesn't cover all possible recursive annotations. Any time hibernate-models will hit any of the following, it will trigger aStackOverflowError
:kotlin.annotation.Target
:Disclaimer: I only tested the first one, because it's blocking the upgrade of Quarkus to Hibernate ORM 7: quarkusio/quarkus#41310. But I'm pretty sure the others would lead to the same behavior.
Suggested solution: delay the building of
StandardAnnotationDescriptor#usagesMap
. Maybe initialize it lazily?The text was updated successfully, but these errors were encountered: