skip to main content

Converting Java Source Code to Object-oriented COBOL : Known cases of Java syntax that is not directly translatable to COBOL : Generic classes and type-variables

Generic classes and type-variables
A generic class is defined with the following format:
The type parameter section, delimited by angle brackets (<>), follows the class name. It specifies the type parameters (also called type variables) T1, T2, ..., and Tn.
This kind of syntax has no equivalent in COBOL, so you don’t have other choice but to discard it.
The following example
import java.util.ArrayList;
public class ALtest {
    public static void main (String[] args) {
        ArrayList<String> al = new ArrayList<String>();
        al.add(new String("xxx"));
is translated to isCOBOL as follows:
       program-id. ALtest.
       configuration section.
       repository.
           class ArrayList as "java.util.ArrayList"
           class JString   as "java.lang.String"
       working-storage section.
       77 al object reference ArrayList.
       procedure division.
           set al to ArrayList:>new().
           al:>add(JString:>new("xxx")).
Note that it will generate the following warnings at compile time:

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left