code: public static void fireDeclaredRootCause(Throwable t, Class... declaredTypes) {
          Throwable root = t;
          while (root != null) {
              Throwable cause = root.getCause();
              if (cause == null) {
                  break;
              }
              root = cause;
          }
          fireDeclared(root, declaredTypes);
      }
docs: Throws the root cause of the given exception if it is unchecked or an
  instance of any of the given declared types. Otherwise, it is thrown as
  an UndeclaredThrowableException. If the root cause is null, then the
  original exception is thrown. This method only returns normally if the
  exception is null.
  
  @param t exception whose root cause is to be thrown
  @param declaredTypes if exception is checked and is not an instance of
  any of these types, then it is thrown as an
  UndeclaredThrowableException.