CoJaC is our tool for converting historical COBOL applications to modern Java solutions. CoJaC generates maintainable and high-performance Java code which is semantically equivalent to the COBOL code.
During conversion, the tool achieves an automation level of 95–99 %. CoJaC combines scientific know-how in compiler construction with core competency resulting from successful migration projects.
CoJaC TECHNOLOGY
For complex compiling processes, the use of specific conversion tools, so-called translators, is necessary. Translators work by analogy with a compiler which, via different intermediate stages, compiles source programmes to executable target code.
CoJaC is a translator for converting historical COBOL applications to modern Java solutions. For the requirements of language conversion, we have further developed the general compiler model into a translator model:
- FRONT-END: reads the COBOL programme, including the corresponding copybooks, and generates an internal syntax tree which represents the complete COBOL programme
- TRANSFORMER: converts the COBOL syntax tree to an equivalent Java syntax tree. The actual conversion is based on syntax trees instead of source code.
- POST-PROCESSOR: splits the complex Java syntax tree into individual syntax trees which represent the programme structure of the subsequent Java programme
- GENERATOR/FORMATTER: generates Java classes and packages from individual Java syntax trees and automatically formats source code according to client specifications
- RUNTIME SYSTEM: allows the use of the COBOL data types and functionalities in converted Java code which do not exist 1:1 in Java
FEATURES
Integration of the source code comments into the target code
Structuring of the target code into Java classes and packages by our tool JPackage according to customer specification
User-specific formatting of the generated Java code
Support of different COBOL dialects (IBM, HPE NonStop, BS2000)
MIGRATION ASPECTS
The process of migration goes far beyond the mere program transformation and includes an architecture migration as well. The target architecture can be selected to run both on a local server and in a commercial provider’s cloud environment:
The graphic here is an indicative example of the architecture of a typical COBOL application and the Java target system resulting from it.- COBOL server programs are provided in the Java target system as web services.
- COBOL batch programs (server) are transformed into autonomous Java programs.
The runtime system provides classes for processing the migrated programs in the Java target environment. This includes classes for the COBOL data types (numeric and alphanumeric data) and basic classes for arrays and structures. In addition, there are methods that implement the functionality of COBOL instructions without native statements in Java (e.g. STRING
and INSPECT
). Further components are static methods for depicting the intrinsic functions, methods for type conversion and classes that provide the functionality of interfaces (files, SQL, middleware). The runtime system forms the basis for a compact maintainable Java code.
Examples of the application of the CoJaC runtime system:
COBOL-servers controlled by middleware (a transaction processing monitor) are translated into Java web services by CoJaC and integrated into an application server. In doing so, middleware-specific data and statements are removed or replaced by a corresponding web service functionality. In the process, the interface does not change in content. The web services process the same messages as the COBOL server before. Necessary conversions are encapsulated by the runtime system which also takes over administration of transactions. Our tool MidaS (Middleware as a Service) is a lightweight alternative compared to commercial systems. MidaS provides an interface that is tailor-made for the migrated online programs and is easy to integrate into a Java server environment.
Example of middleware migration:
The data files used in COBOL are transformed into relational database tables during migration by our tool FiRe. In doing so, the different forms of organisation and access methods are taken into account. Database tables are accessed in the converted Java programs by using methods, which are provided by the runtime system. These runtime system methods emulate the original COBOL statements on file work (OPEN
, READ
, READ NEXT
, CLOSE
, …).
Examples of file migration:
Static SQL statements embedded into the COBOL source code are converted into dynamic SQL statements. Mapping the functionality existing in the basic system, methods for administrating the database connection, for database access, reading and writing of data into host variables and for error handling are integrated into the runtime system. According to experience, the transition to dynamic SQL does not result in runtime disadvantages. At the same time, it allows flexible creation and modification of SQL statements.
Examples of migration of embedded SQL:
The migration of the ASCII masks to web interfaces is carried out by our tool MaTriX. A so-called mask server as a component of MaTriX coordinates the information exchange between interfaces and web services via messages.
FAQ ON LANGUAGE MIGRATION
We have proved in several migration projects that this works (e.g. COBOL to Java at ITZBund and SüdLeasing). For COBOL to Java, large parts of the COBOL code (95–99 %) can be converted automatically. The CoJaC tool generates semantically equivalent Java code. The remaining 1–5 % are clearly indicated, for example, by appropriate comments facilitating the manual conversion.
The COBOL programs were implemented in a procedural language. A redistribution of functionality into individual classes and methods in the sense of the object-oriented concept is not automatically possible. This is not necessarily desirable since the developers must recognise the code. A future, object-oriented further development of the generated Java applications can, of course, be done.
Yes, definitely. The basic structure of the generated Java code is analogous to the COBOL code. This increases the recognition effect. In addition, comments are inserted at the right positions of the target code. The developers of the old system (Java knowledge being the prerequisite) will find their way quickly. There are enough reference projects for automatic language transformation from COBOL to Java, which practically prove that the generated code is maintainable and performant. The available, modern IDEs (e.g. IntelliJ and Eclipse) then allow a comfortable further development.
Concerns are often expressed by competitors who market their own COBOL development environments and are, therefore, not interested in migrating “away from COBOL”.
Those statements, for which Java does not provide the corresponding language resources, are not completely convertible. This mainly concerns the so-called “compiler-directing statements”. These are first implemented during the translation of the COBOL program so to say in a preprocessor step. Java, however, does not provide a preprocessor. Thus, these statements cannot be converted with the common mechanisms. CoJaC includes a sophisticated mechanism to convert copybooks into separate Java classes.
GO TO
statements can be migrated completely automatically. First, an attempt is made to replace them by Java typical statements. Jumps to the end of a section, for example, are translated into Java by a return
instruction. If this is not possible, the CoJaC runtime system takes over the flow control. In the program, GO TO
is then executed by calling a skip()
method.
The statements for modelling COBOL constructs into Java constructs were deliberately chosen in such a way that the generated code is typical for Java. For example, Java classes encapsulating all necessary information, such as length etc., and offering methods to administrate them are provided for different data types in a runtime system. Where possible, the native Java statements are directly used for loops (while
, for
) or if
statements.
PROCEDURE DIVISION
become class methods. In doing so, the order within the source code remains unchanged. Copybooks are converted into separate classes. Even if these copybooks are used several times, only one class will be created. Clones are only created when using COPY
with REPLACING
clause or COPY
in the PROCEDURE DIVISION
. We have with JPackage a tool capable of reuniting the resultant clones.
In addition to the significantly higher costs, you should also consider the project duration in this decision. If more than 95 % of the Java code is generated automatically, the program is of course converted more rapidly than manually. Code freezes and potential blocking times during further development/program maintenance will thus be minimised. Our experience has shown that the software migration in relation to a new development lies at 1:8, which means that if you calculate 5 man-years for a migration project using transformation tools, you will need 40 man-years for a redevelopment of the same program system.
There are two alternative approaches for a redevelopment: either you rewrite the original program 1:1 in Java, in which case the code will be similar to the automatically migrated code, and you can also automatically migrate; or you extract the business logic of the program, create a specification and then develop the program anew. The extraction of the business logic is however a very time-consuming and error-prone process.
Of course, yes. This is another advantage of software migration. The developers maintaining the converted programs in future do not have to know COBOL. They can familiarise themselves with the environment solely on the basis of the Java code.
Well, they have to learn Java. There is no way around this. These programmers, however, have the advantage that they are already familiar with the technical background of the programs, whereas newcomers have, of course, to first acquire the skills.
This is also an argument frequently voiced by customers but that has never been found to be true in earlier projects. Performance problems only occur limited to individual programs and could be eliminated by suitable optimisation measures. Thanks to the advanced technology of the “just-in-time-Compiler”, today’s JVM process Java programs only slightly slower than the processor the compiled COBOL programs.
Tools for software migration require extensive development effort. In addition, very specific know-how in informatics (compiler technology) is necessary. We have 30 years of experience in the development of tools for software migration. The basis is in its years of research work in the field of compiler technology at the Faculty for Informatics at the TU Chemnitz. We still carry out research and development in cooperation with the universities of Koblenz-Landau and Oldenburg. The results are directly reflected in our technologies and tools.
In the course of past years, different types of parser, code generators, formatting and meta tools have been developed which are all combined in our pecBOX (pro et con – Toolbox for Software Migration) and used in our migration projects. No migration project is like the other. For new projects, necessary, new migration tools are compiled from the pecBOX components thus reducing the development time. This generic approach makes migration projects less expensive and reduces the project duration. This has been affirmed by numerous reference customers like Amadeus Germany GmbH, MAN Truck & Bus SE, ITZBund, SüdLeasing GmbH, to name a few.
“Jedes COBOL-Java-Migrationsprojekt birgt neue Überraschungen“
Abstract for 24th Workshop “Software-Reengineering & Evolution” 2–4 May 2022 in Bad Honnef, published in:
Softwaretechnik-Trends, volume 42, part 2, May 2022
Success Story: “Successful COBOL Java Migration at SüdLeasing GmbH”