# Automatic Refactoring Approach for Asynchronous Mechanisms with CompletableFuture
## 7 Conclusions and Future Work  
This paper presents an automated refactoring method that combines various static analysis techniques such as visitor pattern analysis, alias analysis, and executor inheritance structure analysis to perform precondition checks before refactoring. Based on this method, an automated refactoring plugin, ReFuture, was implemented under the Eclipse JDT framework. In the experiments, ReFuture was evaluated based on the number of refactorings, refactoring time, and the introduction of errors, alongside a side-by-side comparison with the existing method. The refactoring results for nine large applications, including ActiveMQ, Hadoop, and Elasticsearch, show that ReFuture refactored 639 out of 813 code structures targeted for refactoring, achieving a success rate of 64.70% without introducing errors. The comparative experiment demonstrates that ReFuture not only excels in large programs but also performs well in medium- and small-scale programs. Compared to manual refactoring, it improves efficiency and provides a valuable learning opportunity for developers to master correct conversion techniques through its preview interface.  
Our future research will primarily focus on the following. (1) ReFuture currently employs a context-insensitive pointer analysis technique from the Spark framework within Soot. While reliable, this method is outdated compared to newer pointer analysis technologies. Its efficacy is also limited by its dependence on the selection of the program's  
\begin{table}
\begin{tabular}{c c c} \hline
**Project Name** & **2 RX** & **ReFuture** \\ \hline Elasticsearch & 4 & 2 \\ JUnit & 1 & 4 \\ DropWizard & 2 & 2 \\ Mockito & 2 & 5 \\ Springside4 & 0 & 9 \\ Titan & 1 & 1 \\ AsyncHttpClient & 105 & 7 \\ Graylog2 Server & 0 & 1 \\ Java Websocket & 0 & 0 \\ B3 log & 0 & 0 \\ \hline \end{tabular}
\end{table}
Table 12: ReFuture VS 2 RX.  
entry method; inaccessible methods within the program can prevent accurate analysis of certain variables, consequently reducing the success rate of refactorings. To enhance our tool's effectiveness and broaden its applicability, we plan to integrate more advanced pointer analysis techniques in future updates. (2) Exploring more rational uses of CompletableFuture to further enhance the quality of existing asynchronous program code, for example, automatically refactoring asynchronous logic that consists of multiple traditional asynchronous constructs combined in a synchronous manner into a fully asynchronous form using CompletableFuture, thereby fully leveraging its rich API to improve program execution efficiency. (3) continuing to improve the ReFuture tool, including testing on more programs to fix potential bugs and planning to develop refactoring plugins suitable for other IDEs to assist more programmers.  
Y.Z.: Proposing the idea, Writing--review and editing; Z.X.: Conducting experimentation, Writing--original draft, review and editing; Y.Y.: Experimental analysis, Writing--review and editing; L.Q.: Writing--review and editing. All authors have read and agreed to the published version of the manuscript.  
This work is partially supported by the Hebei Provincial Natural Science Foundation under Grant No.F2023208001 and the Hebei Provincial Overseas High-level Talent Foundation under Grant No.C20230358. Foundation of Hebei Meteorological Service under Grant 22 KY09.  
Not applicable.  
The raw data supporting the conclusions of this article will be made available by the authors on request.  
The authors declare no conflicts of interest.