Skip to content

Commit

Permalink
[FIXED JENKINS-25118] Matches primitives and wrapper types when match…
Browse files Browse the repository at this point in the history
…ing methods.
  • Loading branch information
ikedam committed Oct 13, 2014
1 parent 80d2ccb commit ba5b9ac
Showing 1 changed file with 10 additions and 0 deletions.
Expand Up @@ -32,6 +32,7 @@
import java.util.Set;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import org.apache.commons.lang.ClassUtils;

/**
* Assists in determination of which method or other JVM element is actually about to be called by Groovy.
Expand All @@ -58,6 +59,15 @@ private static boolean matches(@Nonnull Class<?>[] parameterTypes, @Nonnull Obje
// OK, this parameter matches.
continue;
}
if (
parameterTypes[i].isPrimitive()
&& parameters[i] != null
&& ClassUtils.primitiveToWrapper(parameterTypes[i]).isInstance(parameters[i])
) {
// Groovy passes primitive values as objects (for example, passes 0 as Integer(0))
// The prior test fails as int.class.isInstance(new Integer(0)) returns false.
continue;
}
// TODO what about a primitive parameter type and a wrapped parameter?
if (parameterTypes[i] == String.class && parameters[i] instanceof GString) {
// Cf. SandboxInterceptorTest and class Javadoc.
Expand Down

0 comments on commit ba5b9ac

Please sign in to comment.