---
title: "OmitStackTraceInFastThrow"
author: "dikar"
date: "2011-11-12T14:00:35Z"
tags: []
categories: ["开源软件"]
slug: "omitstacktraceinfastthrow"
draft: false
lastmod: "2011-11-12T14:00:35Z"
id: 1254846
url: "https://dikar.iteye.com/blog/1254846"
---

经常遇到由于这个参数而导致异常堆栈消失的问题，之前看过一篇blog大概有个映像，这里自己记录一下具体的内容。

 

可以参见这篇文章里的测试情况

 

 

## [Hotspot caused exceptions to lose their stack traces in production – and the fix](http://jawspeak.com/2010/05/26/hotspot-caused-exceptions-to-lose-their-stack-traces-in-production-and-the-fix/)

 

[http://jawspeak.com/2010/05/26/hotspot-caused-exceptions-to-lose-their-stack-traces-in-production-and-the-fix/](http://jawspeak.com/2010/05/26/hotspot-caused-exceptions-to-lose-their-stack-traces-in-production-and-the-fix/)

 

 

可以看sun官方针对这个的说明

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`.

 

 

[http://java.sun.com/j2se/1.5.0/relnotes.html#hotspot](http://java.sun.com/j2se/1.5.0/relnotes.html#hotspot)