Skip to content

Commit 03039fc

Browse files
committed
Refine @RegisterReflectionForBinding Javadoc
Provide a better Javadoc to clarify that @RegisterReflectionForBinding should annotate a bean and that the types where reflection is needed should be specified in the annotation attributes. Closes gh-29345
1 parent a3a48a2 commit 03039fc

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

spring-core/src/main/java/org/springframework/aot/hint/annotation/RegisterReflectionForBinding.java

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,39 @@
2525
import org.springframework.core.annotation.AliasFor;
2626

2727
/**
28-
* Indicates that one or more {@link Class} reflection hints should be registered for
29-
* data binding purpose (class, fields, properties, record components, including
30-
* types transitively used on properties and record components).
28+
* Indicate that the classes specified in the annotation attributes require some
29+
* reflection hints for binding or reflection-based serialization purpose. For each
30+
* class specified, hints on constructors, fields, properties, record components,
31+
* including types transitively used on properties and record components are registered.
32+
* At least one class must be specified in the {@code value} or {@code classes} annotation
33+
* attributes.
3134
*
32-
* <p>Typically used to annotate the bean class or bean method where the reflection hint
33-
* is needed.
35+
* <p>Annotated element can be a configuration class, for example:
36+
*
37+
* <pre class="code">
38+
* &#064;Configuration
39+
* &#064;RegisterReflectionForBinding({ Foo.class, Bar.class })
40+
* public class MyConfig {
41+
*
42+
* // ...
43+
* }</pre>
44+
*
45+
* <p>Annotated element can also be any Spring bean class, constructor, field or method, for example:
46+
*
47+
* <pre class="code">
48+
* &#064;Service
49+
* public class MyService {
50+
*
51+
* &#064;RegisterReflectionForBinding(Baz.class)
52+
* public void process() {
53+
* // ...
54+
* }
55+
*
56+
* }</pre>
3457
*
3558
* @author Sebastien Deleuze
3659
* @since 6.0
60+
* @see org.springframework.aot.hint.BindingReflectionHintsRegistrar
3761
*/
3862
@Target({ ElementType.TYPE, ElementType.METHOD })
3963
@Retention(RetentionPolicy.RUNTIME)
@@ -42,14 +66,16 @@
4266
public @interface RegisterReflectionForBinding {
4367

4468
/**
45-
* Classes for which reflection hints should be registered.
69+
* Classes for which reflection hints should be registered. At least one class must specified
70+
* either in {@code value} or {@code classes}.
4671
* @see #classes()
4772
*/
4873
@AliasFor("classes")
4974
Class<?>[] value() default {};
5075

5176
/**
52-
* Classes for which reflection hints should be registered.
77+
* Classes for which reflection hints should be registered. At least one class must specified
78+
* either in {@code value} or {@code classes}.
5379
* @see #value()
5480
*/
5581
@AliasFor("value")

0 commit comments

Comments
 (0)