JAVA2COB is a open-source tool that performs the rule based translation of Java code to COBOL. So our tool aims to extend COBOL systems using Java.
JAVA2COB Github RepositoryThe tool has a GUI and this can be accessed through command line by following the steps below:
git clone https://github.com/SrikrishnaKidambi/Java-to-COBOL.git
cd Java-to-COBOL
cd Antlrjavac -cp ".;antlr-4.13.2-complete.jar;javaparser-core-3.25.8.jar"Â *.javajavac -cp ".:antlr-4.13.2-complete.jar:javaparser-core-3.25.8.jar" *.javacd ..
javac ToolGUI.java
java ToolGUI in the tool's base directory.
We have also buit a website and an extension to access the tool at greater ease and can be found at the links below:
The antlr tool will take in the Java 14 grammar as input and provides the java parser and java lexer. We got the java parser and lexer from antlr repo and antlr4 jar from their website. These were the prerequisites for the generation of Parse Tree.
When the java source code is given to the tool firstly it is tokenized by the lexer which is called as lexical analysis which converts the code into tokens and those tokens are given to the java parser and it creates the parse tree. An instance of parse tree walker can be created and we can pass the parse tree and custom listener to it to walk the nodes of the parse tree and convert the java constructs into cobol constructs thereby we get the translated cobol code.
We have analysed the data division and procedure division of the code seperately. So one parse tree walker walks through the nodes and returns the identification and data division of the cobol code and the other parse tree walker walks through the nodes and returns procedure division of the code.
Once the cobol code is generate using GNU cobol we compiled and executed the code and similarly used java compiler for java code and compared the output to test the correctness of the tool.
We have currently implemented rule based mapping for arithmetic expressions (including int, float, double, long, char, String etc.,), arrays, conditional statements (if-else if-else blocks, switch case), loops, methods and some intrinsic(library) functions available in cobol.
We created a Java Dataset of 101 programs partially with the help of Gpt 4'o to test our tool and we calculated the accuracy of mapping each construct we implemented and then found the weighted average to calculate the tool accuracy and it is found to be 98.35% reflecting the tool's strong performance in code translation from Java to COBOL. Detailed breakdown of accuracy per each construct is provided in the tool paper.
Srikrishna Kidambi, Sai Krishna Brahmajosyula, Sridhar Chimalakonda