If an RMI error occurs and a subclass of RMIRuntimeException would be thrown then annotating a method with this can be used to replace the thrown exception. The specified type must have a constructor with a single Throwable or RMIRuntimeException parameter.
If the exception type specified in value() is a checked exception, then the annotated method must declare it
or any of its superclass in its throws
clause.
This annotation can be used to signal exceptions to the caller using a different kind. E.g. If I/O operations are done over RMI, then rethrowing RMI errors using IOException can be a good idea.
If a method is annotated with RMIForbidden then no calls will be made over the connection and the exception specified using this annotation will be directly thrown.
From: Annotation |