Skip to main content
QUICK REVIEW

[论文解读] Experience on Automatically Converting a C++ Monolith to Java EE

Andre Vehreschild, Lexi Pimenidis|arXiv (Cornell University)|Mar 9, 2026
Software Engineering and Design Patterns被引用 0
一句话总结

本论文记录了基于 clang-tool 的转换器的实现,用以自动将一个庞大的 C++ 单体系统(约80万 LOC,约2,500 个 .cpp 文件,约3,000 个类)转换为在 WildFly 上运行的 Java EE,并解决多重继承、枚举、RAII 等挑战,提出在持续进行 C++ 开发时的持续再生成策略。

ABSTRACT

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.

研究动机与目标

  • 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.

提出的方法

  • 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.

实验结果

研究问题

  • 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?

主要发现

  • 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.

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。