tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Hamilton <Er...@haht.com>
Subject Re: IOException API proposal
Date Wed, 14 Jun 2000 22:10:21 GMT
At 11:23 PM 6/14/00 +0200, Mark Brouwer wrote:
>I have written a rough proposal for
>the next JDK release and before sending it off, I thought well lets have
>a second opinion by some people doing a lot of exception handling :-)

Your proposal does address a real problem, but it's not the right answer.
Error numbers only work when either there is a single authority controlling
their assigment (as in errno.h and winerror.h) or when there is no
polymorphism, so that at runtime you know which authority to consult.  For
example, suppose you and I both write classes that extend java.io.Reader
(and therefore can throw IOException).  I decide that I will use error
number 15 to describe a particular error condition.  You, working
independently of me, decide to use 15 to describe some completely different
error condition.  Now consider the code fragment:

java.io.Reader r = getAReaderFromSomewhere();
try
{
    int i = r.read();
}
catch( java.io.IOException e )
{
    if( e.getErrno() == 15 )
       doSomethingSensible();
}

I submit that it is impossible for doSomethingSensible() to do anything
sensible  :-)

Error numbers cannot be chosen from a single flat namespace for the same
reasons that Java class names, ASN OIDs, and even DNS names cannot.

What's really needed is for java developers to to be much more aggressive
about subclassing the existing excepion classes.  

---------------------
Eric Hamilton
Technology Evangelist
HAHT Software					(919) 786-5213 
400 Newton Rd.				(888) GET HAHT
Raleigh, NC 27615				(919) 786-5254 fax 

http://www.haht.com

Mime
View raw message