Refine KotlinDetector usages and implementation
This commit refines KotlinDetector usages and implementation in order to remove preliminary KotlinDetector#isKotlinReflectPresent invocations and to ensure that KotlinDetector methods are implemented safely and efficiently for such use case. Closes gh-34275
This commit is contained in:
@@ -868,8 +868,7 @@ public class Jackson2ObjectMapperBuilder {
|
||||
// jackson-datatype-jsr310 not available
|
||||
}
|
||||
|
||||
// Kotlin present?
|
||||
if (KotlinDetector.isKotlinPresent()) {
|
||||
if (KotlinDetector.isKotlinReflectPresent()) {
|
||||
try {
|
||||
Class<? extends Module> kotlinModuleClass = (Class<? extends Module>)
|
||||
ClassUtils.forName("com.fasterxml.jackson.module.kotlin.KotlinModule", this.moduleClassLoader);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -103,8 +103,7 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
|
||||
|
||||
NamedValueInfo namedValueInfo = getNamedValueInfo(parameter);
|
||||
MethodParameter nestedParameter = parameter.nestedIfOptional();
|
||||
boolean hasDefaultValue = KotlinDetector.isKotlinReflectPresent() &&
|
||||
KotlinDetector.isKotlinType(parameter.getDeclaringClass()) &&
|
||||
boolean hasDefaultValue = KotlinDetector.isKotlinType(parameter.getDeclaringClass()) &&
|
||||
KotlinDelegate.hasDefaultValue(nestedParameter);
|
||||
|
||||
Object resolvedName = resolveEmbeddedValuesAndExpressions(namedValueInfo.name);
|
||||
@@ -276,7 +275,7 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
|
||||
|
||||
WebDataBinder binder = binderFactory.createBinder(webRequest, null, namedValueInfo.name);
|
||||
Class<?> parameterType = parameter.getParameterType();
|
||||
if (KotlinDetector.isKotlinPresent() && KotlinDetector.isInlineClass(parameterType)) {
|
||||
if (KotlinDetector.isInlineClass(parameterType)) {
|
||||
Constructor<?> ctor = BeanUtils.findPrimaryConstructor(parameterType);
|
||||
if (ctor != null) {
|
||||
parameterType = ctor.getParameterTypes()[0];
|
||||
|
||||
@@ -242,13 +242,11 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||
protected @Nullable Object doInvoke(@Nullable Object... args) throws Exception {
|
||||
Method method = getBridgedMethod();
|
||||
try {
|
||||
if (KotlinDetector.isKotlinReflectPresent()) {
|
||||
if (KotlinDetector.isKotlinType(method.getDeclaringClass())) {
|
||||
if (KotlinDetector.isSuspendingFunction(method)) {
|
||||
return invokeSuspendingFunction(method, getBean(), args);
|
||||
}
|
||||
else if (KotlinDetector.isKotlinType(method.getDeclaringClass())) {
|
||||
return KotlinDelegate.invokeFunction(method, getBean(), args);
|
||||
}
|
||||
return KotlinDelegate.invokeFunction(method, getBean(), args);
|
||||
}
|
||||
return method.invoke(getBean(), args);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user