store()
The javaLib.store() system function invokes a method, places the returned object (or a null value) into the EGL Java™ object space, and associates the object with a specified identifier.
- Running javaLib.remove() on the identifier to remove the object that was related to that identifier
- Relating the object that javaLib.store() returns with the specified identifier
If the method returns a Java™ primitive instead of an object, EGL stores an object that represents the primitive. For example, if the method returns an int, EGL stores an object of type java.lang.Integer.
For more information about the EGL Java™ object space in which javaLib.store() 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.store(
storeId javaObjId in,
identifierOrClass javaObjId in,
method STRING in
{, argument anyEGLPrimitive in} )
- storeId
- A case-sensitive name to identify the returned object. Input can be a variable or expression that is assignment compatible with the STRING type and is cast to objID. EGL strips single- and double-byte blanks from the beginning and end of the argument value.
- identifierOrClass
- The class or object whose method you are invoking. It is one of the following entities:
- A Java™ objID, to invoke a method of a local Java™ object.
- A string representing a class name, to invoke a method of a Java™ class. EGL strips single- and double-byte blanks from the beginning and end of the argument value, which is case sensitive.
- method
- The case-sensitive name of the method to invoke, not including parentheses. Input can be any variable or expression that is assignment compatible with the STRING type. EGL strips single- and double-byte blanks from the beginning and end of the argument value.
- argument
- A value passed to the method. A cast might be required; see "Mapping
EGL primitives to Java™." The Java™ type-conversion rules are in
effect. No error occurs, for example, if you pass a SMALLINT to a
method parameter that is declared as an int. To avoid losing precision,
use an EGL FLOAT for a Java™ double,
and an EGL SMALLFLOAT for a Java™ float.
If you use one of the other EGL types, you might cause a rounding
error.A value of an EGL external type is valid, as shown here:
SharedResourcePowerServer srps = JavaLib.getSharedResourcePowerServer(); JavaLib.store("storeId" as "objID:java", "myId" as "objID:java", "myMethod", srps);
Example
The following example invokes myMethod and associates
the results with storeID.
javaLib.store("storeId" as "objID:java", "myId" as "objID:java",
"myMethod", myVar as "java:smallfloat");
Error considerations
If the v60ExceptionCompatibility program property is not set, or is set to NO, an exception causes a JavaObjectException. Other errors can cause a RuntimeException.
If the v60ExceptionCompatibility program property is set to YES, an error during processing of javaLib.store() 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™ |
| 00001006 | The class of an argument cast to null could not 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 |