Replace getJvmErasure by getClassifier
Should be slightly faster. See gh-32334
This commit is contained in:
parent
946082f806
commit
80f3be6577
|
@ -33,7 +33,6 @@ import kotlin.reflect.full.KClasses;
|
||||||
import kotlin.reflect.full.KClassifiers;
|
import kotlin.reflect.full.KClassifiers;
|
||||||
import kotlin.reflect.full.KTypes;
|
import kotlin.reflect.full.KTypes;
|
||||||
import kotlin.reflect.jvm.KCallablesJvm;
|
import kotlin.reflect.jvm.KCallablesJvm;
|
||||||
import kotlin.reflect.jvm.KTypesJvm;
|
|
||||||
import kotlin.reflect.jvm.ReflectJvmMapping;
|
import kotlin.reflect.jvm.ReflectJvmMapping;
|
||||||
import kotlinx.coroutines.BuildersKt;
|
import kotlinx.coroutines.BuildersKt;
|
||||||
import kotlinx.coroutines.CoroutineStart;
|
import kotlinx.coroutines.CoroutineStart;
|
||||||
|
@ -109,7 +108,7 @@ public abstract class CoroutinesUtils {
|
||||||
* @throws IllegalArgumentException if {@code method} is not a suspending function
|
* @throws IllegalArgumentException if {@code method} is not a suspending function
|
||||||
* @since 6.0
|
* @since 6.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings({"deprecation", "DataFlowIssue"})
|
||||||
public static Publisher<?> invokeSuspendingFunction(CoroutineContext context, Method method, Object target,
|
public static Publisher<?> invokeSuspendingFunction(CoroutineContext context, Method method, Object target,
|
||||||
Object... args) {
|
Object... args) {
|
||||||
Assert.isTrue(KotlinDetector.isSuspendingFunction(method), "'method' must be a suspending function");
|
Assert.isTrue(KotlinDetector.isSuspendingFunction(method), "'method' must be a suspending function");
|
||||||
|
@ -128,7 +127,7 @@ public abstract class CoroutinesUtils {
|
||||||
if (!(parameter.isOptional() && arg == null)) {
|
if (!(parameter.isOptional() && arg == null)) {
|
||||||
KType type = parameter.getType();
|
KType type = parameter.getType();
|
||||||
if (!(type.isMarkedNullable() && arg == null)) {
|
if (!(type.isMarkedNullable() && arg == null)) {
|
||||||
KClass<?> kClass = KTypesJvm.getJvmErasure(type);
|
KClass<?> kClass = (KClass<?>) type.getClassifier();
|
||||||
if (KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
|
if (KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
|
||||||
arg = KClasses.getPrimaryConstructor(kClass).call(arg);
|
arg = KClasses.getPrimaryConstructor(kClass).call(arg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ import kotlin.reflect.KParameter;
|
||||||
import kotlin.reflect.KType;
|
import kotlin.reflect.KType;
|
||||||
import kotlin.reflect.full.KClasses;
|
import kotlin.reflect.full.KClasses;
|
||||||
import kotlin.reflect.jvm.KCallablesJvm;
|
import kotlin.reflect.jvm.KCallablesJvm;
|
||||||
import kotlin.reflect.jvm.KTypesJvm;
|
|
||||||
import kotlin.reflect.jvm.ReflectJvmMapping;
|
import kotlin.reflect.jvm.ReflectJvmMapping;
|
||||||
|
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
|
@ -299,7 +298,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||||
private static class KotlinDelegate {
|
private static class KotlinDelegate {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings({"deprecation", "DataFlowIssue"})
|
||||||
public static Object invokeFunction(Method method, Object target, Object[] args) throws InvocationTargetException, IllegalAccessException {
|
public static Object invokeFunction(Method method, Object target, Object[] args) throws InvocationTargetException, IllegalAccessException {
|
||||||
KFunction<?> function = ReflectJvmMapping.getKotlinFunction(method);
|
KFunction<?> function = ReflectJvmMapping.getKotlinFunction(method);
|
||||||
// For property accessors
|
// For property accessors
|
||||||
|
@ -319,7 +318,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||||
if (!(parameter.isOptional() && arg == null)) {
|
if (!(parameter.isOptional() && arg == null)) {
|
||||||
KType type = parameter.getType();
|
KType type = parameter.getType();
|
||||||
if (!(type.isMarkedNullable() && arg == null)) {
|
if (!(type.isMarkedNullable() && arg == null)) {
|
||||||
KClass<?> kClass = KTypesJvm.getJvmErasure(type);
|
KClass<?> kClass = (KClass<?>) type.getClassifier();
|
||||||
if (KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
|
if (KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
|
||||||
arg = KClasses.getPrimaryConstructor(kClass).call(arg);
|
arg = KClasses.getPrimaryConstructor(kClass).call(arg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ import kotlin.reflect.KParameter;
|
||||||
import kotlin.reflect.KType;
|
import kotlin.reflect.KType;
|
||||||
import kotlin.reflect.full.KClasses;
|
import kotlin.reflect.full.KClasses;
|
||||||
import kotlin.reflect.jvm.KCallablesJvm;
|
import kotlin.reflect.jvm.KCallablesJvm;
|
||||||
import kotlin.reflect.jvm.KTypesJvm;
|
|
||||||
import kotlin.reflect.jvm.ReflectJvmMapping;
|
import kotlin.reflect.jvm.ReflectJvmMapping;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
@ -298,7 +297,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||||
private static final String COROUTINE_CONTEXT_ATTRIBUTE = "org.springframework.web.server.CoWebFilter.context";
|
private static final String COROUTINE_CONTEXT_ATTRIBUTE = "org.springframework.web.server.CoWebFilter.context";
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings({"deprecation", "DataFlowIssue"})
|
||||||
public static Object invokeFunction(Method method, Object target, Object[] args, boolean isSuspendingFunction,
|
public static Object invokeFunction(Method method, Object target, Object[] args, boolean isSuspendingFunction,
|
||||||
ServerWebExchange exchange) throws InvocationTargetException, IllegalAccessException {
|
ServerWebExchange exchange) throws InvocationTargetException, IllegalAccessException {
|
||||||
|
|
||||||
|
@ -330,7 +329,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||||
if (!(parameter.isOptional() && arg == null)) {
|
if (!(parameter.isOptional() && arg == null)) {
|
||||||
KType type = parameter.getType();
|
KType type = parameter.getType();
|
||||||
if (!(type.isMarkedNullable() && arg == null)) {
|
if (!(type.isMarkedNullable() && arg == null)) {
|
||||||
KClass<?> kClass = KTypesJvm.getJvmErasure(type);
|
KClass<?> kClass = (KClass<?>) type.getClassifier();
|
||||||
if (KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
|
if (KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
|
||||||
arg = KClasses.getPrimaryConstructor(kClass).call(arg);
|
arg = KClasses.getPrimaryConstructor(kClass).call(arg);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue