</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-stdlib</artifactId>
+ <version>2.0.21</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
// search recursively through all annotations
for (Annotation annotation : clazz.getAnnotations()) {
Class<? extends Annotation> annotationClass = annotation.annotationType();
- if (!annotationClass.getName().startsWith("java.lang.annotation")) {
+ if (!annotationClass.getName().startsWith("java.lang.annotation") && !annotationClass.getName().startsWith("kotlin")) {
+ // In case an annotation is annotated with itself,
+ // an example would be @Target, which is ignored by the check above
+ // however, other libraries might do similar things
+ if (annotationClass.equals(clazz)) continue;
+
Extension extensionAnnotation = findExtensionAnnotation(annotationClass);
if (extensionAnnotation != null) {
return extensionAnnotation;
*/
package org.pf4j;
+import kotlin.sequences.Sequence;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Assertions.assertNull(extension);
}
+ // This is a regression test, as this caused an StackOverflowError with the previous implementation
+ @Test
+ public void runningOnNonExtensionKotlinClassDoesNotThrowException() {
+ Extension result = AbstractExtensionFinder.findExtensionAnnotation(Sequence.class);
+
+ Assertions.assertNull(result);
+ }
}