Java Conversions


About:

Any command that returns a Java object or primitive Java type will automatically convert the object or primitive type to a corresponding Tcl value. This conversion can be skipped by using the -noconvert option. This applies to the nsjava::call, nsjava::field, nsjava::prop, javaObj, and javaArrayObj commands. The nsjava::new command does not do any conversion because it makes no sense to convert a Java object that was just allocated. If the returned value is a primitive Java type it will be converted to an integer or floating-point Tcl value. If the result is a String object, then the Java string object is converted into a Tcl string. For all other object types, a Java object handle is created and returned. If the -noconvert option is specified a Java object handle is always returned.

Tcl values are also be converted to Java objects and primitive Java types when they are given as arguments to Java commands. The default conversion for all Tcl values is to match the signature of the method or constructor being called. If the tcl type can't be converted to match the method signature required type, then an exception will be thrown.

Copyright © 1997-1998 Sun Microsystems, Inc.