Abstract
We present an approach for checking that Java programs correctly use libraries such as java.util.concurrent.locks for synchronizing concurrent tasks. Concretely, the article develops methods to check that the behaviour of a program is in accordance with a set of coding rules that govern the correct usage of the library. Here such coding rules are formalized as Prolog predicates that judge whether the history of interactions between program and library represents correct usage or not. The history of interactions is obtained by tracing the interactions between the program and the library when executing a representative test suite. The approach is evaluated in a case study in which around 200 independent monitor-based Java implementations of a common specification are analysed to check adherence to the concurrency coding rules.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
Input parameters are specified using the [i] qualifier; output parameters use the [o] qualifier.
- 2.
Note that the code sketch assumes that every account has a transfer queue.
- 3.
Byteman permits tracing invocation (entry) and exit (return or throw) of a method call.
- 4.
The number of rules vary as the implementations are free to organise the shared state in different ways, and Byteman rules must trace all such accesses.
References
Agarwal, R., Stoller, S.D.: Run-time detection of potential deadlocks for programs with locks, semaphores, and condition variables. In: Proceedings of the 2006 Workshop on Parallel and Distributed Systems: Testing and Debugging, PADTAD 2006, pp. 51–60. ACM, New York (2006)
Chen, W., Warren, D.S.: Tabled evaluation with delaying for general logic programs. J. ACM 43(1), 20–74 (1996)
Claessen, K., Hughes, J.: Quickcheck: a lightweight tool for random testing of haskell programs. In: Proceedings of the Fifth ACM SIGPLAN International Conference on Functional Programming, ICFP 2000, pp. 268–279. ACM, New York (2000)
Dinn, A.E.: Flexible, dynamic injection of structured advice using byteman. In: Borba, P., Chiba, S. (eds.) Companion Volume of the 10th International Conference on Aspect-Oriented Software Development, AOSD 2011, pp. 41–50. ACM (2011)
Falcone, Y., Krstic, S., Reger, G., Traytel, D.: A taxonomy for classifying runtime verification tools. Int. J. Softw. Tools Technol. Transf. 23(2), 255–284 (2021). https://doi.org/10.1007/S10009-021-00609-Z
Fredlund, L., Mariño, J., Alborodo, R.N.N., Herranz, A.: A testing-based approach to ensure the safety of shared resource concurrent systems. Proc. Inst. Mech. Eng. Part O: J. Risk Reliab. (2015)
Herlihy, M.P., Wing, J.M.: Linearizability: a correctness condition for concurrent objects. ACM Trans. Program. Lang. Syst. 12(3), 463–492 (1990)
Herranz, A., Mariño, J.: A verified implementation of priority monitors in Java. In: Proceedings of the 2011 International Conference on Formal Verification of Object-Oriented Software, FoVeOOS 2011, pp. 160–177. Springer, Heidelberg (2012)
Herranz, A., Mariño, J., Carro, M., Moreno Navarro, J.J.: Modeling concurrent systems with shared resources. In: Alpuente, M., Cook, B., Joubert, C. (eds.) Formal Methods for Industrial Critical Systems. LNCS, vol. 5825, pp. 102–116. Springer, Cham (2009)
Hsiao, C.H., et al.: Race detection for event-driven mobile applications. SIGPLAN Not. 49(6), 326–336 (2014). https://doi.org/10.1145/2666356.2594330
Lochmann, A., Schirmeier, H., Borghorst, H., Spinczyk, O.: Lockdoc: trace-based analysis of locking in the linux kernel. In: Candea, G., van Renesse, R., Fetzer, C. (eds.) Proceedings of the 14th EuroSys Conference 2019, Dresden, Germany, pp. 11:1–11:15. ACM (2019)
Mariño, J., Alborodo, R.N.N., Fredlund, L., Herranz, Á.: Synthesis of verified concurrent Java components from formal models. Softw. Syst. Model. (2016)
Marpons-Ucero, G., Mariño-Carballo, J., Carro, M., Herranz-Nieva, Á., Moreno-Navarro, J.J., Fredlund, L.: Automatic coding rule conformance checking using logic programming. In: PADL 2008. LNCS, vol. 4902, pp. 18–34. Springer, Cham (2008)
Mutlu, E., Tasiran, S., Livshits, B.: Detecting Javascript races that matter. In: Proceedings of the 2015 10th Joint Meeting on Foundations of Software Engineering, ESEC/FSE 2015, pp. 381–392. Association for Computing Machinery, New York (2015). https://doi.org/10.1145/2786805.2786820
Song, F., Touili, T.: Model-checking software library API usage rules. In: Johnsen, E.B., Petre, L. (eds.) Integrated Formal Methods, 10th International Conference, IFM 2013, Turku, Finland, 10–14 June 2013. LNCS, vol. 7940, pp. 192–207. Springer, Cham (2013)
Welch, P.H., Brown, N., Moores, J., Chalmers, K., Sputh, B.H.C.: Integrating and extending JCSP. In: McEwan, A.A., Schneider, S.A., Ifill, W., Welch, P.H. (eds.) The 30th Communicating Process Architectures Conference, CPA 2007. Concurrent Systems Engineering Series, vol. 65, pp. 349–370. IOS Press (2007)
Yu, T., Srisa-an, W., Rothermel, G.: Simracer: an automated framework to support testing for process-level races. In: Proceedings of the 2013 International Symposium on Software Testing and Analysis, ISSTA 2013, p. 167–177. Association for Computing Machinery, New York (2013). https://doi.org/10.1145/2483760.2483771
Acknowledgements
This work has been partly funded by the Ministerio de Ciencia e Innovación of Spain (SAFER project, ref. PID2019-104735RB-C44).
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2025 The Author(s), under exclusive license to Springer Nature Switzerland AG
About this paper
Cite this paper
Fredlund, LÅ., Herranz, Á., Mariño, J. (2025). Checking Concurrency Coding Rules. In: Erdem, E., Vidal, G. (eds) Practical Aspects of Declarative Languages. PADL 2025. Lecture Notes in Computer Science, vol 15537. Springer, Cham. https://doi.org/10.1007/978-3-031-84924-4_8
Download citation
DOI: https://doi.org/10.1007/978-3-031-84924-4_8
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-031-84923-7
Online ISBN: 978-3-031-84924-4
eBook Packages: Computer ScienceComputer Science (R0)