Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Avoid creating a stacktrace prior to JDK 1.7 Date: Sun, 02 Oct 2011 17:51:06 -0400 Organization: A noiseless patient Spider Lines: 43 Message-ID: References: <4424828.699.1317485416810.JavaMail.geo-discussion-forums@prng5> <1058576.2212.1317496868028.JavaMail.geo-discussion-forums@prfh23> <16954967.979.1317524784002.JavaMail.geo-discussion-forums@prng5> <32945439.611.1317569831219.JavaMail.geo-discussion-forums@prni6> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 2 Oct 2011 21:51:11 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="f8igmItKsWs6nM5YanFxAA"; logging-data="27716"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/34q8WvkuzrOBiPdB8xyvg" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 In-Reply-To: Cancel-Lock: sha1:CSlOp+JF+d7hrs8e+U7jGmlY7D4= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8486 On 10/2/2011 2:26 PM, Jan Burse wrote: > > Lew schrieb: >> There's a difference between "no information" and "information that > > there is no information". The latter tells you something, at least. > > My original question was: How can I force an exception to not > record some stack frame list at all. > > One proposed solution so far was pre-allocating exceptions > from a call site with a few stack frames. Eventually also > calling the following method on the pre-allocated exception: > > setStackTrace(new StackTraceElement[0]); > > So as to even free the stack trace that was allocate from the > call site with only a few stack frames. The above method is > available since JDK 1.4. > > What about calling setStackTrace() just after the new and before > the throw. This would only give a space advantage but not a > time advantage. I've become confused about what you're looking for. The thread began with your desire to avoid filling a stack trace entirely: > Will it every time I call it for a > non-existing class build the whole stack > trace for the exception x and then > immediately forget about it? [...] > If I were to write my own forName() > method I would set the writableStackTrace > to false if the exception is only needed > to immediately notify the callee about > something. From this perspective, how does it improve matters if you replace a filled-in trace with a new one of your own devising, however short? What is your goal? -- Eric Sosman esosman@ieee-dot-org.invalid