Applied Sciences (Feb 2025)
Refactoring for Java-Structured Concurrency
Abstract
Structured concurrency treats multiple tasks running in different threads as a single unit, thereby improving reliability and enhancing observability. The existing IDE (Integrated Development Environment) does not provide sufficient support to leverage such an advanced structure and conduct refactoring automatically. Manual refactoring is tedious and error prone. There is an urgent need to provide adequate support to perform automatic refactoring. To this end, this paper proposes ReStruct, an automatic refactoring approach to transform unstructured concurrency to structured concurrency. ReStruct first employs visitor pattern analysis to acquire the target code for refactoring and then performs a precondition to filter out the code that meets the refactoring criteria. Subsequently, it performs scope analysis to guide the refactoring process. Finally, ReStruct performs refactoring on the AST of the source program. ReStruct is implemented as an Eclipse plugin and is evaluated in seven real-world projects via the number of refactorings and changes to LOCs (lines of code), time, and performance after refactoring. The experimental results illustrate that a total of 82 unstructured codes are refactored, with an average of 27.3 s per project. Furthermore, the performances of these refactored projects are improved by an average of 6.5%, demonstrating its effectiveness.
Keywords