W3C home > Mailing lists > Public > www-dom@w3.org > April to June 1998

19980416 errata and methods with exceptions

From: TAMURA Kent <kent@trl.ibm.co.jp>
Date: Fri, 17 Apr 1998 10:33:36 +0900
Message-Id: <199804170133.KAA04361@ns.trl.ibm.com>
To: www-dom@w3.org

Compililation erros in WD-DOM-19980416/java/*.java:

TreeIterator.java(13,48) : error J0232: Expected '{' or ';'
Node.java(21,58) : error J0232: Expected '{' or ';'
Node.java(24,58) : error J0232: Expected '{' or ';'
Node.java(26,57) : error J0232: Expected '{' or ';'
AttributeList.java(7,54) : error J0232: Expected '{' or ';'
AttributeList.java(9,46) : error J0232: Expected '{' or ';'
QueryOperator.java(11,11) : error J0056: Missing return type specification
QueryOperator.java(12,37) : error J0049: Undefined name 'QueryExpressionList'
QueryOperator.java(14,11) : error J0056: Missing return type specification
Element.java(7,42) : error J0049: Undefined name 'name'



in Node.java
>    public Node insertBefore(Node newChild, 
>             Node refChild)  public class NotMyChildException extends Exception {};
>    public Node replaceChild(Node newChild, 
>             Node oldChild)  public class NotMyChildException extends Exception {};
>    public Node removeChild(Node oldChild)
>             public class NotMyChildException extends Exception {};

These seem to mean `throws clause' such as "insertBefore(...)
throws NotMyChildException;".  But I strongly object to add
throws clauses to these method.

When a method has `throws clsuses', programmers *must* write
try-catch blocks even if the method never throw the exception.


For example, in the following code the insertBefore() method
never throw NotMyChildException.  But programmers must write a
try-catch block.

	try {
	    node.insertBefore(node2, null);
	} catch (NotMyChildException e) {
	    // The exception is never thrown.
	}

So, I propose that NotMyChildException and
NoSuchAttributeException and NoSuchNodeException inherit
java.lang.RuntimeException and methods with throws clauses are
declared such as:

    /**
     * @exception NotMyChildException
     */
    public Node insertBefore(Node newChild, Node refChild);

not `public Node insertBefore(Node newChild, Node refChild)
throws NotMyChildException'.

-- 
TAMURA, Kent @ Tokyo Research Laboratory, IBM Japan
Received on Thursday, 16 April 1998 21:34:19 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:45 GMT