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:
The J adapter class generator searches the generation name management file for a method having the same name and parameter.
If a matching method is found, it uses the corresponding COBOL method name.
If no matching method is found, it generates a new COBOL method and adds it to the generation name management file.
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
These naming rules also apply to class methods.
Java fields (variables) (class/instance) are associated with COBOL property methods. The same rules as those for methods also apply to property methods.
The way of assigning numbers may be different depending on the version of JDK or J2SDK used for adapter class generation.