Skip to content

Commit

Permalink
Blackbird: handle varargs constructor types as fixed arity
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenschlansker committed Jul 7, 2021
1 parent 7e6a872 commit 1d6b7c7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ public ValueInstantiator createOptimized()
methodType(Object.class, MethodHandle.class, Object[].class)),
methodType(Object.class, Object[].class))
.getTarget().invokeExact(
argsCreatorHandle.asSpreader(
argsCreatorHandle
.asFixedArity()
.asSpreader(
Object[].class,
argsCreatorHandle.type().parameterCount())
.asType(methodType(Object.class, Object[].class))))
Expand Down Expand Up @@ -107,10 +109,7 @@ private MethodHandle directHandle(AnnotatedElement element) {
Stream.of(element)
.filter(Constructor.class::isInstance)
.map(Constructor.class::cast)
.filter(c -> !Modifier.isPrivate(c.getModifiers())
// 07-Jul-2021, ckozak: modules-base#141Avoid attempting to optimize varargs
// methods due to class-cast edge cases
&& !c.isVarArgs())
.filter(c -> !Modifier.isPrivate(c.getModifiers()))
.flatMap(t -> {
try {
return Stream.of(_lookup.unreflectConstructor(t));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.blackbird.BlackbirdTestBase;

public class DoubleArrayDeserTest extends BlackbirdTestBase
public class DoublePrimitiveArrayConstructorDeser141Test extends BlackbirdTestBase
{
static class Foo141 {
@JsonProperty("bar")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.fasterxml.jackson.module.blackbird.BlackbirdTestBase;

// [modules-base#141]
public class DoubleVarArgsDeser141Test extends BlackbirdTestBase
public class DoublePrimitiveVarArgsConstructorDeser141Test extends BlackbirdTestBase
{
// [modules-base#141]
static class Foo141 {
Expand Down

0 comments on commit 1d6b7c7

Please sign in to comment.