journal article·2025-02-24Open access

Refactoring for Java-Structured Concurrency

Yang Zhang, Gaojie Shen, Liyan Zhang, Meiyan Zheng, Kun Zheng

Applied Sciences· Volume 15· Issue 5

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.
Source: crossref · Quality: baseline

Research context

OpenAlex topics: Distributed systems and fault tolerance · Parallel Computing and Optimization Techniques · Real-Time Systems Scheduling

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

Funding

Hebei Provincial Department of Science and Technology

References (31)

Show source-provided references
1. Bateman, R.P.A. (2022, September 16). Structured Concurrency. Available online: https://openjdk.org/jeps/428.
2. Refactoring for Asynchronous Execution on Mobile Devices10.1109/MS.2015.133 ↗
3. Tramontana, E. (2023). An Automatic Transformer from Sequential to Parallel Java Code. Future Internet, 15.10.3390/fi15090306 ↗
4. Midolo, E. (2021, January 22–24). Refactoring Java Loops to Streams Automatically. Proceedings of the 2021 4th International Conference on Computer Science and Software Engineering (CSSE 2021), Singapore.10.1145/3494885.3494910 ↗
5. Radoi, C., Tarce, M., Minea, M., and Johnson, R. (2009, January 25–29). ReLooper: Refactoring for Loop Parallelism. Proceedings of the 24th ACM SIGPLAN Conference Companion on Object Oriented Programming Systems Languages and Applications, Orlando, FL, USA.
6. Schäfer, M., Sridharan, M., Dolby, J., and Tip, F. (2011, January 21–28). Refactoring Java programs for flexible locking. Proceedings of the 33rd International Conference on Software Engineering, Honolulu, HI, USA.10.1145/1985793.1985804 ↗
7. Zhang, Y., Shao, S., Zhai, J., and Ma, S. (2020, January 18–22). FineLock: Automatically refactoring coarse-grained locks into fine-grained locks. Proceedings of the 29th ACM SIGSOFT International Symposium on Software Testing and Analysis, Virtual Event.10.1145/3395363.3404368 ↗
8. Automated Refactoring for Stampedlock10.1109/ACCESS.2019.2931953 ↗
9. (2023, October 03). Eclipse Development Platform Extension Toolkit. Available online: https://github.com/eclipse-jdt.
10. (2023, October 15). Flexible, Scalable Machine Learning Platform (SystemML). Available online: https://systemds.apache.org/download.html.
11. (2023, October 15). High-Performance Java Framework for Building Microservices (Light-4j). Available online: https://github.com/networknt/light-4j.
12. (2023, August 10). Notes on Structured Concurrency, 2018. Available online: https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/.
13. Stadler, L., Würthinger, T., and Wimmer, C. (2010, January 15–17). Efficient coroutines for the Java platform. Proceedings of the 8th International Conference on the Principles and Practice of Programming in Java, Vienna, Austria.10.1145/1852761.1852765 ↗
14. Beronić, D., Pufek, P., Mihaljević, B., and Radovan, A. (October, January 27). On Analyzing Virtual Threads–a Structured Concurrency Model for Scalable Applications on the JVM. Proceedings of the 2021 44th International Convention on Information, Communication and Electronic Technology (MIPRO), Opatija, Croatia.10.23919/MIPRO52101.2021.9596855 ↗
15. Chen, Y.A., and You, Y.P. (September, January 29). Structured Concurrency: A Review. Proceedings of the Workshop Proceedings of the 51st International Conference on Parallel Processing, Bordeaux, France.
16. Pufek, P., Beronic, D., Mihaljevic, B., and Radovan, A. (October, January 28). Achieving Efficient Structured Concurrency through Lightweight Fibers in Java Virtual Machine. Proceedings of the 2020 43rd International Convention on Information, Communication and Electronic Technology (MIPRO), Opatija, Croatia.10.23919/MIPRO48935.2020.9245253 ↗
17. Chirila, C.B., and Sora, I. (2024, January 23–25). Java Single vs. Platform vs. Virtual Threads Runtime Performance Assessment in the Context of Key Class Detection. Proceedings of the 2024 IEEE 18th International Symposium on Applied Computational Intelligence and Informatics (SACI), Timisoara, Romania.10.1109/SACI60582.2024.10619722 ↗
18. Beronic, D., Modric, L., Mihaljevic, B., and Radovan, A. (2022, January 23–27). Comparison of Structured Concurrency Constructs in Java and Kotlin—Virtual Threads and Coroutines. Proceedings of the 2022 45th Jubilee International Convention on Information, Communication and Electronic Technology (MIPRO), Opatija, Croatia.10.23919/MIPRO55190.2022.9803765 ↗
19. Rosà, A., Basso, M., Bohnhoff, L., and Binder, W. (2013, January 4–7). Automated Runtime Transition between Virtual and Platform Threads in the Java Virtual Machine. Proceedings of the 2023 30th Asia-Pacific Software Engineering Conference (APSEC), Seoul, Republic of Korea.10.1109/APSEC60848.2023.00080 ↗
20. Franklin, L., Gyori, A., Lahoda, J., and Dig, D. (2013, January 18–26). LambdaFicator: From imperative to functional programming through automated refactoring. Proceedings of the 2013 35th International Conference on Software Engineering (ICSE), San Francisco, CA, USA.10.1109/ICSE.2013.6606699 ↗
21. Refactoring Java programs for customizable locks based on bytecode transformation10.1109/ACCESS.2019.2919203 ↗
22. Fernandes, S., Aguiar, A., and Restivo, A. (2022, January 10–14). LiveRef: A Tool for Live Refactoring Java Code. Proceedings of the 37th IEEE/ACM International Conference on Automated Software Engineering, Rochester, MI, USA.10.1145/3551349.3559532 ↗
23. Fernandes, S. (2022, January 10–14). Towards a Live Environment for Code Refactoring. Proceedings of the 37th IEEE/ACM International Conference on Automated Software Engineering, Rochester, MI, USA.10.1145/3551349.3559569 ↗
24. (2023, May 08). Java Development Kit. Available online: https://www.jetbrains.com/idea/.
25. (2023, May 08). Jmh, a Tool for Java Program Testing. Available online: https://jmeter.apache.org.
26. Zhang, C. (2009, January 16–24). FlexSync: An aspect-oriented approach to Java synchronization. Proceedings of the 2009 IEEE 31st International Conference on Software Engineering, Vancouver, BC, Canada.10.1109/ICSE.2009.5070537 ↗
27. (2023, October 15). Open Source Data Analysis and Visualization Tools (MetaOmGraph). Available online: https://github.com/urmi-21/MetaOmGraph.
28. (2023, October 15). Combines New Java Features into Practical Applications (ModernJava). Available online: https://github.com/ThoughtFlow/ModernJava.
29. (2023, October 15). Biological Microscopy Image Processing (Bigstitcher). Available online: https://imagej.net/plugins/bigstitcher/.
30. (2023, October 15). Biomedical Imaging. Available online: https://github.com/trackmate-sc/TrackMate.
31. (2023, October 15). Solutions to Google Code Problems. Available online: https://github.com/salvois/codejam.