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

5.8.4 Name that needs to be unique within an entire run unit

Java method names are normally used as they are in COBOL. However, Java permits multiple methods with a same name to be defined if they have different parameters. In this case, numbers are assigned to COBOL method names for identification. However, to take advantage of polymorphism (diversification) that is the characteristics of object-oriented programming, methods having the same name and parameter are always assigned the same name. This correspondence relationship must be consistent within the run unit of the COBOL program that uses the J adapter class generator. For instance, the java.io.ObjectInputStream class inherits the java.io.ObjectInput interface and java.io.InputStream class (see the figure below).

Relationships among java.io.ObjectInput interface, java.io.InputStream class, and java.io.ObjectInputStream class

For the adapter class corresponding to these interface and classes, methods of the same name must be generated for the read methods having the same parameters.

The J adapter class generator uses the generation name management file to manage the correspondence of method names across classes or interfaces. It then assigns numbers to methods with the same name according to the following rules:

  1. The J adapter class generator searches the generation name management file for a method having the same name and parameter.

  2. If a matching method is found, it uses the corresponding COBOL method name.

  3. If no matching method is found, it generates a new COBOL method and adds it to the generation name management file.

  4. A COBOL method name is generated according to the following rule:

    • The COBOL method name that is first added is the same as the Java method name.

    • The second and subsequent COBOL method names are assigned number in ascending order from 01.

Example

The object methods corresponding to the read methods of the java.io.ObjectInput interface, java.io.InputStream class, and java.io.ObjectInputStream class are assigned names as shown below:

Java method

COBOL method

java.io.ObjectInput interface

read()

java-io-ObjectInput class

read

read(byte[])

read-01

read(byte[], int, int)

read-02

java.io.InputStream class

read()

java-io-InputStream class

read

read(byte[])

read-01

read(byte[], int, int)

read-02

java.io.ObjectInputStream class

read()

java-io-ObjectInputStream class

read

read(byte[], int, int)

read-02

Note

The way of assigning numbers may be different depending on the order adapter classes are generated. Use the same generation name management file to generate adapter classes to be used under the same environment.

Supplement