jjzjj

addSuppressed

全部标签

java - 我需要一位专家让我了解 Java Throwable 的 addSuppressed 的作用?

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:JDK1.7Throwable`addSuppressed()`method所以Java在Throwable中有一个方法publicfinalvoidaddSuppressed(Throwableexception)这就是它的作用:Appendsthespecifiedexceptiontotheexceptionsthatweresuppressedinordertodeliverthisexception.Thismethodisthread-safeandtypicallycalled(automati

exception - JDK 1.7 可抛出的 `addSuppressed()` 方法

好吧,我通过了相关问题,我阅读了JDK1.7的源代码,但我没有找到答案。在这个问题中我想完全忽略fillInStackTrace。从JDK1.4开始,添加了initCause()方法。例如,当您使用核心反射来调用您收到InvocationTargetException的方法时,其中包含目标异常。当我看到这个功能时,我也开始在这样的场景中使用它try{//containssomecodethatcanthrownewIOException();}catch(IOExceptione){thrownewRuntimeException(e);}所以,我捕获了一个异常,我还没准备好在这里处理