Follow

Compile extremely large programs

COBOL programs can be extremely large, sometimes hundreds of thousands of lines of code.  Elastic COBOL is capable of compiling these large programs but there are restrictions on how large Java programs can be.  

If you compile a huge COBOL source file from either from the command line (ecobol command) or from within Eclipse you will likely see this message from the Java compiler:

$ ecobol mycode.cbl

Elastic COBOL V13.8.18 Copyright (C) 2010-2013 Heirloom Computing

LOC: 126992 (11711 variables in 316 records)
Warnings: 27
Errors: 0
Result: Compilation SUCCESSFUL
Building: Class files
mycode.java:36: error: code too large
static // initializer
^
1 error

Code generated from a COBOL program named XX.CBL is compiled into xx.java.  The error message code too large indicates the generated Java classes exceed the size the Java compiler is capable of handling.  To remedy this situation provide the -opt:large flag on the ecobol command line or as an Additional Parameter to the Eclipse COBOL Compiler Settings dialog box.  With this optimization flag for large source files, Elastic COBOL will generate multiple smaller files and use the Java class hierarchy to subclass large WORKING-STORAGE SECTIONs or PROCEDURE DIVISIONs.

This is still a large amount of code.  The Java compiler may require additional memory to compile these classes.  That can be set with the JAVA_TOOL_OPTIONS environment variable.

You can further reduce the amount of code that is produced (if you do not wish to maintain it as Java code) by specifying additional Elastic COBOL compiler options that compress its output.

The command with these new options would be:

$ export JAVA_TOOL_OPTIONS=-Xmx4096m
$ ecobol -opt:large -out:nocomments -out:shortnames mycode.cbl

Elastic COBOL V13.8.18 Copyright (C) 2010-2013 Heirloom Computing

LOC: 126992 (11711 variables in 316 records)
Warnings: 27
Errors: 0
Result: Compilation SUCCESSFUL
Building: Class files
$

Note:  To set Windows environment variables use the SET command instead of export.

See ecobol Options for a listing of all compiler options, or use ecobol -help.

Use Elastic COBOL version v13.8.18 or higher.  Use Eclipse "Install New Programs" to specify either the standard update site (http://www.elasticcobol.com/downloads/updates) or the "overnight build" site (http://www.elasticcobol.com/downloads/overnight) with the latest fixes.  Overnight builds have passed HCI regression tests but you may see differences or incompatibilities with the last standard release.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk