throwWithStackTrace method Null safety

  1. @Since("2.16")
Never throwWithStackTrace(
  1. Object error,
  2. StackTrace stackTrace
)
@Since("2.16")

Throws error with associated stack trace stackTrace.

If error extends Error and has not yet been thrown, its stackTrace is set as well, just as if it was thrown by a throw. The actual stack trace captured along with the error, or set on error if it is an Error, may not be the stackTrace object itself, but will be a stack trace with the same content.

Implementation

@Since("2.16")
static Never throwWithStackTrace(Object error, StackTrace stackTrace) {
  checkNotNullable(error, "error");
  checkNotNullable(stackTrace, "stackTrace");
  _throw(error, stackTrace);
}