The java::field Command


Usage:

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

The java::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 java::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.

% java::field Integer MAX_VALUE
2147483647

The java::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 [java::field java.util.Hashtable class]
% java::info class $cl
java.lang.Class

Copyright © 1997-1998 Sun Microsystems, Inc.