OBJECT REFERENCE phrase

A data item defined with the OBJECT REFERENCE phrase is an object reference. An object reference data item is a 4-byte elementary item or an 8-byte elementary item depending on whether the LP(32) or LP(64) is in effect. If LP(32) is in effect, 4 bytes are allocated for the item; otherwise, 8 bytes are allocated for the item.

class-name-1
An optional class name.

You must define class-name-1 in the REPOSITORY paragraph in the configuration section of the containing class or outermost program.

If specified, class-name-1 indicates that data-name-1 always refers to an object-instance of class class-name-1 or a class derived from class-name-1.

Important: The programmer must ensure that the referenced object meets this requirement; violations are not diagnosed.

If class-name-1 is not specified, the object reference can refer to an object of any class. In this case, data-name-1 is a universal object reference.

You can specify data-name-1 within an alphanumeric group item without affecting the semantics of the group item. There is no conversion of values or other special handling of the object references when statements are executed that operate on the group. The group continues to behave as an alphanumeric group item.

An object reference can be defined in any section of the DATA DIVISION of a factory definition, object definition, method, or program. An object-reference data item can be used in only:

  • A SET statement (format 7 only)
  • A relation condition
  • An INVOKE statement
  • The USING or RETURNING phrase of an INVOKE statement
  • The USING or RETURNING phrase of a CALL statement
  • A program procedure division or ENTRY statement USING or RETURNING phrase
  • A method procedure division USING or RETURNING phrase

Object-reference data items:

  • Are ignored in CORRESPONDING operations
  • Are unaffected by INITIALIZE statements
  • Can be the subject or object of a REDEFINES clause
  • Cannot be a conditional variable
  • Can be written to a file (but upon subsequent reading of the record the content of the object reference is undefined)

A VALUE clause for an object-reference data item can contain only NULL or NULLS.

You can use the SYNCHRONIZED clause with the USAGE OBJECT REFERENCE clause to obtain efficient alignment of the object-reference data item.

The JUSTIFIED, PICTURE, and BLANK WHEN ZERO clauses cannot be used to describe group or elementary items defined with the USAGE OBJECT REFERENCE clause.