classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Informative throws


From: Eric Blake
Subject: Informative throws
Date: Thu, 26 Jul 2001 17:24:01 +0100

I just had an idea for another configure option.  For efficiency sake, when
Classpath throws an exception, the no-arg constructor results in fewer bytes
(both in the constant pool and in the executable code) and more speed (no
string concatenation or intern()ing).  But for debugging purposes (whether
debugging Classpath itself, or debugging another Java application while
using Classpath), it is nice to have meaningful exception messages, even
though it adds overhead.  So I am proposing we do something like this (this
is a rough proposal, I haven't coded any of it up yet):

in gnu.classpath.Configuration.in, add the option EXCEPTION_MESSAGES:
  /**
   * Controls whether exceptions explicitly thrown by Classpath will
   * be constructed with messages, set by configuring with
   * --enable-exception-messages.  If --enable-debug is set,
   * this will also be set.  Notice that exceptions thrown by
   * the VM are not affected by this option.
   */
  boolean EXCEPTION_MESSAGES = DEBUG || @EXCEPTION_MESSAGES@;

Then, in places like Integer.decode() (which, by the way, is buggy at the
moment), we could do things like this:

    if (str == null || (len = str.length()) == 0)
      if (Configuration.EXCEPTION_MESSAGES)
        throw new NumberFormatException("string null or empty");
      else
        throw new NumberFormatException();

Any feedback on this idea?

--
Eric Blake, Elixent, Castlemead, Lwr Castle St., Bristol BS1 3AG, UK
address@hidden   tel:+44(0)117 917 5611




reply via email to

[Prev in Thread] Current Thread [Next in Thread]