Exceptions
SST supports the catching and throwing of Java exceptions using the standard Smalltalk exception mechanism. All Java exceptions are represented in Smalltalk by a subclass of SstRmiThrowable. While there are many different Java exception classes, typically these can be represented by only a small number of Smalltalk classes. For example, the definition for the Java exception java.rmi.ServerError is as follows:
java_rmi_ServerError
^#((#class 'java.rmi.ServerError' 'java.rmi.RemoteException'
#SstRmiRemoteException 8455284893909696482 ##nil)
())
Notice that the Smalltalk implementation class is specified as SstRmiRemoteException. This can be done because exceptions are serializable and typical exceptions have no additional slots. Instances of SstRmiThrowable simply remember the Java class of the exception they represent.
Java remote exceptions (the only kind you can get using RMI) are caught using Smalltalk's standard when:do: family of protocols. Exceptions are thrown using an API of the class SstRmiThrowable. The detailed variation should only be used for Java exceptions having a detail slot.
kind: className message: message
Builds and answers a new instance of the receiver representing a Java exception of class @className with @message as its detailMessage. The answered object can be sent throw to invoke the exception.
throw: kind message: message [detail: detail]
Throws an exception signaling a Java-style exception of Java class @kind (such as java.io.IOException) with @message as the detailMessage and @detail as the detail of the exception. Such exceptions will be forwarded or returned to Java as instances of @kind. The actual exception thrown is SstRmiConstants::ExSstRmiException.
The receiver of these methods must be the implementation class that corresponds to the Java exception class (for example, @kind). This ensures proper serialization of the exception.
To ensure that these exceptions are propagated back to any calling RMI system, the invocation handlers in SST must be running with the forwardExceptions configuration option set to true. This is the default setting so typically you can safely ignore this issue.
Last modified date: 01/29/2015