The nsjava::field Command


Usage:

nsjava::field ?-noconvert? objOrClass field ?value field value ...?

The nsjava::field command is used to manipulate public fields from Tcl. The objOrClass argument specifies either a fully qualified name of the declaring class of the field to access, or an object handle. The field argument specifies which field to manipulate. If an additional value parameter exists, then the field will be set to value, otherwise the current value of the field is returned. Multiple fields may be set via additional parameters by alternating field signatures and values. A full field signature is is required to specify shadowed fields of superclasses.

Examples:

The nsjava::field command can be used to get the value of a class or instance variable. In this example, we query the static variable java.lang.Integer.MAX_VALUE, which has the value 2147483647.

% nsjava::field Integer MAX_VALUE
2147483647

The nsjava::field command also supports getting the compiler simulated class field for a Class. This is the preferred method of getting a handle to a java.lang.Class object given a class name.

% set cl [nsjava::field java.util.Hashtable class]
% nsjava::info class $cl
java.lang.Class

Copyright © 1997-1998 Sun Microsystems, Inc.