Upgrade to Kotlin 1.5

* To align with the rest of Spring portfolio, based on Spring Framework 5.3.x generation,
it is better to upgrade to the Kotlin version supported by SF
* Fix  `ClassUtils.isLambda()` to treat `$inlined$` classes as Kotlin lambdas and let
Java DSL to delegate to the `LambdaMessageProcessor` for better expected type handling.
Looks like Kotlin does not carry type info in its lambdas anymore (at least for functions).
* Add `-parameters` to the compiler args for possible method argument names discovery.
Essentially realign with the rest of portfolio
* Fix Kotlin tests for deprecated API
This commit is contained in:
Artem Bilan
2021-09-13 13:04:57 -04:00
committed by Gary Russell
parent 0f2285d5a3
commit 0fb64f1762
6 changed files with 21 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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.
@@ -235,13 +235,14 @@ public abstract class ClassUtils {
}
/**
* Check if class is Java lambda.
* Check if class is Java or Kotlin lambda.
* @param aClass the {@link Class} to check.
* @return true if class is a Java lambda.
* @return true if class is a Java or Kotlin lambda.
* @since 5.2
*/
public static boolean isLambda(Class<?> aClass) {
return aClass.isSynthetic() && !aClass.isAnonymousClass() && !aClass.isLocalClass();
return (aClass.isSynthetic() && !aClass.isAnonymousClass() && !aClass.isLocalClass())
|| aClass.getName().contains("$inlined$"); // for Kotlin lambdas
}
/**

View File

@@ -245,7 +245,7 @@ class KotlinDslTests {
fun functionFlow() =
integrationFlow<Function<ByteArray, String>>({ beanName("functionGateway") }) {
transform(Transformers.objectToString()) { id("objectToStringTransformer") }
transform<String> { it.toUpperCase() }
transform<String> { it.uppercase() }
split<Message<*>> { it.payload }
split<String>({ it }) { id("splitterEndpoint") }
resequence()
@@ -312,7 +312,7 @@ class KotlinDslTests {
channel { queue("wireTapChannel") }
}
delay("delayGroup") { defaultDelay(100) }
transform<String> { it.toUpperCase() }
transform<String> { it.uppercase() }
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018-2020 the original author or authors.
* Copyright 2018-2021 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.
@@ -154,7 +154,7 @@ class FunctionsTests {
@Bean
@Transformer(inputChannel = "functionServiceChannel")
fun kotlinFunction(): (String) -> String {
return { it.toUpperCase() }
return { it.uppercase() }
}
@Bean
@@ -187,7 +187,7 @@ class FunctionsTests {
@Bean
fun monoFunctionGateway() =
integrationFlow<MonoFunction>({ proxyDefaultMethods(true) }) {
handle<String>({ p, _ -> Mono.just(p).map(String::toUpperCase) }) { async(true) }
handle<String>({ p, _ -> Mono.just(p).map(String::uppercase) }) { async(true) }
}
}