Skip to content

Commit 8c063a0

Browse files
committed
Add runtime hints for MethodValidationPostProcessor
Closes gh-28689
1 parent 7a3e8bf commit 8c063a0

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationPostProcessor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.springframework.aop.support.annotation.AnnotationMatchingPointcut;
2929
import org.springframework.beans.factory.InitializingBean;
3030
import org.springframework.beans.factory.config.BeanPostProcessor;
31+
import org.springframework.context.annotation.ImportRuntimeHints;
3132
import org.springframework.lang.Nullable;
3233
import org.springframework.util.Assert;
3334
import org.springframework.validation.annotation.Validated;
@@ -57,6 +58,7 @@
5758
* @see jakarta.validation.executable.ExecutableValidator
5859
*/
5960
@SuppressWarnings("serial")
61+
@ImportRuntimeHints(MethodValidationRuntimeHintsRegistrar.class)
6062
public class MethodValidationPostProcessor extends AbstractBeanFactoryAwareAdvisingPostProcessor
6163
implements InitializingBean {
6264

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2002-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.validation.beanvalidation;
18+
19+
import jakarta.validation.Validator;
20+
21+
import org.springframework.aop.SpringProxy;
22+
import org.springframework.aop.framework.Advised;
23+
import org.springframework.aot.hint.RuntimeHints;
24+
import org.springframework.aot.hint.RuntimeHintsRegistrar;
25+
import org.springframework.core.DecoratingProxy;
26+
import org.springframework.lang.Nullable;
27+
28+
/**
29+
* {@link RuntimeHintsRegistrar} implementation that registers proxy entries
30+
* for {@link MethodValidationPostProcessor}.
31+
*
32+
* @author Sebastien Deleuze
33+
* @since 6.0
34+
*/
35+
public class MethodValidationRuntimeHintsRegistrar implements RuntimeHintsRegistrar {
36+
37+
@Override
38+
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
39+
hints.proxies().registerJdkProxy(Validator.class, SpringProxy.class, Advised.class, DecoratingProxy.class);
40+
}
41+
}

0 commit comments

Comments
 (0)