The java::throw Command


Usage:

java::throw throwableObj

The java::throw command throws a Java exception. throwableObj must be a valid Java object handle and must be an instance of java.lang.Throwable. Internally, the java::throw command sets the errorCode global variable to a list whose first element is the string "JAVA" and whose second element is throwableObj. Then, it generates a Tcl error to cause the script to return abruptly. The effect of calling the java::throw command is exactly the same as calling a Java method which throws a Java exception.

Example:

The following code will raise a java.lang.ClassNotFoundException.
java::throw [java::new ClassNotFoundException "bad class foo"]
Copyright © 1997-1998 Sun Microsystems, Inc.