Skip to content

Commit a9f511c

Browse files
committed
Remove reflection handling for kotlin.Unit class
There is just enough to check the value type name against "kotlin.Unit" literal. This way we don't need extra reflection bits to be exposed into a native image
1 parent daaa30e commit a9f511c

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

spring-integration-core/src/main/java/org/springframework/integration/aot/CoreRuntimeHints.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
100100

101101
Stream.of(
102102
"kotlin.jvm.functions.Function0",
103-
"kotlin.jvm.functions.Function1",
104-
"kotlin.Unit")
103+
"kotlin.jvm.functions.Function1")
105104
.forEach(type ->
106105
reflectionHints.registerTypeIfPresent(classLoader, type, MemberCategory.INVOKE_PUBLIC_METHODS));
107106

spring-integration-core/src/main/java/org/springframework/integration/util/ClassUtils.java

+1-18
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ public abstract class ClassUtils {
8484
*/
8585
public static final Class<?> KOTLIN_FUNCTION_1_CLASS;
8686

87-
/**
88-
* The {@code kotlin.Unit} class object.
89-
*/
90-
public static final Class<?> KOTLIN_UNIT_CLASS;
91-
9287
static {
9388
PRIMITIVE_WRAPPER_TYPE_MAP.put(Boolean.class, boolean.class);
9489
PRIMITIVE_WRAPPER_TYPE_MAP.put(Byte.class, byte.class);
@@ -166,23 +161,11 @@ public abstract class ClassUtils {
166161
finally {
167162
KOTLIN_FUNCTION_1_CLASS = kotlinClass;
168163
}
169-
170-
kotlinClass = null;
171-
try {
172-
kotlinClass = org.springframework.util.ClassUtils.forName("kotlin.Unit", defaultClassLoader);
173-
}
174-
catch (ClassNotFoundException e) {
175-
//Ignore: assume no Kotlin in classpath
176-
}
177-
finally {
178-
KOTLIN_UNIT_CLASS = kotlinClass;
179-
}
180164
}
181165
else {
182166
KOTLIN_FUNCTION_0_CLASS = null;
183167
KOTLIN_FUNCTION_0_INVOKE_METHOD = null;
184168
KOTLIN_FUNCTION_1_CLASS = null;
185-
KOTLIN_UNIT_CLASS = null;
186169
}
187170
}
188171

@@ -278,7 +261,7 @@ public static boolean isKotlinFunction1(Class<?> aClass) {
278261
* @since 5.3.2
279262
*/
280263
public static boolean isKotlinUnit(Class<?> aClass) {
281-
return KOTLIN_UNIT_CLASS != null && KOTLIN_UNIT_CLASS.isAssignableFrom(aClass);
264+
return "kotlin.Unit".equals(aClass.getName());
282265
}
283266

284267
}

0 commit comments

Comments
 (0)