Automatic Refactoring Approach for Asynchronous Mechanisms with CompletableFuture
Source abstract
Abstract
To address the inherent limitations of Future in asynchronous programming frameworks, JDK 1.8 introduced the CompletableFuture class, which features approximately 50 different methods for composing and executing asynchronous computations and handling exceptions. This paper proposes an automatic refactoring method that integrates multiple static analysis techniques, including visitor pattern analysis, alias analysis, and executor inheritance structure analysis, to conduct precondition checks. Distinct from existing Future refactoring methods, this approach considers custom executor types, thereby extending its applicability. Using this method, the ReFuture automatic refactoring plugin was implemented within the Eclipse JDT framework. The method was evaluated in terms of the number of refactorings, refactoring time, and error introduction, alongside a side-by-side comparison with the existing method. The refactoring outcomes for nine large applications, including ActiveMQ, Hadoop, and Elasticsearch, show that ReFuture successfully refactored 639 out of 813 potential code structures, achieving a refactoring success rate of 64.70% without introducing errors. This tool effectively facilitates the refactoring to CompletableFuture and enhances refactoring efficiency compared to manual methods.
Source: crossref · Quality: baseline
Research context
OpenAlex topics: Manufacturing Process and Optimization · Model-Driven Software Engineering Techniques · Additive Manufacturing and 3D Printing Technologies
SciVX discovery tags are terminology-based. OpenAlex topics are source-provided classifications.
Affiliations
School of Information Science and Engineering, Hebei University of Science and Technology, Shijiazhuang 050000, China
Shijiazhuang Meteorological Bureau, Shijiazhuang 050000, China
Funding
Hebei Provincial Natural Science Foundation · Hebei Provincial Overseas High-level Talent Foundation · Hebei Meteorological Service
References (40)
Show source-provided references
1. (2024, March 21). Android—Java’s FutureTask Composability—Stack Overflow. Available online: https://stackoverflow.com/questions/14704812/javas-futuretask-composability.
2. (2024, March 21). Java—Waiting on a List of Future—Stack Overflow. Available online: https://stackoverflow.com/questions/19348248/waiting-on-a-list-of-future.
3. (2024, September 19). Google/Guava. Available online: https://github.com/google/guava.
4. Kohler, M., and Salvaneschi, G. (2019, January 11–15). Automated Refactoring to Reactive Programming. Proceedings of the 2019 34th IEEE/ACM International Conference on Automated Software Engineering (ASE), San Diego, CA, USA.10.1109/ASE.2019.00082 ↗
5. Orton, I. (2021, January 13). Alan Mycroft Refactoring Traces to Identify Concurrency Improvements. Proceedings of the 23rd ACM International Workshop on Formal Techniques for Java-like Programs, Virtual Event, Denmark.10.1145/3464971.3468420 ↗
6. Converting Parallel Code from Low-Level Abstractions to Higher-Level Abstractions10.1007/978-3-662-44202-9_21 ↗
7. Okur, S., Hartveld, D.L., Dig, D., and Deursen, A. (June, January 31). A Study and Toolkit for Asynchronous Programming in C#. Proceedings of the 36th International Conference on Software Engineering, Hyderabad, India.
8. Lin, Y., and Dig, D. (2015, January 9–13). Refactorings for Android Asynchronous Programming. Proceedings of the 2015 30th IEEE/ACM International Conference on Automated Software Engineering (ASE), Lincoln, NE, USA.10.1109/ASE.2015.50 ↗
9. Dig, D., Marrero, J., and Ernst, M.D. (2009, January 16–24). Refactoring Sequential Java Code for Concurrency via Concurrent Libraries. Proceedings of the 2009 IEEE 31st International Conference on Software Engineering, Vancouver, BC, Canada.10.1109/ICSE.2009.5070539 ↗
10. Ishizaki, K., Daijavad, S., and Nakatani, T. (2011, January 17–21). Refactoring Java Programs Using Concurrent Libraries. Proceedings of the Workshop on Parallel and Distributed Systems Testing, Analysis, and Debugging—PADTAD ’11, Toronto, ON, Canada.10.1145/2002962.2002970 ↗
11. Refactoring Java Programs for Customizable Locks Based on Bytecode Transformation10.1109/ACCESS.2019.2919203 ↗
12. Zhang, Y., Shao, S., Ji, M., Qiu, J., Tian, Z., Du, X., and Guizani, M. (2020). An Automated Refactoring Approach to Improve IoT Software Quality. Appl. Sci., 10.10.3390/app10010413 ↗
13. Midolo, A., and Tramontana, E. (2023). An Automatic Transformer from Sequential to Parallel Java Code. Future Internet, 15.10.3390/fi15090306 ↗
14. Lin, Y., Radoi, C., and Dig, D. (2014, January 11). Retrofitting Concurrency for Android Applications through Refactoring. Proceedings of the 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering, Hong Kong, China.10.1145/2635868.2635903 ↗
15. Automatic Migration from Synchronous to Asynchronous JavaScript APIs10.1145/3485537 ↗
16. (2024, June 19). Eclipse Java Development Tools (JDT)|The Eclipse Foundation. Available online: https://eclipse.dev/jdt/.
17. Vallée-Rai, R., Co, P., Gagnon, E., Hendren, L., Lam, P., and Sundaresan, V. (2010, January 1–4). Soot: A Java Bytecode Optimization Framework. Proceedings of the CASCON First Decade High Impact Papers on—CASCON ’10, Toronto, ON, Canada.10.1145/1925805.1925818 ↗
18. (2024, March 22). Eclipse IDE|The Eclipse Foundation. Available online: https://eclipseide.org/.
19. (2024, August 27). Xzy0311/ReFuture. Available online: https://github.com/xzy0311/ReFuture.
20. A Large-Scale Study on the Usage of Java’s Concurrent Programming Constructs10.1016/j.jss.2015.04.064 ↗
21. Enabling Additional Parallelism in Asynchronous JavaScript Applications
22. Goetz, B. (2006). Java Concurrency in Practice, Addison-Wesley.
23. Dyer, R., Nguyen, H.A., Rajan, H., and Nguyen, T.N. (2013, January 18–26). Boa: A Language and Infrastructure for Analyzing Ultra-Large-Scale Software Repositories. Proceedings of the 2013 35th International Conference on Software Engineering (ICSE), San Francisco, CA, USA.10.1109/ICSE.2013.6606588 ↗
24. The Free Lunch Is over: A Fundamental Turn toward Concurrency in Software
25. (2024, March 28). CodeQL. Available online: https://codeql.github.com/.
26. (2024, March 28). Analyzing Your Projects—CodeQL. Available online: https://codeql.github.com/docs/codeql-for-visual-studio-code/analyzing-your-projects/#downloading-a-database-from-github.
27. Giordano, G., Fasulo, A., Catolino, G., Palomba, F., Ferrucci, F., and Gravino, C. (2022, January 15–18). On the Evolution of Inheritance and Delegation Mechanisms and Their Impact on Code Quality. Proceedings of the 2022 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER), Honolulu, HI, USA.10.1109/SANER53432.2022.00113 ↗
28. Survey on Java Pointer Analysis
29. Ondrej Lhoták (2004). SPARK: A Flexible Points-to Analysis Framework for Java, National Library of Canada = Bibliothèque nationale du Canada.
30. Fan, G., and Xuan, Z. (2016, January 23–25). Design and Implementation of a Dependence-Based Taint Analysis. Proceedings of the 2016 11th International Conference on Computer Science & Education (ICCSE), Nagoya, Japan.10.1109/ICCSE.2016.7581718 ↗
31. (2024, June 19). ActiveMQ. Available online: https://activemq.apache.org/.
32. (2024, June 19). Apache Hadoop. Available online: https://hadoop.apache.org/.
33. (2024, June 19). Elasticsearch. Available online: https://www.elastic.co/cn/elasticsearch.
34. (2024, June 19). Jenkins. Available online: https://www.jenkins.io/.
35. (2024, June 19). Apache Tomcat. Available online: https://tomcat.apache.org/.
36. (2024, June 19). JGroups. Available online: http://www.jgroups.org/.
37. (2024, June 19). Apache Flume—Apache Flume. Available online: https://flume.apache.org/.
38. (2024, June 19). Apache ZooKeeper. Available online: https://zookeeper.apache.org/.
39. (2024, June 19). Apache Tika. Available online: https://tika.apache.org/.
40. (2024, September 22). Apache Projects List. Available online: https://projects.apache.org/projects.html?language#Java.