Skip to content

Commit 887e79c

Browse files
committed
Use box-impl function as factory for kotlin jvm inline class
1 parent d35a6bc commit 887e79c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
package com.fasterxml.jackson.databind.ext;
22

33
import java.lang.reflect.Constructor;
4+
import java.lang.reflect.Method;
5+
import java.lang.reflect.Modifier;
46

57
public class KotlinSupport {
68
public static boolean isJvmInlineClassSyntheticConstructor(Constructor<?> ctor) {
79
Class<?>[] params = ctor.getParameterTypes();
810
Class<?> lastParam = params[params.length - 1];
911
return ctor.isSynthetic() && lastParam.getName().equals("kotlin.jvm.internal.DefaultConstructorMarker");
1012
}
13+
14+
public static boolean isJvmInlineClassBoxingFunction(Method method) {
15+
return Modifier.isStatic(method.getModifiers())
16+
&& method.isSynthetic()
17+
&& method.getName().equals("box-impl");
18+
}
1119
}

src/main/java/com/fasterxml/jackson/databind/introspect/AnnotatedCreatorCollector.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ private List<AnnotatedMethod> _findPotentialFactories(TypeFactory typeFactory,
278278

279279
private static boolean _isIncludableFactoryMethod(Method m)
280280
{
281+
if (KotlinSupport.isJvmInlineClassBoxingFunction(m)) {
282+
return true;
283+
}
284+
281285
return Modifier.isStatic(m.getModifiers())
282286
// 09-Nov-2020, ckozak: Avoid considering synthetic methods such as
283287
// lambdas used within methods because they're not relevant.

0 commit comments

Comments
 (0)