Software Reverse Engineering (SRE)

Web Supplement to Master’s Thesis at San José State University

  • You are here: 
  • Home
  • Legacy Software Reengineering and Reuse Exercise

Legacy Software Reengineering and Reuse Exercise

Description of the Exercise:

Provide a command-line (or graphical) interactive Java front-end to the legacy COBOL application SMPLCALC.cbl by implementing the program architecture shown below:

Legacy Software Reengineering and Reuse Exercise Architecture
Figure 1. Legacy Software Reengineering and Reuse Exercise Architecture

Provide a command-line (or graphical) interactive Java front-end to the legacy COBOL application SMPLCALC.cbl by implementing the program architecture illustrated in Fig. 1.  Before starting the exercise, download and extract the following archive file located here SMPLCALC.cbl Legacy COBOL Program Artifacts.

Follow these steps to complete the exercise:

1.) Locate the interface data structure for SMPLCALC.cbl in the copybook (source include file) SMPLCALC.cpy. There is only one data structure in the copybook.

2.) Create an XML Schema which represents all of the data in the SMPLCALC-INTERFACE COBOL data structure.  Instead of writing this by hand, you can use the Micro Focus Net Express CBL2XML wizard [37].

3.) Write a Java interface ISimpleCalculator.java for three computation types supported by SMPLCALC.cbl using appropriate method signatures:

  1. blong doAdd(int, int) throws java.lang.ArithmeticException.
  2. long doSubtract(int, int) throws Java.lang.ArithmeticException
  3. long doMultipy(int, int) throws Java.lang.ArithmeticException

4.) Write a Java class JSimpleCalculator.java that implements the interface defined in ISimpleCalculator.java and provides a user interface for:

  1. Specifying which computation (add, sub, mul) is desired.
  2. Specifying the operands to the computation.
  3. Displaying the result of the computation (can be an error).

5.) Use the Java command-line utility xjc, in combination with the XML Schema created in Step 2, to generate Java to XML marshalling code (JAXB). Update JSimpleCalculator.java to call this marshalling code.

6.) Write a small C/C++ JNI program Java2CblXmlBridge.cpp which exports a method “Java2SmplCalc” which:

  1. Invokes XML2CALC.cbl (see Step 7), passing the XML document received from JSimpleCalculator.java.
  2. Returns the XML document generated by XML2CALC.cbl (see Step 7) on return from SMPLCALC.cbl to JSimpleCalculator.java.

7.) Write a COBOL program XML2CALC.cbl which:

  1. Marshalls XML received from the Java2CblXmlBridge.cpp, based on the XML Schema created in Step 2, into SMPLCALC-INTERFACE.
  2. Invokes SMPLCALC.cbl, passing SMPLCALC-INTERFACE by reference.
  3. Marshalls SMPLCALC-INTERFACE back to XML before returning to Java2CblXmlBridge.cpp.

8.) Compile XML2CALC.cbl and link it with the machine/object code for SMPLCALC.cbl (SMPLCALC.obj).

  1. To simulate a situation where only partial source code for an application is available, do not recompile SMPLCALC.cbl; use the object file (machine code) that comes with this exercise instead.

9.) Create a DLL that can be loaded an used by JSimpleCalculator.java by compiling and linking Java2CblXmlBridge.cpp with the object code for XML2CALC.cbl.

  1. Update JSimpleCalculator.java to use the XJC-generated marshalling code to send/receive XML through the JNI method defined in Step 8 and display the results of the computations performed downstream by SMPLCALC.cbl.

10.) Update JSimpleCalculator.java to use the XJC-generated marshalling code to send/receive XML through the JNI method defined in Step 8 and display the results of the computations performed downstream by SMPLCALC.cbl.

Software for the Exercise:

Solution to the Exercise:

The following screen captures demonstrate execution of the solution code.  Feel free to create a graphical user interface using Java Swing in your own solution.

Legacy Software Reengineering and Reuse Solution
Figure 2. Legacy Software Reengineering and Reuse Solution Input

Legacy Software Reengineering and Reuse Solution
Figure 3. Legacy Software Reengineering and Reuse Solution Output

 


Posted on May 20th, 2009 | By: teodoro

Comments are closed.