mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-23 14:40:00 +00:00
Reinstantiate checks for kotlin-reflect
This commit reinstantiates checks for kotlin-reflect (via static final fields for faster Java code paths and better native code removal) which were removed as part of gh-34275, which did not consider the increasingly popular use cases where kotlin-stdlib is present in the classpath as a transitive dependency in Java applications. Closes gh-35511
This commit is contained in:
+3
-1
@@ -72,6 +72,8 @@ import org.springframework.web.method.support.ModelAndViewContainer;
|
||||
*/
|
||||
public abstract class AbstractNamedValueMethodArgumentResolver implements HandlerMethodArgumentResolver {
|
||||
|
||||
private static final boolean KOTLIN_REFLECT_PRESENT = KotlinDetector.isKotlinReflectPresent();
|
||||
|
||||
private final @Nullable ConfigurableBeanFactory configurableBeanFactory;
|
||||
|
||||
private final @Nullable BeanExpressionContext expressionContext;
|
||||
@@ -103,7 +105,7 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
|
||||
|
||||
NamedValueInfo namedValueInfo = getNamedValueInfo(parameter);
|
||||
MethodParameter nestedParameter = parameter.nestedIfOptional();
|
||||
boolean hasDefaultValue = KotlinDetector.isKotlinType(parameter.getDeclaringClass()) &&
|
||||
boolean hasDefaultValue = KOTLIN_REFLECT_PRESENT && KotlinDetector.isKotlinType(parameter.getDeclaringClass()) &&
|
||||
KotlinDelegate.hasDefaultValue(nestedParameter);
|
||||
|
||||
Object resolvedName = resolveEmbeddedValuesAndExpressions(namedValueInfo.name);
|
||||
|
||||
+3
-1
@@ -66,6 +66,8 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||
|
||||
private static final Class<?>[] EMPTY_GROUPS = new Class<?>[0];
|
||||
|
||||
private static final boolean KOTLIN_REFLECT_PRESENT = KotlinDetector.isKotlinReflectPresent();
|
||||
|
||||
|
||||
private HandlerMethodArgumentResolverComposite resolvers = new HandlerMethodArgumentResolverComposite();
|
||||
|
||||
@@ -247,7 +249,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||
protected @Nullable Object doInvoke(@Nullable Object... args) throws Exception {
|
||||
Method method = getBridgedMethod();
|
||||
try {
|
||||
if (KotlinDetector.isKotlinType(method.getDeclaringClass())) {
|
||||
if (KOTLIN_REFLECT_PRESENT && KotlinDetector.isKotlinType(method.getDeclaringClass())) {
|
||||
if (KotlinDetector.isSuspendingFunction(method)) {
|
||||
return invokeSuspendingFunction(method, getBean(), args);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user