可以用下面这个函数:
public static <E extends Exception> void throwActualException(Exception exception) throws E { throw (E) exception; }
用法如下:
new Thread(()->{ try { String a = null; if(a == null){ throw new Exception("不能为空"); } }catch (Exception e){ throwActualException(e); } }).start();