|
|
|
@ -44,6 +44,7 @@ import org.springframework.beans.factory.aot.BeanRegistrationAotContribution; |
|
|
|
import org.springframework.beans.factory.support.DefaultListableBeanFactory; |
|
|
|
import org.springframework.beans.factory.support.DefaultListableBeanFactory; |
|
|
|
import org.springframework.beans.factory.support.RegisteredBean; |
|
|
|
import org.springframework.beans.factory.support.RegisteredBean; |
|
|
|
import org.springframework.beans.factory.support.RootBeanDefinition; |
|
|
|
import org.springframework.beans.factory.support.RootBeanDefinition; |
|
|
|
|
|
|
|
import org.springframework.core.OverridingClassLoader; |
|
|
|
import org.springframework.lang.Nullable; |
|
|
|
import org.springframework.lang.Nullable; |
|
|
|
|
|
|
|
|
|
|
|
import static java.lang.annotation.ElementType.ANNOTATION_TYPE; |
|
|
|
import static java.lang.annotation.ElementType.ANNOTATION_TYPE; |
|
|
|
@ -134,6 +135,14 @@ class BeanValidationBeanRegistrationAotProcessorTests { |
|
|
|
.withMemberCategory(MemberCategory.DECLARED_FIELDS)).accepts(this.generationContext.getRuntimeHints()); |
|
|
|
.withMemberCategory(MemberCategory.DECLARED_FIELDS)).accepts(this.generationContext.getRuntimeHints()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test // gh-33940
|
|
|
|
|
|
|
|
void shouldSkipConstraintWithMissingDependency() throws Exception { |
|
|
|
|
|
|
|
MissingDependencyClassLoader classLoader = new MissingDependencyClassLoader(getClass().getClassLoader()); |
|
|
|
|
|
|
|
Class<?> beanClass = classLoader.loadClass(ConstraintWithMissingDependency.class.getName()); |
|
|
|
|
|
|
|
process(beanClass); |
|
|
|
|
|
|
|
assertThat(this.generationContext.getRuntimeHints().reflection().typeHints()).isEmpty(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void process(Class<?> beanClass) { |
|
|
|
private void process(Class<?> beanClass) { |
|
|
|
BeanRegistrationAotContribution contribution = createContribution(beanClass); |
|
|
|
BeanRegistrationAotContribution contribution = createContribution(beanClass); |
|
|
|
if (contribution != null) { |
|
|
|
if (contribution != null) { |
|
|
|
@ -269,4 +278,31 @@ class BeanValidationBeanRegistrationAotProcessorTests { |
|
|
|
Optional<BeanWithRecursiveOptional> optional; |
|
|
|
Optional<BeanWithRecursiveOptional> optional; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static class ConstraintWithMissingDependency { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MissingType missingType; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static class MissingType {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static class MissingDependencyClassLoader extends OverridingClassLoader { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MissingDependencyClassLoader(ClassLoader parent) { |
|
|
|
|
|
|
|
super(parent); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected boolean isEligibleForOverriding(String className) { |
|
|
|
|
|
|
|
return className.startsWith(BeanValidationBeanRegistrationAotProcessorTests.class.getName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected Class<?> loadClassForOverriding(String name) throws ClassNotFoundException { |
|
|
|
|
|
|
|
if (name.contains("MissingType")) { |
|
|
|
|
|
|
|
throw new NoClassDefFoundError(name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return super.loadClassForOverriding(name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|