RFC: (Java) SAX exceptions and new minor SAX version

(Note that this is not a major API change, and does not affect non-Java versions of SAX.)

Over on the sax-devel mailing list, Norman Walsh, who is involved with JAXP at Sun, has requested a small change to the SAXException class (see the archived thread).

When we were designing SAX quite a few years back, we needed the ability to embed an exception in another exception but Java did not support that, so we designed our own support. Starting with JDK 1.4, Java has supported embedded exceptions through the getCause method. Implementing getCause in SAXException would allow for more accurate stack traces and debugging, among other things.

Unfortunately, there is never such a thing as a perfectly backwards-compatible change. Chris Burdess pointed out that this change will break Java code that was calling initCause manually, and obviously, there will be some other differences in behaviour depending on which version of SAX people use. I believe that bringing SAX in line with modern Java usage (JDK 1.4 has itself been around for a while) is worth the trouble, and that very few applications would experience problems, but I’d like to see some wider discussion before I decide to put out a minor SAX release. Please let me know what you think, either by subscribing to the sax-devel list, posting a comment here, or posting your own blog entry and pinging this one.

This entry was posted in Uncategorized and tagged . Bookmark the permalink.

2 Responses to RFC: (Java) SAX exceptions and new minor SAX version

  1. Matthias says:

    Strong yes. As another poster I would have favoured the SAXException constructor to call #initCause but as mentioned some !@#!@# decided that calling #initCause twice is forbidden.

    ServletException should do the same thing. I hate it when cause chains break at ServletException.

Comments are closed.