Now, because we’re talking about an object-oriented language, the inheritance of classes is respected for the “catch” clause.If ArithmeticException is replaced with its superclass, RuntimeException, the catch block will catch all instances of the RuntimeException class and its subclasses (including ArithmeticException).

But, who would do that?

Below are the subclasses of RuntimeException taken from the Java Platform Standard Ed.8.

AnnotationTypeMismatchException, ArithmeticException, ArrayStoreException, BufferOverflowException, BufferUnderflowException, CannotRedoException, CannotUndoException, ClassCastException, CMMException,CompletionException, ConcurrentModificationException, DataBindingException, DateTimeException, DOMException, EmptyStackException, EnumConstantNotPresentException, EventException, FileSystemAlreadyExistsException,FileSystemNotFoundException, IllegalArgumentException, IllegalMonitorStateException, IllegalPathStateException, IllegalStateException, IllformedLocaleException, ImagingOpException, IncompleteAnnotationException,IndexOutOfBoundsException, JMRuntimeException, LSException, MalformedParameterizedTypeException, MalformedParametersException, MirroredTypesException, MissingResourceException, NegativeArraySizeException,NoSuchElementException, NoSuchMechanismException, NullPointerException, ProfileDataException, ProviderException, ProviderNotFoundException, RasterFormatException, RejectedExecutionException, SecurityException,SystemException, TypeConstraintException, TypeNotPresentException, UncheckedIOException, UndeclaredThrowableException, UnknownEntityException, UnmodifiableSetException, UnsupportedOperationException,WebServiceException, WrongMethodTypeException

What exception handling routine would be common for all these classes, but not others? You might as well catch all exceptions (including the others) in one clause. Defining the RuntimeException doesn’t seem to be very useful.

Contents

Background

Review of Exception Handling Basics

The Requirements

The Three-tiered Exception Handling Architecture

Summary