Comparing and setting object references
You can compare object references by coding conditional
statements or a call to the JNI service IsSameObject, and you can
set object references by using the
For example, code either
below to check whether the object reference anAccount refers to no
If anAccount = Null . . .
If anAccount = Nulls . . .
You can code a call to IsSameObject to check whether two object references, object1 and object2, refer to the same object instance or whether each refers to no object instance. To ensure that the arguments and return value are interoperable with Java™ and to establish addressability to the callable service, code the following data definitions and statements before the call to IsSameObject:
. . .
01 is-same Pic X.
88 is-same-false Value X'00'.
88 is-same-true Value X'01' Through X'FF'.
Set Address Of JNIEnv To JNIEnvPtr
Set Address Of JNINativeInterface To JNIEnv
Call IsSameObject Using By Value JNIEnvPtr object1 object2
If is-same-true . . .
Within a method you can
check whether an object reference refers to the object instance on
which the method was invoked by coding a call to IsSameObject that
compares the object reference and
can instead invoke the Java
(inherited from java.lang.Object) to determine whether two object
references refer to the same object instance.
can make an object reference refer to no object instance by using
SET statement. For example:
Set anAccount To Null.
You can also make one object reference refer to the
same instance as another object reference does by using the
Set anotherAccount To anAccount.
SET statement causes anotherAccount
to refer to the same object instance as anAccount does. If the receiver
(anotherAccount) is a universal object reference, the sender (anAccount)
can be either a universal or a typed object reference. If the receiver
is a typed object reference, the sender must be a typed object reference
bound to the same class as the receiver or to one of its subclasses.
a method you can make an object reference refer to the object instance
on which the method was invoked by setting it to
Set anAccount To Self.
The Java Native Interface (IsSameObject)