Merge branch '6.2.x'
This commit is contained in:
@@ -316,13 +316,10 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||
Object arg = args[index];
|
||||
if (!(parameter.isOptional() && arg == null)) {
|
||||
KType type = parameter.getType();
|
||||
if (!(type.isMarkedNullable() && arg == null) && type.getClassifier() instanceof KClass<?> kClass
|
||||
if (!(type.isMarkedNullable() && arg == null)
|
||||
&& type.getClassifier() instanceof KClass<?> kClass
|
||||
&& KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
|
||||
KFunction<?> constructor = Objects.requireNonNull(KClasses.getPrimaryConstructor(kClass));
|
||||
if (!KCallablesJvm.isAccessible(constructor)) {
|
||||
KCallablesJvm.setAccessible(constructor, true);
|
||||
}
|
||||
arg = constructor.call(arg);
|
||||
arg = box(kClass, arg);
|
||||
}
|
||||
argMap.put(parameter, arg);
|
||||
}
|
||||
@@ -337,6 +334,20 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||
return (result == Unit.INSTANCE ? null : result);
|
||||
}
|
||||
|
||||
private static Object box(KClass<?> kClass, @Nullable Object arg) {
|
||||
KFunction<?> constructor = Objects.requireNonNull(KClasses.getPrimaryConstructor(kClass));
|
||||
KType type = constructor.getParameters().get(0).getType();
|
||||
if (!(type.isMarkedNullable() && arg == null)
|
||||
&& type.getClassifier() instanceof KClass<?> parameterClass
|
||||
&& KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(parameterClass))) {
|
||||
arg = box(parameterClass, arg);
|
||||
}
|
||||
if (!KCallablesJvm.isAccessible(constructor)) {
|
||||
KCallablesJvm.setAccessible(constructor, true);
|
||||
}
|
||||
return constructor.call(arg);
|
||||
}
|
||||
|
||||
private static void handleResult(Object result, SynchronousSink<Object> sink) {
|
||||
if (KotlinDetector.isInlineClass(result.getClass())) {
|
||||
try {
|
||||
@@ -357,7 +368,11 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||
}
|
||||
|
||||
private static Object unbox(Object result) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
|
||||
return result.getClass().getDeclaredMethod("unbox-impl").invoke(result);
|
||||
Object unboxed = result.getClass().getDeclaredMethod("unbox-impl").invoke(result);
|
||||
if (KotlinDetector.isInlineClass(unboxed.getClass())) {
|
||||
return unbox(unboxed);
|
||||
}
|
||||
return unboxed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user