19980416 errata and methods with exceptions

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 UTC