Support recursive annotations in merged annotations
Although Java does not allow the definition of recursive annotations, Kotlin does, and prior to this commit an attempt to synthesize a merged annotation using the MergedAnnotation API resulted in a StackOverflowError if there was a recursive cycle in the annotation definitions. This commit addresses this issue by tracking which annotations have already been visited and short circuits the recursive algorithm if a cycle is detected. Closes gh-28012
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -88,7 +88,7 @@ class AnnotationTypeMappingsTests {
|
||||
@Test
|
||||
void forAnnotationTypeWhenRepeatableMetaAnnotationIsFiltered() {
|
||||
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(WithRepeatedMetaAnnotations.class,
|
||||
Repeating.class.getName()::equals);
|
||||
RepeatableContainers.standardRepeatables(), Repeating.class.getName()::equals);
|
||||
assertThat(getAll(mappings)).flatExtracting(AnnotationTypeMapping::getAnnotationType)
|
||||
.containsExactly(WithRepeatedMetaAnnotations.class);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user