Skip to content

Commit 02f3fd2

Browse files
committed
Use box-impl function as factory for kotlin jvm inline class
1 parent 0e53942 commit 02f3fd2

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/main/java/com/fasterxml/jackson/databind/ext/KotlinSupport.java

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
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) {
@@ -12,4 +14,10 @@ public static boolean isJvmInlineClassSyntheticConstructor(Constructor<?> ctor)
1214
Class<?> lastParam = params[params.length - 1];
1315
return ctor.isSynthetic() && lastParam.getName().equals("kotlin.jvm.internal.DefaultConstructorMarker");
1416
}
17+
18+
public static boolean isJvmInlineClassSyntheticBoxingFunction(Method method) {
19+
return Modifier.isStatic(method.getModifiers())
20+
&& method.isSynthetic()
21+
&& method.getName().equals("box-impl");
22+
}
1523
}

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

+4
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.isJvmInlineClassSyntheticBoxingFunction(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)