|
|
|
|
@ -16,12 +16,15 @@
@@ -16,12 +16,15 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.aot.hint; |
|
|
|
|
|
|
|
|
|
import java.lang.annotation.Annotation; |
|
|
|
|
import java.lang.reflect.AnnotatedElement; |
|
|
|
|
import java.lang.reflect.Field; |
|
|
|
|
import java.lang.reflect.Method; |
|
|
|
|
import java.lang.reflect.RecordComponent; |
|
|
|
|
import java.lang.reflect.Type; |
|
|
|
|
import java.util.LinkedHashSet; |
|
|
|
|
import java.util.Set; |
|
|
|
|
import java.util.function.Consumer; |
|
|
|
|
|
|
|
|
|
import kotlin.jvm.JvmClassMappingKt; |
|
|
|
|
import kotlin.reflect.KClass; |
|
|
|
|
@ -161,27 +164,32 @@ public class BindingReflectionHintsRegistrar {
@@ -161,27 +164,32 @@ public class BindingReflectionHintsRegistrar {
|
|
|
|
|
|
|
|
|
|
private void registerJacksonHints(ReflectionHints hints, Class<?> clazz) { |
|
|
|
|
ReflectionUtils.doWithFields(clazz, field -> |
|
|
|
|
MergedAnnotations |
|
|
|
|
.from(field, MergedAnnotations.SearchStrategy.TYPE_HIERARCHY) |
|
|
|
|
.stream(JACKSON_ANNOTATION) |
|
|
|
|
.filter(MergedAnnotation::isMetaPresent) |
|
|
|
|
.forEach(annotation -> { |
|
|
|
|
forEachJacksonAnnotation(field, annotation -> { |
|
|
|
|
Field sourceField = (Field) annotation.getSource(); |
|
|
|
|
if (sourceField != null) { |
|
|
|
|
hints.registerField(sourceField); |
|
|
|
|
} |
|
|
|
|
})); |
|
|
|
|
ReflectionUtils.doWithMethods(clazz, method -> |
|
|
|
|
MergedAnnotations |
|
|
|
|
.from(method, MergedAnnotations.SearchStrategy.TYPE_HIERARCHY) |
|
|
|
|
.stream(JACKSON_ANNOTATION) |
|
|
|
|
.filter(MergedAnnotation::isMetaPresent) |
|
|
|
|
.forEach(annotation -> { |
|
|
|
|
forEachJacksonAnnotation(method, annotation -> { |
|
|
|
|
Method sourceMethod = (Method) annotation.getSource(); |
|
|
|
|
if (sourceMethod != null) { |
|
|
|
|
hints.registerMethod(sourceMethod, ExecutableMode.INVOKE); |
|
|
|
|
} |
|
|
|
|
})); |
|
|
|
|
forEachJacksonAnnotation(clazz, annotation -> annotation.getRoot().asMap().values().forEach(value -> { |
|
|
|
|
if (value instanceof Class<?> classValue) { |
|
|
|
|
hints.registerType(classValue, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS); |
|
|
|
|
} |
|
|
|
|
})); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void forEachJacksonAnnotation(AnnotatedElement element, Consumer<MergedAnnotation<Annotation>> action) { |
|
|
|
|
MergedAnnotations |
|
|
|
|
.from(element, MergedAnnotations.SearchStrategy.TYPE_HIERARCHY) |
|
|
|
|
.stream(JACKSON_ANNOTATION) |
|
|
|
|
.filter(MergedAnnotation::isMetaPresent) |
|
|
|
|
.forEach(action::accept); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|