Skip to content

Commit

Permalink
Use box-impl function as factory for kotlin jvm inline class
Browse files Browse the repository at this point in the history
  • Loading branch information
wplong11 committed Aug 4, 2023
1 parent d35a6bc commit a39e938
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package com.fasterxml.jackson.databind.ext;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class KotlinSupport {
public static boolean isJvmInlineClassSyntheticConstructor(Constructor<?> ctor) {
Class<?>[] params = ctor.getParameterTypes();
Class<?> lastParam = params[params.length - 1];
return ctor.isSynthetic() && lastParam.getName().equals("kotlin.jvm.internal.DefaultConstructorMarker");
}

public static boolean isJvmInlineClassSyntheticBoxingFunction(Method method) {
return Modifier.isStatic(method.getModifiers())
&& method.isSynthetic()
&& method.getName().equals("box-impl");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ private List<AnnotatedMethod> _findPotentialFactories(TypeFactory typeFactory,

private static boolean _isIncludableFactoryMethod(Method m)
{
if (KotlinSupport.isJvmInlineClassSyntheticBoxingFunction(m)) {
return true;
}

return Modifier.isStatic(m.getModifiers())
// 09-Nov-2020, ckozak: Avoid considering synthetic methods such as
// lambdas used within methods because they're not relevant.
Expand Down

0 comments on commit a39e938

Please sign in to comment.