Exception的性能是差,原因在于ThrowablefillInStackTrace()方法

参见:http://www.blogjava.net/stone2083/archive/2010/07/09/325649.html

根本原因在于:
异常基类Throwable.java的public synchronized native Throwable fillInStackTrace()方法
方法介绍:
Fills in the execution stack trace. This method records within this Throwable object information about the current state of the stack frames for the current thread.
性能开销在于:
1. 是一个synchronized方法(主因)
2. 需要填充线程运行堆栈信息

 

另外透过JVM看Exception本质,可以看看Exception在底层是怎么实现的。