[Paper Review] Experience on Automatically Converting a C++ Monolith to Java EE
The paper documents building a clang-tool–based transpiler to automatically convert a large C++ monolith (≈800k LOC, ≈2,500 .cpp files, ≈3,000 classes) into Java EE running on WildFly, addressing challenges like multiple inheritance, enums, and RAII, with a strategy for continuous regeneration during ongoing C++ development.
Converting a large C++ code base (800k lines of code) into Java alone is challenging. Changing the architecture from a monolith into an application adhering to the Java application server standard and to run it on WildFly is a different number. This report describes the experience made during the C++ to Java conversion, the techniques used as well as the way to success of running the Java code on the application server for the first time. The approaches to solve the usual C++ to Java culprits, like multiple inheritance, enum-handling and scoped objects are described. A clang-tool-based software is developed to continuously regenerate the Java, because development on the C++ code base continued.
Motivation & Objective
- Motivate the conversion of a large C++ artifact to Java to unify base layers, modernize the stack, and improve maintainability and hiring prospects.
- Describe the challenges posed by C++ features (e.g., multiple inheritance, enums, RAII) and how they interact with Java and a Java application server.
- Present the architecture and workflow of the transpiler and how it automates translation while accommodating ongoing C++ development.
- Explain how the generated Java artifacts are structured, packaged, and integrated with Java EE (WildFly)
- Show empirical observations of the conversion process, including problem areas and lessons learned.
Proposed method
- Develop a transpiler based on clang-tool to analyze and convert C++ core layer code to Java code.
- Use a central transpile visitor plus rewriting/templating to emit Java equivalents of C++ constructs.
- Employ a Java template engine and a free-function mapper to translate C++ free functions to Java static methods.
- Implement a package/import registry to map C++ namespaces and STL usage to Java packages and imports.
- Apply special handling for challenging features (e.g., multiple inheritance, Chain of Command pattern, DAOs) and convert them to Java-compatible designs.
- Enable continuous regeneration by generating Java from C++ upon each check-in and performing a checked replacement when necessary.
Experimental results
Research questions
- RQ1How can a large C++ monolith be translated into a Java EE architecture while preserving behavior and enabling deployment on a Java application server?
- RQ2What are the main C++ idioms (e.g., multiple inheritance, destructors, enums) that hinder straightforward translation to Java, and how can they be mitigated?
- RQ3What automation techniques (tooling, templates, rules) are effective for translating C++ to Java-at-scale without prohibitive manual intervention?
- RQ4How can a translation approach handle ongoing C++ development during the conversion process?
- RQ5What are viable architectural adaptations (e.g., converting is-a to has-a for DAOs, handling Chains of Command) to fit Java paradigms?
Key findings
- The artifact consists of about 2,500 CPP files, ~3,000 classes, and ~800,000 lines of code.
- Approximately 400 classes inherit from multiple base classes; most involve a DAO or a Chain pattern, guiding the chosen mitigation strategies.
- Only about 10 classes remained that required manual tweaking after automated translation.
- The transpiler uses a template-based emission strategy and a rewrite table to map C++ constructs to Java equivalents, including complex type handling and operator/method rewrites.
- A central package registry aggregates imports based on inferred usage, enabling consistent Java package structure and avoiding missing imports.
- The approach demonstrates practical handling of enums, RAII-style resource management, and complex inheritance in a Java ecosystem, enabling deployment on a Java application server (WildFly).
- The workflow supports continuous regeneration of Java code as the C++ base evolves, with a checked-replace mechanism to integrate manual corrections when needed.
Better researchstarts right now
From reading papers to final review, dramatically reduce your research time.
No credit card · Free plan available
This review was created by AI and reviewed by human editors.