private static <T extends Exception> T createException(final Class<T> clazz,
    final ForeignExceptionMessage eem) throws ClassNotFoundException, NoSuchMethodException,
    InstantiationException, IllegalAccessException, InvocationTargetException {
    final GenericExceptionMessage gem = eem.getGenericException();
    final Class<?> realClass = Class.forName(gem.getClassName());
    final Class<? extends T> cls = realClass.asSubclass(clazz);
    final Constructor<? extends T> cn = cls.getConstructor(String.class);
    cn.setAccessible(true);
    return cn.newInstance(gem.getMessage());
  }
Helper to convert Exceptions and StackTraces from/to protobuf. (see ErrorHandling.proto for the
internal of the proto messages)
hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/util/ForeignExceptionUtil.java