class ReflectionUtils {

    public static Method
        getMethod(ClassLoader cl,
                  Class<?> clazz,
                  String methodName,
                  Collection<String> parameterTypes) throws ReflectiveOperationException {
        
        boolean hasPrimitive = false;
        Class<?>[] methodParameters = new Class<?> [parameterTypes.size()];
        Class<?>[] primitiveParameters = new Class<?> [parameterTypes.size()];
        
        Iterator<String> iter = parameterTypes.iterator(); 
        int i = 0;
        while (iter.hasNext()) {
            String parameter = iter.next();
            if (!parameter.contains(".")) {
                parameter = "java.lang." + parameter;
            }
            Class<?> parameterClass = cl.loadClass(parameter);
            methodParameters[i] = parameterClass;
            Class<?> primitive = wrappers2Primitive.get(parameterClass);
            if (primitive != null) {
                primitiveParameters[i] = primitive;
                hasPrimitive = true;
            } else {
                primitiveParameters[i] = parameterClass;
            }
            i++;
        }
        try {
            return clazz.getMethod(methodName, methodParameters);
        }
        catch (NoSuchMethodException ex) {
            if (hasPrimitive) {
               try {
                   return clazz.getMethod(methodName,primitiveParameters);
               }
               catch (NoSuchMethodException ex2) {
                   logger.warn("Unable to find method {} with primitive arguments {}", methodName, primitiveParameters);
               }
           }
           throw ex;
       }
    }

    private  ReflectionUtils();

}