Compiler
Overview
The job of any compiler is to convert human-readable source code to an object that a computer can run. To accomplish this, isCOBOL performs the following steps:
1. The COBOL source code is translated to a Java source code.
The name of the Java source file is obtained by converting the name of the COBOL source file to upper-case and replacing dashes by underscores. For example, A COBOL source file whose name is Hello-World.cbl generates HELLO_WORLD.java.
2. If no errors occur, then Compiler looks for an existing class file (e.g. HELLO_WORLD.class) and deletes it, if it exists.
3. Finally, the Compiler compiles the Java source code generating a Java class file. The Java source code is then deleted unless you use the -jj option.
There are situations in which more than one class file is generated.
If the -d compiler option is used, a class file called program$Debug$Infos is generated in addition to the program class file.
If the source code contains PERFORM THREAD statements, a class file for each thread is generated in addition to the program class file. These classes are named using a progressive number (program$1, program$2, ..., etc).
If the program is object-oriented, a class file for each method is generated in addition to the program class. These classes are named using the method name (i.e. program$method).
If the source contains SEARCH statements, a class for each SEARCH is generated in addition to the program class. These classes are named using a progressive number (program$1, program$2, ..., etc).
If the -big compiler option is used, some class files are generated in addition to the program class file. These classes are named using the program name, the “inner” and “CONST” keywords, and progressive numbers. The –big behavior can be configured by the iscobol.compiler.max_constants * and iscobol.compiler.max_paragraphs * properties.
If the program contains ESQL statements with more than 700 host variables, additonal classes are generated (each containing a maximum of 700 variables). These classes are named using a progressive number (program$1, program$2, ..., etc). This behavior can be configured by the iscobol.compiler.max_hostvars * property.
If the source code contains SORT-RETURN and/or SORT-MESSAGE special registers, two additional classes are generated. The classes are named program$SortAbort and program$1.
If the source code contains OCCURS statements or object invocation in the SCREEN SECTION, a class file for each occurrence and each object invocation are generated in addition to the program class file. These classes are named using a progressive number (program$1, program$2, ..., etc.). If the OCCURS statement appears in the LINKAGE SECTION, a class of each occurrence is always generated. If the OCCURS statement appears in the WORKING-STORAGE SECTION, a class for each occurrence is generated only if the index is variable.
If the Screen Section contains dynamic values due to LENGTH OF, object invokation or FUNCTION syntaxes, an additional class for each one of these values is generated. The classes are named using a progressive number (program$1, program$2, ..., etc).
If the Screen Section contains control properties associated with referenced variables, for example: VALUE W-VALUE (offs:len) and offs or len are data-items (not constant values), then an additional class for each one of these cases is generated. The classes are named using a progressive number (program$1, program$2, ..., etc). If the referenced variable appears in the LINKAGE SECTION, a class of each occurrence is always generated. If the referenced variable appears in the WORKING-STORAGE SECTION, a class for each occurrence is generated only if offs or len are variables.
The command to execute the compiler is:
iscc Options SourceCode
Note: On Windows this command should be launched from inside the isCOBOL Shell. Otherwise you need to set the ISCOBOL and ISCOBOL_JDK_ROOT environment variables before using iscc.
Compiling multiple source files at once
The isCOBOL compiler supports the * wildcard in the SourceCode parameter.
For example, the following compilations:
iscc prog1.cbl
iscc prog2.cbl
iscc prog3.cbl
iscc prog4.cbl
can be done all at once with the command:
iscc prog*.cbl
Automatic compilation of referenced COBOL classes
If a COBOL program references a COBOL class with object oriented syntax, the COBOL class is automatically compiled if necessary.
Consider the following source files, for example:
prog1.cbl
       program-id. prog1.
       configuration section.
       repository.
           class class1 as "class1".
       procedure division.
       main.
           invoke class1 "method1".
           goback.
class1.cbl
       class-id. class1 as "class1".
       identification division.
       factory.
       procedure division.
       identification division.
       method-id. method1 as "method1".
       procedure division.
       main.
      *    method code here
       end method method1.
       end factory.
When prog1.cbl is compiled, if CLASS1.class is not found in the Classpath, then the Compiler tries to compile class1.cbl before proceeding with the compilation of prog1.cbl.
This feature can be disabled by adding the -noarcc option to the Compiler command line.
Exit status
The Compiler returns 0 if the compilation is OK and a number greater than 0 if the compilation fails. When you compile multiple source files at once, if any of these files produce severe errors, then the return code will be greater than zero.
The following table lists the possible exit status codes returned by the Compiler:
Exit Code
Meaning
0
No errors
1
A Java exception occurred during the compilation process (e.g. ClassNotFoundException: com.sun.tools.javac.Main)
4
Compilation failed due to Severe errors
5
Invalid command line (e.g. unsupported option)