Finds the best equally-matching constructors for the given arguments.
@param <T>
@param clazz
@param args
@return constructors
161670
public static <T> Constructor<T>[] candidateConstructors(Class<T> clazz, Object[] args) {
        return candidateConstructors(collectConstructors(clazz), args);
    }
1239709
public static <T> T getInstance(Class<T> clazz, Class<?>[] paramTypes, Object[] params) {
        Assert.isTrue(CollectionUtil.safeSizeOf(paramTypes) == CollectionUtil.safeSizeOf(params));
        try {
            Constructor<T> constructor = clazz.getConstructor(paramTypes);
            ReflectUtil.allowAccess(constructor);
            return constructor.newInstance(params);
        } catch (Exception e) {
            throw new ReflectException("获取类实例异常，可能是没有默认无参构造器", e);
        }
    }
43977
protected Constructor<?> getConstructor(Class<?> clazz, Class<?> paramClass) {
        for (Constructor<?> c : clazz.getConstructors()) {
            Class<?>[] paramTypes = c.getParameterTypes();
            if (paramTypes.length != 1) {
                continue;
            }
            if (paramTypes[0].equals(paramClass)) {
                return c;
            }
        }
        return null;
    }
918658
public static Class<?>[] collectArgTypes(final Object[] args) {
        final Class<?>[] result = new Class<?>[args.length];
        collectArgTypes(args, result, 0, 0, args.length);
        return result;
    }
1150041
@SuppressWarnings("unchecked")
    public static <T> Constructor<T> findMatchingConstructor(Class<T> classToInspect, Object... params) {
        Constructor<T> checkedConstructors = null;
        for (Constructor<?> constructor : classToInspect.getDeclaredConstructors()) {
            Type[] parameterTypes = constructor.getParameterTypes();
            if (parameterTypes.length == params.length && checkParameterTypes(parameterTypes, params)) {
                if (checkedConstructors == null) {
                    checkedConstructors = (Constructor<T>) constructor;
                } else {
                    throw BusinessException.createNew(BusinessErrorCode.AMBIGUOUS_CONSTRUCTOR_FOUND)
                            .put("constructor1", constructor)
                            .put("constructor2", checkedConstructors)
                            .put("object", classToInspect.getSimpleName())
                            .put("parameters", params);
                }
            }
        }
        return checkedConstructors;
    }
979179
@SuppressWarnings({"unchecked"})
    public static <T> Constructor<T> findPossibleConstructor( Class<T> klass, Object... args ) throws NoSuchMethodException
    {
        for (Constructor constructor : klass.getConstructors())
        {
            if (arityMatches(constructor, args)) return constructor;
        }

        throw noSuitableConstructorException(klass, args);
    }
205943
private static Method getMethod(String methodName, Class<?> clazz, Class<?>... args) {
        Method method;
        try {
            method = clazz.getMethod(methodName, args);
        } catch (NoSuchMethodException e1) {
            method = null;
        }
        return method;
    }
940189
public static Converter<?, ?> constructConverter(Class<? extends Converter<?, ?>> clazz) {
		Constructor<? extends Converter<?, ?>> constructor;
		try {
			constructor = clazz.getConstructor();
		} catch (Exception e) {
			throw new IllegalArgumentException("Could not find public no-arg constructor for CSV converter class: "
					+ clazz, e);
		}
		try {
			return constructor.newInstance();
		} catch (Exception e) {
			throw new IllegalArgumentException("Could not construct new CSV converter: " + clazz, e);
		}
	}
840502
@SuppressWarnings("unchecked")
    public <T> List<T> getAnnotations(final Class<? extends Annotation> clazz) {
        return (List<T>) foundAnnotations.get(clazz);
    }
1276479
public static <T> T newInstance(Constructor<T> constructor, Object... args) {
        try {
            return constructor.newInstance(args);
        } catch (Exception e) {
            throw new ClientException(e);
        }
    }
268828
public <T> Clazz<T> FindClazz( Class<T> clazz )
	{
		if( clazzz == null )
			return null;

		for( Clazz<?> c : clazzz.values() )
			if( c.getReflectedClass() == clazz )
			{
				@SuppressWarnings( "unchecked" )
				Clazz<T> result = (Clazz<T>) c;
				return result;
			}

		return null;
	}
605138
public static <T> Constructor<T>[] candidateConstructors(Constructor<T>[] constructors, Object[] args) {
        return candidateConstructors(constructors, collectArgTypes(args));
    }
79703
@SafeVarargs
    public static <T> Constructor<T> getDeclaredConstructor(final Class<T> cls, final Class<?>... parameterTypes) {
        Map<Class<?>[], Constructor<?>> constructorPool = classDeclaredConstructorPool.get(cls);
        Constructor<T> constructor = null;

        if (constructorPool != null) {
            constructor = (Constructor<T>) constructorPool.get(parameterTypes);
        }

        if (constructor == null) {
            try {
                constructor = cls.getDeclaredConstructor(parameterTypes);

                // SHOULD NOT set it true here.
                // constructor.setAccessible(true);
            } catch (NoSuchMethodException e) {
                // ignore.
            }

            if (constructor != null) {
                if (constructorPool == null) {
                    constructorPool = new ArrayHashMap<>(ConcurrentHashMap.class);
                    classDeclaredConstructorPool.put(cls, constructorPool);
                }

                constructorPool.put(parameterTypes.clone(), constructor);
            }
        }

        return constructor;
    }
525562
public static <T> Constructor<T>[] candidateConstructors(Constructor<T>[] constructors, Class<?>[] argTypes) {
        return candidates(constructors, collectSignatures(constructors), collectVarArgs(constructors), argTypes);
    }
899802
private static Class[] initParamsClasses(final Object... args) {
		int count = 0;
		Class[] intArgsClass = null;
		if (args != null) {
			intArgsClass = new Class[args.length];
			for (final Object arg : args) {
				intArgsClass[count++] = arg.getClass();
			}
		}
		return intArgsClass;
	}
480171
public static MethodHandle findDefaultConstructor(Class<?> clazz) {
    MethodHandle methodHandle = null;
    try {
      Constructor<?> constructor = clazz.getConstructor();
      methodHandle = MethodHandles.publicLookup().unreflectConstructor(constructor);
    } catch (NoSuchMethodException | SecurityException | IllegalAccessException e) {
      // No default constructor
    }
    return methodHandle;
  }
1199213
public static Method[] candidateMethods(Class<?> clazz, String name, Class<?>[] argTypes) {
        return candidateMethods(collectMethods(clazz, name), argTypes);
    }