Object Data Type

The object data type allows you to define a Java object. You specify the object data type as follows:

 * Variable MyString is a Java String object.
D MyString        S               O   CLASS(*JAVA
D                                          :'java.lang.String')

or as follows:

D bdcreate        PR              O   EXTPROC(*JAVA
D                                            :'java.math.BigDecimal'
D                                            :*CONSTRUCTOR)

In position 40, you specify data type O. In the keyword section, you specify the CLASS keyword to indicate the class of the object. Specify *JAVA for the environment, and the class name.

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 CLASS keyword. 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.



[ Top of Page | Previous Page | Next Page | Contents | Index ]