29
29
import org .springframework .aop .TargetSource ;
30
30
import org .springframework .aop .support .AopUtils ;
31
31
import org .springframework .aop .target .SingletonTargetSource ;
32
- import org .springframework .aot .hint .ProxyHints ;
33
- import org .springframework .aot .hint .RuntimeHints ;
34
32
import org .springframework .core .DecoratingProxy ;
35
33
import org .springframework .lang .Nullable ;
36
34
import org .springframework .util .Assert ;
@@ -101,34 +99,35 @@ public static Class<?> ultimateTargetClass(Object candidate) {
101
99
* proxy generated by Spring AOP.
102
100
* <p>Specifically, {@link SpringProxy}, {@link Advised}, and {@link DecoratingProxy}
103
101
* will be appended to the set of user-specified interfaces.
104
- * <p>Any {@linkplain Class#isSealed() sealed} interface in the set of
105
- * user-specified interfaces will be omitted from the results, since only
106
- * non-sealed interfaces are eligible for JDK dynamic proxies.
107
- * <p>This method can be useful when registering {@linkplain ProxyHints proxy
108
- * hints} for Spring's AOT support, as demonstrated in the following example
109
- * which uses this method via a {@code static} import.
102
+ * <p>This method can be useful when registering
103
+ * {@linkplain org.springframework.aot.hint.ProxyHints proxy hints} for Spring's
104
+ * AOT support, as demonstrated in the following example which uses this method
105
+ * via a {@code static} import.
110
106
* <pre class="code">
111
107
* RuntimeHints hints = ...
112
108
* hints.proxies().registerJdkProxy(completeJdkProxyInterfaces(MyInterface.class));
113
109
* </pre>
114
110
* @param userInterfaces the set of user-specified interfaces implemented by
115
111
* the component to be proxied
116
112
* @return the complete set of interfaces that the proxy should implement
113
+ * @throws IllegalArgumentException if a supplied {@code Class} is {@code null},
114
+ * is not an {@linkplain Class#isInterface() interface}, or is a
115
+ * {@linkplain Class#isSealed() sealed} interface
117
116
* @since 6.0
118
117
* @see SpringProxy
119
118
* @see Advised
120
119
* @see DecoratingProxy
121
- * @see RuntimeHints#proxies()
122
- * @see ProxyHints#registerJdkProxy(Class...)
120
+ * @see org.springframework.aot.hint. RuntimeHints#proxies()
121
+ * @see org.springframework.aot.hint. ProxyHints#registerJdkProxy(Class...)
123
122
* @see #completeJdkProxyInterfaces(String...)
124
123
*/
125
124
public static Class <?>[] completeJdkProxyInterfaces (Class <?>... userInterfaces ) {
126
125
List <Class <?>> completedInterfaces = new ArrayList <>(userInterfaces .length + 3 );
127
126
for (Class <?> ifc : userInterfaces ) {
128
- Assert .isTrue (ifc . isInterface (), () -> ifc . getName () + " must be an interface " );
129
- if ( !ifc .isSealed ()) {
130
- completedInterfaces . add ( ifc );
131
- }
127
+ Assert .notNull (ifc , "'userInterfaces' must not contain null values " );
128
+ Assert . isTrue ( ifc . isInterface () && !ifc .isSealed (),
129
+ () -> ifc . getName () + " must be a non-sealed interface" );
130
+ completedInterfaces . add ( ifc );
132
131
}
133
132
completedInterfaces .add (SpringProxy .class );
134
133
completedInterfaces .add (Advised .class );
@@ -141,9 +140,10 @@ public static Class<?>[] completeJdkProxyInterfaces(Class<?>... userInterfaces)
141
140
* proxy generated by Spring AOP.
142
141
* <p>Specifically, {@link SpringProxy}, {@link Advised}, and {@link DecoratingProxy}
143
142
* will be appended to the set of user-specified interfaces.
144
- * <p>This method can be useful when registering {@linkplain ProxyHints proxy
145
- * hints} for Spring's AOT support, as demonstrated in the following example
146
- * which uses this method via a {@code static} import.
143
+ * <p>This method can be useful when registering
144
+ * {@linkplain org.springframework.aot.hint.ProxyHints proxy hints} for Spring's
145
+ * AOT support, as demonstrated in the following example which uses this method
146
+ * via a {@code static} import.
147
147
* <pre class="code">
148
148
* RuntimeHints hints = ...
149
149
* hints.proxies().registerJdkProxy(completeJdkProxyInterfaces("com.example.MyInterface"));
@@ -156,8 +156,8 @@ public static Class<?>[] completeJdkProxyInterfaces(Class<?>... userInterfaces)
156
156
* @see SpringProxy
157
157
* @see Advised
158
158
* @see DecoratingProxy
159
- * @see RuntimeHints#proxies()
160
- * @see ProxyHints#registerJdkProxy(Class...)
159
+ * @see org.springframework.aot.hint. RuntimeHints#proxies()
160
+ * @see org.springframework.aot.hint. ProxyHints#registerJdkProxy(Class...)
161
161
* @see #completeJdkProxyInterfaces(Class...)
162
162
*/
163
163
public static String [] completeJdkProxyInterfaces (String ... userInterfaces ) {
0 commit comments