Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #8411

Avoid creating a stacktrace prior to JDK 1.7

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail
From Jan Burse <janburse@fastmail.fm>
Newsgroups comp.lang.java.programmer
Subject Avoid creating a stacktrace prior to JDK 1.7
Date Fri, 30 Sep 2011 15:57:57 +0200
Organization albasani.net
Lines 44
Message-ID <j64ht6$o64$1@news.albasani.net> (permalink)
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.albasani.net ILRqm3PBapBa+Z9yw+3R2v0CeKMjivYkPNnE/KhOxCMRAofztEd34HBLNLFTyCeL3m4pnkjDHMcN7jtVz/M8yzgqMgzO8yQFGDv1g+272x6YmqBVN0kiCuZRW2xQUkUk
NNTP-Posting-Date Fri, 30 Sep 2011 13:57:58 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="O4eNuZm/lgQBpJvzG5jCA/e4NENKVk4eonoFGwv5BKuM+sQe9cfSK2wVuBtAIjmqAttFVx/Zx/RY7RKlz0yPtwEmQ3gjsK4n9Re/y5UYtcIIrwdx153XKPHETcNWj21N"; mail-complaints-to="abuse@albasani.net"
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0) Gecko/20110922 Firefox/7.0 SeaMonkey/2.4
Cancel-Lock sha1:0YjJFW469dmnMJOwuxKT9znhJ9I=
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8411

Show key headers only | View raw


Dear All,

I have the following code deep down in a
recursion which eats up a lot of stack.
The recursion is not shown but only
the code:

     Class<?> class;
     try {
         class = Class.forName(str);
     } catch (ClassNotFoundException x) {
         class = null;
     }

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?

Now I see in JDK 1.7 (*) a protected
constructor:

    package java.lang;

    protected Throwable(String message,
          Throwable cause,
          boolean enableSuppression,
          boolean writableStackTrace)

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.

But what if I have JDK 1.6 only available
and not JDK 1.7. Can I instruct an exception
to not fill the stack trace? And way
arround?

Bye

(*)
http://download.oracle.com/javase/7/docs/api/

Back to comp.lang.java.programmer | Previous | NextNext in thread | Find similar


Thread

Avoid creating a stacktrace prior to JDK 1.7 Jan Burse <janburse@fastmail.fm> - 2011-09-30 15:57 +0200
  Re: Avoid creating a stacktrace prior to JDK 1.7 Stanimir Stamenkov <s7an10@netscape.net> - 2011-10-01 13:27 +0300
    Re: Avoid creating a stacktrace prior to JDK 1.7 Jan Burse <janburse@fastmail.fm> - 2011-10-01 13:22 +0200
      Re: Avoid creating a stacktrace prior to JDK 1.7 Lew <lewbloch@gmail.com> - 2011-10-01 09:10 -0700
        Re: Avoid creating a stacktrace prior to JDK 1.7 Stanimir Stamenkov <s7an10@netscape.net> - 2011-10-01 20:31 +0300
        Re: Avoid creating a stacktrace prior to JDK 1.7 Jan Burse <janburse@fastmail.fm> - 2011-10-01 20:02 +0200
          Re: Avoid creating a stacktrace prior to JDK 1.7 Lew <lewbloch@gmail.com> - 2011-10-01 12:21 -0700
            Re: Avoid creating a stacktrace prior to JDK 1.7 Jan Burse <janburse@fastmail.fm> - 2011-10-01 22:04 +0200
              Re: Avoid creating a stacktrace prior to JDK 1.7 Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-10-01 16:24 -0400
                Re: Avoid creating a stacktrace prior to JDK 1.7 Jan Burse <janburse@fastmail.fm> - 2011-10-01 23:14 +0200
                Re: Avoid creating a stacktrace prior to JDK 1.7 Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-10-01 17:28 -0400
                Re: Avoid creating a stacktrace prior to JDK 1.7 Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-10-01 23:45 +0000
                Re: Avoid creating a stacktrace prior to JDK 1.7 Stanimir Stamenkov <s7an10@netscape.net> - 2011-10-02 00:58 +0300
                Re: Avoid creating a stacktrace prior to JDK 1.7 Jan Burse <janburse@fastmail.fm> - 2011-10-02 02:04 +0200
                Re: Avoid creating a stacktrace prior to JDK 1.7 Lew <lewbloch@gmail.com> - 2011-10-01 20:06 -0700
                Re: Avoid creating a stacktrace prior to JDK 1.7 Stanimir Stamenkov <s7an10@netscape.net> - 2011-10-02 13:14 +0300
                Re: Avoid creating a stacktrace prior to JDK 1.7 Lew <lewbloch@gmail.com> - 2011-10-02 08:37 -0700
                Re: Avoid creating a stacktrace prior to JDK 1.7 Jan Burse <janburse@fastmail.fm> - 2011-10-02 20:26 +0200
                Re: Avoid creating a stacktrace prior to JDK 1.7 Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-10-02 17:51 -0400
                Re: Avoid creating a stacktrace prior to JDK 1.7 Jan Burse <janburse@fastmail.fm> - 2011-10-03 01:32 +0200
    Re: Avoid creating a stacktrace prior to JDK 1.7 Stanimir Stamenkov <s7an10@netscape.net> - 2011-10-01 20:19 +0300
      Re: Avoid creating a stacktrace prior to JDK 1.7 Jan Burse <janburse@fastmail.fm> - 2011-10-01 20:04 +0200
        Re: Avoid creating a stacktrace prior to JDK 1.7 Stanimir Stamenkov <s7an10@netscape.net> - 2011-10-01 21:15 +0300

csiph-web