storeField()
The javaLib.storeField() system function places the value of a class field or object field into the EGL Java™ object space.
- Running javaLib.remove() on the identifier to remove the object that was related to it.
- Relating the new object to the identifier.
If the class or object field contains a Java™ primitive instead of an object, EGL stores an object that represents the primitive. For example, if the field contains an int, EGL stores an object of type java.lang.Integer.
For more information about the EGL Java™ object space in which javaLib.storeField() 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 (see ExternalType part).
Syntax
javaLib.storeField(
storeId javaObjId in,
identifierOrClass javaObjIdOrClass in,
field STRING in)
- storeId
- A case-sensitive name that identifies the object. Input can be any variable or expression that is assignment compatible with the STRING type, and is cast to objID, as in a later example. EGL strips single- and double-byte blanks from the beginning and end of the argument value.
- identifierOrClass
- This argument is one of the following entities:
- A Java™ objID, to access a field of a Java™ object.
- A string representing the name of a Java™ class, to access a field of a Java™ class. EGL strips single- and double-byte blanks from the beginning and end of the argument value, which is case sensitive.
- field
- The case-sensitive name of a field within the specified object or class. Input can be any variable or expression that is assignment compatible with the STRING type. Single- and double-byte blanks are stripped from the beginning and end of the string.
Example
In this example, the javaLib.storeField() system
function places the value of myField in the object
space.
javaLib.storeField("myStoreId" as "objID:java",
"myId" as "objID:java", "myField");
Error considerations
If the v60ExceptionCompatibility program property is not set, or is set to NO, an exception causes a JavaObjectException. Other errors cause a RuntimeException.
If the v60ExceptionCompatibility program property is set to YES, an error during processing of javaLib.storeField() 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. |
| 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. |