Remove usage of RuntimeHintsUtils & SynthesizedAnnotation.

Closes: #2685
This commit is contained in:
Christoph Strobl
2022-09-06 17:48:36 +02:00
parent 1ccdac2d05
commit f157eff53c
3 changed files with 10 additions and 33 deletions

View File

@@ -23,7 +23,6 @@ import java.util.function.Predicate;
import org.springframework.aot.generate.GenerationContext;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.core.annotation.MergedAnnotation;
import org.springframework.core.annotation.SynthesizedAnnotation;
/**
* @author Christoph Strobl
@@ -51,7 +50,8 @@ public class TypeContributor {
* @param contribution
*/
@SuppressWarnings("unchecked")
public static void contribute(Class<?> type, Predicate<Class<? extends Annotation>> filter, GenerationContext contribution) {
public static void contribute(Class<?> type, Predicate<Class<? extends Annotation>> filter,
GenerationContext contribution) {
if (type.isPrimitive()) {
return;
@@ -59,24 +59,21 @@ public class TypeContributor {
if (type.isAnnotation() && filter.test((Class<? extends Annotation>) type)) {
contribution.getRuntimeHints().reflection().registerType(type, hint ->
hint.withMembers(MemberCategory.INTROSPECT_PUBLIC_METHODS));
contribution.getRuntimeHints().reflection().registerType(type,
hint -> hint.withMembers(MemberCategory.INTROSPECT_PUBLIC_METHODS));
// TODO: do we need this if meta annotated with SD annotation?
if (type.getPackage().getName().startsWith(DATA_NAMESPACE)) {
contribution.getRuntimeHints().proxies().registerJdkProxy(type, SynthesizedAnnotation.class);
}
return;
}
if (type.isInterface()) {
contribution.getRuntimeHints().reflection().registerType(type, hint ->
hint.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
contribution.getRuntimeHints().reflection().registerType(type,
hint -> hint.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
return;
}
contribution.getRuntimeHints().reflection().registerType(type, hint ->
hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.DECLARED_FIELDS));
contribution.getRuntimeHints().reflection().registerType(type,
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS,
MemberCategory.DECLARED_FIELDS));
}
/**

View File

@@ -77,7 +77,6 @@ class RepositoryRuntimeHints implements RuntimeHintsRegistrar {
// annotated queries
hints.proxies().registerJdkProxy( //
TypeReference.of("org.springframework.data.annotation.QueryAnnotation"), //
TypeReference.of("org.springframework.core.annotation.SynthesizedAnnotation"));
TypeReference.of("org.springframework.data.annotation.QueryAnnotation"));
}
}

View File

@@ -21,7 +21,6 @@ import static org.springframework.data.aot.RepositoryRegistrationAotContribution
import java.io.Serializable;
import org.junit.jupiter.api.Test;
import org.springframework.aop.SpringProxy;
import org.springframework.aop.framework.Advised;
import org.springframework.aot.hint.RuntimeHints;
@@ -30,8 +29,6 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.RegisteredBean;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.DecoratingProxy;
import org.springframework.core.annotation.SynthesizedAnnotation;
import org.springframework.data.annotation.QueryAnnotation;
import org.springframework.data.aot.sample.ConfigWithCustomImplementation;
import org.springframework.data.aot.sample.ConfigWithCustomRepositoryBaseClass;
import org.springframework.data.aot.sample.ConfigWithFragments;
@@ -44,7 +41,6 @@ import org.springframework.data.aot.sample.ReactiveConfig;
import org.springframework.data.domain.Page;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.repository.reactive.ReactiveSortingRepository;
import org.springframework.transaction.interceptor.TransactionalProxy;
@@ -264,21 +260,6 @@ public class RepositoryRegistrationAotProcessorIntegrationTests {
});
}
@Test // GH-2593
void contributesProxiesForDataAnnotations() {
RepositoryRegistrationAotContribution repositoryBeanContribution = computeAotConfiguration(
ConfigWithQueryMethods.class).forRepository(ConfigWithQueryMethods.CustomerRepositoryWithQueryMethods.class);
assertThatContribution(repositoryBeanContribution) //
.codeContributionSatisfies(contribution -> {
contribution.contributesJdkProxy(Param.class, SynthesizedAnnotation.class);
contribution.contributesJdkProxy(ConfigWithQueryMethods.CustomQuery.class, SynthesizedAnnotation.class);
contribution.contributesJdkProxy(QueryAnnotation.class, SynthesizedAnnotation.class);
});
}
@Test // GH-2593
void doesNotCareAboutNonDataAnnotations() {