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
This commit is contained in:
Artem Bilan
2022-10-07 12:18:32 -04:00
parent daaa30e67f
commit a9f511c170
2 changed files with 2 additions and 20 deletions

View File

@@ -100,8 +100,7 @@ class CoreRuntimeHints implements RuntimeHintsRegistrar {
Stream.of(
"kotlin.jvm.functions.Function0",
"kotlin.jvm.functions.Function1",
"kotlin.Unit")
"kotlin.jvm.functions.Function1")
.forEach(type ->
reflectionHints.registerTypeIfPresent(classLoader, type, MemberCategory.INVOKE_PUBLIC_METHODS));

View File

@@ -84,11 +84,6 @@ public abstract class ClassUtils {
*/
public static final Class<?> KOTLIN_FUNCTION_1_CLASS;
/**
* The {@code kotlin.Unit} class object.
*/
public static final Class<?> KOTLIN_UNIT_CLASS;
static {
PRIMITIVE_WRAPPER_TYPE_MAP.put(Boolean.class, boolean.class);
PRIMITIVE_WRAPPER_TYPE_MAP.put(Byte.class, byte.class);
@@ -166,23 +161,11 @@ public abstract class ClassUtils {
finally {
KOTLIN_FUNCTION_1_CLASS = kotlinClass;
}
kotlinClass = null;
try {
kotlinClass = org.springframework.util.ClassUtils.forName("kotlin.Unit", defaultClassLoader);
}
catch (ClassNotFoundException e) {
//Ignore: assume no Kotlin in classpath
}
finally {
KOTLIN_UNIT_CLASS = kotlinClass;
}
}
else {
KOTLIN_FUNCTION_0_CLASS = null;
KOTLIN_FUNCTION_0_INVOKE_METHOD = null;
KOTLIN_FUNCTION_1_CLASS = null;
KOTLIN_UNIT_CLASS = null;
}
}
@@ -278,7 +261,7 @@ public abstract class ClassUtils {
* @since 5.3.2
*/
public static boolean isKotlinUnit(Class<?> aClass) {
return KOTLIN_UNIT_CLASS != null && KOTLIN_UNIT_CLASS.isAssignableFrom(aClass);
return "kotlin.Unit".equals(aClass.getName());
}
}