Use object types
- Last Updated: December 18, 2019
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
In order to support strong typing of references to objects, a class or interface type can be used to specify a data type in a variable definition. The variable can then be used to hold an object reference, which is a value that references an instance of a class and its members. The object type name that defines the object reference can identify a class or an interface. If it identifies an interface, the object reference is used to point to an instance of a class that implements the specified interface. This interface can be an interface type that the class instance explicitly implements or a super interface inherited by the explicitly implemented interface.
The object type name for a class or interface consists of two
parts—a class or interface name preceded by a qualifying package
name, for example, Classes.Inventory.MyClass. The
package name corresponds to a directory path (related to PROPATH)
where the class file that defines the class or interface type is
stored, and the class or interface name is identical to the class filename.
In a supported context, you can reference an object type without
its qualifying package name. For more information, see Specify unqualified class or interface type names. For
more information on class or interface type names, see Define and reference object type names.
An object reference is comparable to the HANDLE data
type, with the important distinction that an object reference identifies
a specific object type that a variable or field defined for that
object reference can hold. This allows the compiler to verify that
all uses of the object reference are correct, which is not possible with
a weakly typed handle.
In addition to a variable, you can define the following ABL elements to hold an object reference to a class or interface data type:
- A property or the return type of a method or user-defined function
- A parameter to a method, local procedure, or user-defined function
- A field in a temp-table, which must always be defined as the
root class type,
Progress.Lang.Object
You can pass an object reference as a parameter between an application server and an ABL client, as long as the object’s class satisfies certain restrictions and the class is defined on both the client and server sides. See Pass object reference parameters for more information.
You never use an object reference to access static members of a class. Instead, you can use a class type name to access the static members of a class. For more information, see Access static members.
For more information on defining and using object references to class and interface types, see Instantiate and manage class-based objects.