private static Class<?>[] getConstructorParameterTypes(final Class<?> aClass, final Object... constructorArgs) {
    if (constructorArgs.length == 0) return ArrayUtil.EMPTY_CLASS_ARRAY;

    loop: for (final Constructor<?> constructor : aClass.getDeclaredConstructors()) {
      if (constructor.getParameterCount() == constructorArgs.length) {
        final Class<?>[] parameterTypes = constructor.getParameterTypes();
        for (int i = 0; i < parameterTypes.length; i++) {
          Class<?> parameterType = parameterTypes[i];
          final Object constructorArg = constructorArgs[i];
          if (!parameterType.isInstance(constructorArg) && constructorArg != null) {
            continue loop;
          }
        }
        return parameterTypes;
      }
    }
    throw new AssertionError("Cannot find constructor for arguments: " + Arrays.asList(constructorArgs));
  }
private static Class<?>[] getConstructorParameterTypes(final Class<?> aClass, final Object... constructorArgs)