Top
NetCOBOL V11.0 J Adapter Class GeneratorUser's Guide
FUJITSU Software

5.5.5 Class method

Explanation

A public class method (static method) is mapped to a COBOL factory method.

Expansion format

METHOD-ID. internal-method-name AS "external-method-name" [OVERRIDE].
    ...
DATA DIVISION.
LINKAGE SECTION.
[parameter ...]
[return-value ...]
PROCEDURE DIVISION [USING parameter ...] [RETURNING return-value]
                                     [RAISING exception-class-name].
END METHOD internal-method-name.

Generation rules

  1. The internal method name is internally used by the J adapter class generator and cannot be viewed from the class user.

  2. The external method name is used to identify the method. The class user identifies the method with the external method name.

  3. An external method name is generated according to the following rules:

    JavaMethodName[-nn]
    • A Java method name is used as is as a COBOL method name.

    • If a same method name has already been assigned, the second and subsequent method names are each suffixed with a hyphen "-" followed by a two-digit number (01 to 99) to prevent name duplication. (see "5.8 Numbering Names".)

    • A name exceeding 160 characters is truncated after the 160th character.

  4. When a parameter is declared for the method, the corresponding parameter is generated. See "5.5.1 Data types" for the correspondence between parameter data types.

  5. When a return value is declared for the method, the corresponding return value is generated. See "5.5.1 Data types" for the correspondence between return value data types.

  6. When an exception is declared for the constructor, the RAISING specification is generated.

Generation example

The factory method corresponding to class method abs (long) of the java.lang.Math class is generated as shown below:

METHOD-ID. JM-ABS-01 AS "abs-01".                              [1]
    ...
LINKAGE SECTION.
01  RTN-VALUE  PIC S9(18) COMP-5. 
01  PARA-1  PIC S9(18) COMP-5.
PROCEDURE DIVISION USING PARA-1 RETURNING RTN-VALUE.
    ...
END METHOD JM-ABS-01.

Supplement

When a COBOL method name is generated from a Java method name, a number is assigned to secure the uniqueness of the name. The class browser or method name cross-reference list file can be used to check the correspondence between Java methods and COBOL methods. In the case of class browser, it can be identified from the parameter that appears during method selection. In the case of method name cross-reference list file, it can be identified from the type of argument of the constructor.