将classname传递给方法

ryv*_*age 3 java instanceof

我的程序倾向于使用大量的包装异常(SwingWorker例如,包装所有异常ExecutionException).所以,我正在尝试编写一个方法,允许我检查异常或其任何原因是否instanceof是异常类型,但我不知道如何(如果可能的话)传递JUST类名作为方法的参数.

到目前为止,我有这个:

public static boolean errorOrCausesInstanceOfClass(Throwable e, Class c) {
    return e != null && (e.getClass().equals(c) || (e.getCause() != null && errorOrCausesInstanceOfClass(e.getCause(), c)));
}
Run Code Online (Sandbox Code Playgroud)

但这只有在e.getClass()完全相同的情况下才有效c.getClass().但是我想检查使用instanceof以捕获子类.

有没有办法实现这个目标?