Skip to content

Commit 0e53942

Browse files
committed
Use kotlin jvm inline class synthetic constructors
1 parent 7d112ec commit 0e53942

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.fasterxml.jackson.databind.ext;
2+
3+
import java.lang.reflect.Constructor;
4+
5+
public class KotlinSupport {
6+
public static boolean isJvmInlineClassSyntheticConstructor(Constructor<?> ctor) {
7+
Class<?>[] params = ctor.getParameterTypes();
8+
if (params.length == 0) {
9+
return false;
10+
}
11+
12+
Class<?> lastParam = params[params.length - 1];
13+
return ctor.isSynthetic() && lastParam.getName().equals("kotlin.jvm.internal.DefaultConstructorMarker");
14+
}
15+
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import com.fasterxml.jackson.databind.AnnotationIntrospector;
1313
import com.fasterxml.jackson.databind.JavaType;
14+
import com.fasterxml.jackson.databind.ext.KotlinSupport;
1415
import com.fasterxml.jackson.databind.introspect.AnnotatedClass.Creators;
1516
import com.fasterxml.jackson.databind.type.TypeFactory;
1617
import com.fasterxml.jackson.databind.util.ClassUtil;
@@ -406,6 +407,6 @@ private final AnnotationMap collectAnnotations(AnnotatedElement main, AnnotatedE
406407

407408
// for [databind#1005]: do not use or expose synthetic constructors
408409
private static boolean isIncludableConstructor(Constructor<?> c) {
409-
return !c.isSynthetic();
410+
return !c.isSynthetic() || KotlinSupport.isJvmInlineClassSyntheticConstructor(c);
410411
}
411412
}

0 commit comments

Comments
 (0)