public static @NotNull <T> T newInstance(@NotNull Class<T> aClass, boolean isKotlinDataClassesSupported) {
    try {
      Constructor<T> constructor = aClass.getDeclaredConstructor();
      try {
        constructor.setAccessible(true);
      }
      catch (SecurityException ignored) {
      }
      return constructor.newInstance();
    }
    catch (Exception e) {
      //noinspection InstanceofCatchParameter
      if (e instanceof InvocationTargetException) {
        Throwable targetException = ((InvocationTargetException)e).getTargetException();
        // handle ExtensionNotApplicableException also (extends ControlFlowException)
        if (targetException instanceof ControlFlowException && targetException instanceof RuntimeException) {
          throw (RuntimeException)targetException;
        }
      }

      if (isKotlinDataClassesSupported) {
        T t = createAsDataClass(aClass);
        if (t != null) {
          return t;
        }
      }

      ExceptionUtilRt.rethrowUnchecked(e);
      throw new RuntimeException(e);
    }
  }
public static @NotNull <T> T newInstance(@NotNull Class<T> aClass, boolean isKotlinDataClassesSupported)