You'll have to pass a Class array as an argument in to your custom invoke
method that has the explicit types to search for in the method signature instead of trying to determine types from the parameters directly. This is exactly why Class.getMethod(String, Class[])
requires the types instead of inferring from parameters.
Change your signature to something like this. Use the class array directly, instead of inferring types. Alternatively you could us a Collection instead of an array, this is merely for example.
public Object invoke(Object objectContainingMethod,String methodName, Class<?>[] types, Object...params)