The javaLib.setField() system function sets the value of a field in a local Java™ object or class. To accomplish this, EGL invokes the local Java "set" method for the field.
For more about the EGL Java object space in which javaLib.setField() and similar functions operate, see Java access functions. EGL maintains this method of Java access for compatibility with earlier versions. For new code, use the more powerful ExternalType syntax; for more information, see ExternalType part.
javaLib.setField( identifierOrClass javaObjId in, field STRING in, value JavaType in)
Input can be any variable or expression that is assignment compatible with the STRING type. If you specify an identifier of an object, the identifier must be cast to objID, as in a later example. EGL strips single- and double-byte blanks from the beginning and end of the argument value.
The following example sets the field myField in the object identified by myId to the value in myNumField.
javaLib.setField("myId" as "objID:java", "myField", myNumField as "java:short");
If the v60ExceptionCompatibility program property is not set, or is set to NO, an exception causes EGL to throw a JavaObjectException. Other errors cause EGL to throw a RuntimeException.
If the v60ExceptionCompatibility program property is set to YES, an error during processing of javaLib.setField() can set sysVar.errorCode to a value listed in the next table.
Value in sysVar.errorCode | Description |
---|---|
00001000 | An exception was thrown by an invoked method or as a result of a class initialization |
00001001 | The object was null, or the specified identifier was not in the object space |
00001002 | A public method, field, or class with the specified name does not exist or cannot be loaded |
00001003 | The EGL primitive type does not match the type expected in Java |
00001007 | A SecurityException or IllegalAccessException was thrown during an attempt to get information about a method or field; or an attempt was made to set the value of a field that was declared final |
00001009 | An identifier rather than a class name must be specified; the method or field is not static |