欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

java ArrayIndexOutOfBoundsException没有堆栈信息问题,,在日志中看到了java.

来源: javaer 分享于  点击 253 次 点评:203

java ArrayIndexOutOfBoundsException没有堆栈信息问题,,在日志中看到了java.


在日志中看到了java.lang.ArrayIndexOutOfBoundsException异常,但是堆栈信息都是空的,程序在catch这个异常后确实是打印堆栈了。

经过google找到了解决方法:

需要在java的虚拟机参数中添加-XX:-OmitStackTraceInFastThrow选项,这样就可以得到此异常的堆栈信息了。

关于虚拟机参数-XX:-OmitStackTraceInFastThrow的官方说明如下:

The compiler in the server VM now provides correct stack backtraces for all "cold" built-in exceptions. For performance purposes, when such an exception is thrown a few times, the method may be recompiled. After recompilation, the compiler may choose a faster tactic using preallocated exceptions that do not provide a stack trace. To disable completely the use of preallocated exceptions, use this new flag: -XX:-OmitStackTraceInFastThrow.

相关栏目:

用户点评