throwWithStackTrace 静态方法
- @Since("2.16")
- Object error,
- StackTrace stackTrace
抛出带有相关堆栈跟踪的错误 stackTrace。
如果 StackTrace.current 在 throw 时的值为 stackTrace,则行为类似于 throw error。
类似于 throw,如果 error 继承自 Error 且之前未抛出,则其 Error.stackTrace 属性将被设置为 stackTrace。
此函数不保证保留 stackTrace 的标识。被此错误的 try/catch 捕获的 StackTrace 对象,或被设置为 error 的 Error.stackTrace 的对象,可能不是提供的参数中的同一 stackTrace 对象,但它将根据 StackTrace.toString 具有相同的内 容。
实现
@Since("2.16")
static Never throwWithStackTrace(Object error, StackTrace stackTrace) {
checkNotNullable(error, "error");
checkNotNullable(stackTrace, "stackTrace");
_throw(error, stackTrace);
}