Java Generation Options

Several Elastic COBOL compiler options allow variations in the generation of Java source code. Although the basic structure of the Java program is roughly the same no matter what the options are, the generated code can be simplified or expanded as necessary. This document covers the primary options influencing the output. See other Forum articles for related topics such as,

Java Integration Options

Use -out:importjava java-import-class to include specific Java import statements at the top of the generated code. Use -out:package your-package-name to create Java output directory hierarchy and include the Java package statement in each Java class.

Dealing with Java Restrictions

Java programs have more restrictions than COBOL programs, they can contain only so many source lines and variable declarations. Use -opt:large if Java errors occur because of size issues (javac error message "Java: Too many lines."). For finer control, use -opt:break n to break up a large program into Java modules of n lines or less. To break any program, large or small, on COBOL section or paragraph boundaries use -opt:break section or -opt:break para.

Simplify Java Names

Use -out:translate to translate COBOL element names to simpler Java variable names without the implied group hierarchy. Deduplification of names will occur. Elastic COBOL must generate a COBOL-compatible linear memory array to back groups and elements so that either internally or externally (e.g., by invoking business rules) referenced groups and elements within them can be modified or referenced in such a way that the other "view" is available at all times. This option also generates an offset

Optimized Sparse Arrays

Use -opt:occurs to optimize OCCURS (arrays) to generate simulated array Java objects in such as way that sparsely populated arrays will take limited time to initialize and reduce the memory footprint. Use -opt:nooccurs (default) to generate all COBOL arrays as standard Java arrays.