Table of Contents
Fetching ...

Translating PL/I Macro Procedures into Java Using Automatic Templatization and Large Language Models

Takaaki Tateishi, Yasuharu Katsuno

TL;DR

The paper tackles translating PL/I macro procedures (code that generates PL/I code) into Java, a task hard for direct translation due to macro-generated strings. It introduces templatization, a symbolic-execution–driven intermediate representation that produces templates with definition and code parts, enabling LLM-assisted translation to Java via annotations like @PLIVariable. The approach preserves modularity and maintainability, demonstrated by experiments on ten macro procedures where the resulting Java code reproduces the original macro-generated behavior. This work has practical impact for modernizing legacy PL/I systems by providing a structured path from macro-based PL/I to readable, maintainable Java.

Abstract

Modernizing legacy enterprise systems often involves translating PL/I programs into modern languages such as Java. This task becomes significantly more complex when PL/I macro procedures are involved. The PL/I macro procedures are considered string-manipulating programs that generate PL/I code, and they make automated translation more complex. Recently, large language models (LLMs) have been explored for automated code translation. However, LLM-based code translation struggles to translate the PL/I macro procedures to Java programs that reproduce the behavior of the plain PL/I code generated by the original PL/I macro procedures. This paper proposes a novel method called templatization, which uses symbolic execution to generate code templates (code with named placeholders) as an intermediate representation. In this approach, symbolic values are treated as parts of macro-generated code. By symbolically executing macro procedures and generating code templates, our approach facilitates LLMs to generate readable and maintainable Java code. Our preliminary experiment on ten PL/I macro procedures shows that the LLM-based translation through templatization successfully generates Java programs that reproduce the behavior of the macro-generated PL/I programs.

Translating PL/I Macro Procedures into Java Using Automatic Templatization and Large Language Models

TL;DR

The paper tackles translating PL/I macro procedures (code that generates PL/I code) into Java, a task hard for direct translation due to macro-generated strings. It introduces templatization, a symbolic-execution–driven intermediate representation that produces templates with definition and code parts, enabling LLM-assisted translation to Java via annotations like @PLIVariable. The approach preserves modularity and maintainability, demonstrated by experiments on ten macro procedures where the resulting Java code reproduces the original macro-generated behavior. This work has practical impact for modernizing legacy PL/I systems by providing a structured path from macro-based PL/I to readable, maintainable Java.

Abstract

Modernizing legacy enterprise systems often involves translating PL/I programs into modern languages such as Java. This task becomes significantly more complex when PL/I macro procedures are involved. The PL/I macro procedures are considered string-manipulating programs that generate PL/I code, and they make automated translation more complex. Recently, large language models (LLMs) have been explored for automated code translation. However, LLM-based code translation struggles to translate the PL/I macro procedures to Java programs that reproduce the behavior of the plain PL/I code generated by the original PL/I macro procedures. This paper proposes a novel method called templatization, which uses symbolic execution to generate code templates (code with named placeholders) as an intermediate representation. In this approach, symbolic values are treated as parts of macro-generated code. By symbolically executing macro procedures and generating code templates, our approach facilitates LLMs to generate readable and maintainable Java code. Our preliminary experiment on ten PL/I macro procedures shows that the LLM-based translation through templatization successfully generates Java programs that reproduce the behavior of the macro-generated PL/I programs.

Paper Structure

This paper contains 8 sections, 7 figures.

Figures (7)

  • Figure 1: Overview of Translation from PL/I to Java
  • Figure 2: PL/I macro procedure
  • Figure 3: Generated Java code
  • Figure 4: PL/I template
  • Figure 5: The prompt for translating PL/I template into Java
  • ...and 2 more figures