StackTraceElement[ ] tr;
try{
throw new Exception();
} catch(Exception e){
tr = e.getStackTrace();
}
//Do some track trace logging
The stack trace of any call is snagged via an exception so that the caller can be ascertained.
问下面哪个选项正确:
(A) An Exception cannot be instantiated outside of a real exception event
(B) Runtime().getRuntime().getStackTrace() is the proper call for this purpose
(C) StackTraceException is the correct class for this purpose
(D) Throwing the exception is unnecessary for retrieving its stack trace