OBJECT{(*JAVA:class-name)}

The OBJECT keyword is used in a free-form definition to indicate that the item has type object.

It must be the first keyword.

The parameters are optional if the OBJECT keyword is used to define the type of the return value for a Java™ constructor method. In this case, the class of the return value is the same as the class of the Java method, so it is not necessary to specify the class again. See EXTPROC({*CL|*CWIDEN|*CNOWIDEN| {*JAVA:class-name:}}name) for information on defining the prototype for a Java constructor.

Otherwise, both parameters are required.

The first parameter must be *JAVA.

The second parameter specifies the Java class of the object. See Object Data Type for information on specifying the Java class. The parameter must be a literal or a named constant.

Note: If you do specify the parameters for the OBJECT keyword when defining the return value for a Java constructor, the class must be the same as the class specified by the EXTPROC keyword.
In the following example
  • Field str is defined as an object field of class java.lang.String.
  • The return value of the prototype newBigDecimal for the Java BigDecimal object constructor is defined as an object. The OBJECT keyword has no parameters, so the class of the return value, 'java.math.BigDecimal', is derived from the class specified in the EXTPROC keyword.

  DCL-S str OBJECT(*JAVA : 'java.lang.String');

  DCL-PR newBigDecimal OBJECT EXTPROC(*JAVA : 'java.math.BigDecimal'
                                            : *CONSTRUCTOR);
     val VARUCS2(100) CONST;
  END-PR;