Object Data Type
The object data type allows you to define a Java™ object.
DCL-S MyString OBJECT(*JAVA : 'java.lang.String');
DCL-PR bdcreate OBJECT EXTPROC(*JAVA : 'java.math.BigDecimal'
: *CONSTRUCTOR);
val UCS2(100) CONST;
END-PR;
* Variable MyString is a Java String object.
D MyString S O CLASS(*JAVA
D :'java.lang.String')
D bdcreate PR O EXTPROC(*JAVA
D :'java.math.BigDecimal'
D :*CONSTRUCTOR)
For both the OBJECT keyword and the CLASS keyword, you specify *JAVA for the first parameter, and the class name for the second parameter.
If the object is the return type of a Java constructor, the class of the returned object is the same as the class of the method so you do not specify the parameters of the OBJECT keyword in a free-form definition, or the CLASS keyword in a fixed-form definition. Instead, you specify the EXTPROC keyword with environment *JAVA, the class name, and procedure name *CONSTRUCTOR.
An object cannot be based. It also cannot be a subfield of a data structure.
If an object is an array or table, it must be loaded at runtime. Pre-run and compile-time arrays and tables of type Object are not allowed.
Every object is initialized to *NULL, which means that the object is not associated with an instance of its class.
To change the contents of an object, you must use method calls. You cannot directly access the storage used by the object.
Classes are resolved at runtime. The compiler does not check that a class exists or that it is compatible with other objects.