The Object Data Type and CLASS Keyword

Fields that can store objects are declared using the O data type. To declare a field of type O, code O in column 40 of the D-specification and use the CLASS keyword to provide the class of the object. The CLASS keyword accepts two parameters:
CLASS(*JAVA:class_name)

*JAVA identifies the object as a Java™ object. Class_name specifies the class of the object. It must be a character literal or named constant, and the class name must be fully qualified. The class name is case sensitive.

For example, to declare a field that will hold an object of type BigDecimal:
D bdnum           S               O   CLASS(*JAVA:'java.math.BigDecimal')
To declare a field that will hold an object of type String:
D string          S               O   CLASS(*JAVA:'java.lang.String')

Note that both class names are fully qualified and that their case exactly matches that of the Java class.

Fields of type O cannot be defined as subfields of data structures. It is possible to have arrays of type O fields, but pre-runtime and compile-time tables and arrays of type O are not allowed.


Feedback