Abstract
Modularizing legacy monolithic Java systems is a critical yet labor-intensive task. We present ClassLAR, a lightweight architectural recovery approach that leverages the semantic intent embedded in fully-qualified class names. By utilizing pre-trained language models and clustering algorithms, ClassLAR identifies module boundaries with high accuracy and exceptional efficiency. Our evaluation on 20 open-source projects demonstrates that ClassLAR outperforms state-of-the-art techniques in both recovery quality and runtime performance.
Introduction
Modern software systems often evolve into large, complex monoliths, leading to architectural decay where the implemented structure deviates from the intended design. While the Java Platform Module System (JPMS) introduced in Java 9 provides mechanisms for encapsulation, retrofitting modules into existing systems remains a significant challenge. Existing automated tools often rely on heavy-weight static or dynamic analysis, which can be slow and sensitive to implementation "noise"—details that obscure the high-level design.
The ClassLAR Approach
ClassLAR (Class and Language model-based Architectural Recovery) operates on the principle that package and class names encapsulate a developer's mental model of the system. By focusing solely on these identifiers, the approach avoids the overhead of deep code analysis.
The recovery pipeline consists of four stages:
- Extraction: Collecting all fully-qualified class names from the target system.
- Code Embedding: Utilizing CodeBERT-java to transform names into dense vector representations that capture semantic relationships.
- Clustering: Applying the HDBSCAN algorithm to group vectors into initial module candidates.
- Undersized Module Repair: Refining clusters through singleton repair (merging single-class modules) and split-package repair (ensuring package integrity across modules) to meet JPMS requirements.
Experimental Evaluation
To evaluate ClassLAR, the researchers curated a benchmark of 20 popular open-source Java projects (including JUnit5, OpenJDK, and Apache Lucene) that have already transitioned to JPMS. This "ground truth" dataset allows for a direct comparison between automated recovery and expert developer intent.
Key Results
ClassLAR was benchmarked against four prominent recovery techniques: ACDC, ARC, SARIF, and FCA.
- Accuracy: ClassLAR achieved an average a2a similarity score of 85.78%, surpassing the next best technique by 11.46 percentage points.
- Efficiency: The approach demonstrated remarkable speed, running 3.99x to 10.50x faster than baselines. In large-scale projects, ClassLAR completed tasks in under an hour where other tools required over 12 hours or timed out.
Discussion and Insights
The success of ClassLAR underscores that software identifiers are rich with architectural information. Modern language models like CodeBERT effectively act as superior topic models, capturing functional relationships better than traditional methods like Latent Dirichlet Allocation (LDA). By ignoring method bodies and complex logic, ClassLAR remains robust against implementation details that do not reflect high-level modular boundaries.
Conclusion and Future Work
ClassLAR provides a highly efficient and accurate means of recovering Java modules from monolithic codebases. While currently focused on static architectural properties, future enhancements could incorporate runtime data or automate the generation of module-info.java descriptors. This work paves the way for more accessible and automated software modularization.
Summary updated