Abstract
In object-oriented languages, a notion of behavioural subtyping is needed to enable modular reasoning. This is no longer sufficient when such languages are extended with aspects. In general, all aspects need to be inspected in order to understand the behaviour of a single method or proceed call, which complicates reasoning about aspect-oriented programs. In this paper, we present an approach to modular reasoning that consists of two parts. First, the advice substitution principle, based on behavioural subtyping, identifies when it is possible to remain unaware of an advice while preserving modular reasoning. Second, in cases where it is undesired or impossible to be unaware of an advice, a simple specification clause can be used to restore modular reasoning and to become aware of this advice. We show that our approach effectively enables modular reasoning about pre- and postconditions in a minimal aspect-oriented language called ContractAJ. To ensure the approach is used correctly, we also provide a runtime contract enforcement algorithm that is specified in ContractAJ, and implemented in AspectJ.
Tim Molderez—Funded by a doctoral scholarship of the Research Foundation - Flanders (FWO).
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
An analogous definition of \(\rightharpoonup _{\mathsf {sep}}\) can be given for advice with an execution pointcut.
- 2.
Note that execution pointcuts matching on advice executions are also converted into call pointcuts, which is accepted by ContractAJ’s operational semantics as it reuses the dynamic type as static type in advice executions.
- 3.
An analogous definition of \(\rightharpoonup _{\mathsf {exec}}\) can be given in case an if construct is already present in the execution pointcut.
- 4.
Note that we use two different concatenation symbols to avoid ambiguity. “;” concatenates records in \(\mathcal {J}\) and “+” concatenates tuples in an \(\mathcal {A}\) record.
- 5.
The tuple might still be needed in case an around advice makes multiple proceed calls. This is however not supported, as it is an uncommon scenario and would unnecessarily complicate the semantics.
- 6.
This definition only applies if all advice are ASP-compliant; it will be extended later in Sect. 5.5 to take into account non-ASP-compliant advice as well.
- 7.
- 8.
The evaluation of the condition in if pointcut constructs might involve store-altering rule applications. However, this is harmless as we assume that these conditions are free from side effects and always terminate.
- 9.
The library and source code are available at: https://github.com/timmolderez/adbc.
- 10.
One caveat is that an advice body should make use of its thisJoinPoint variable in order for it to be available for higher-order advice.
References
Agostinho, S., Moreira, A., Guerreiro, P.: Contracts for aspect-oriented design. In: Proceedings of the 2008 AOSD workshop on Software Engineering Properties of Languages and Aspect Technologies (SPLAT), pp. 1:1–1:6. ACM, New York, NY, USA (2008)
Aldrich, J.: Open modules: modular reasoning about advice. In: Gao, X.-X. (ed.) ECOOP 2005. LNCS, vol. 3586, pp. 144–168. Springer, Heidelberg (2005)
America, P.: Designing an object-oriented programming language with behavioural subtyping. In: de Bakker, J.W., de Roever, W.P., Rozenberg, G. (eds.) Foundations of Object-Oriented Languages. LNCS, vol. 489, pp. 60–90. Springer, Heidelberg (1991)
Apel, S., Batory, D.: How AspectJ is used: an analysis of eleven AspectJ programs. J. Object Technol. (JOT) 9(1), 117–142 (2010)
Aracic, I., Gasiunas, V., Mezini, M., Ostermann, K.: An overview of CaesarJ. In: Rashid, A., Akşit, M. (eds.) Transactions on Aspect-Oriented Software Development I. LNCS, vol. 3880, pp. 135–173. Springer, Heidelberg (2006)
Bagherzadeh, M., Rajan, H., Leavens, G.T., Mooney, S.: Translucid contracts: expressive specification and modular verification for aspect-oriented interfaces. In: Proceedings of the Tenth International Conference on Aspect-Oriented Software Development, AOSD 2011, pp. 141–152. ACM, New York, NY, USA (2011)
Bodden, E., Tanter, É., Inostroza, M.: Join point interfaces for safe and flexible decoupling of aspects. ACM Trans. Softw. Eng. Methodol. 23(1), 7:1–7:41 (2014)
Borgida, A., Mylopoulos, J., Reiter, R.: On the frame problem in procedure specifications. IEEE Trans. Softw. Eng. 21(10), 785–798 (1995)
Clarke, D.G., Potter, J.M., Noble, J.: Ownership types for flexible alias protection. SIGPLAN Not. 33(10), 48–64 (1998)
Clement, A., Colyer, A., Kersten, M.: Aspect-oriented programming with AJDT. In: ECOOP Workshop on Analysis of Aspect-Oriented Software (2003)
Clifton, C., Leavens, G.T.: Observers and assistants: a proposal for modular aspect-oriented reasoning. In: Proceedings of the 1st Workshop on Foundations of Aspect-Oriented Languages, FOAL 2002, p. 33 (2002)
Clifton, C., Leavens, G.T.: Obliviousness, modular reasoning, and the behavioral subtyping analogy. In: Workshop on Software Engineering Properties of Languages for Aspect Technologies (SPLAT) (2003)
Clifton, C., Leavens, G.T.: A design discipline and language features for modular reasoning in aspect-oriented programs. Ph.D. thesis, Iowa State University (2005)
Clifton, C., Leavens, G.T., Boyland, J.: MAO: ownership and effects for more effective reasoning about aspects. In: Ernst, E. (ed.) ECOOP 2007. LNCS, vol. 4609, pp. 451–475. Springer, Heidelberg (2007)
Dantas, D.S., Walker, D.: Harmless advice. In: Conference Record of the 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2006, pp. 383–396. ACM, New York, NY, USA (2006)
Dhara, K.K., Leavens, G.T.: Forcing behavioral subtyping through specification inheritance. In: Proceedings of the 18th International Conference on Software Engineering, 1996, pp. 258–267 (1996)
Filman, R.E., Friedman, D.P.: Aspect-oriented programming is quantification and obliviousness. In: Workshop on Advanced separation of Concerns, OOPSLA (2000)
Findler, R.B., Felleisen, M.: Contract soundness for object-oriented languages. In: Proceedings of the 16th ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), pp. 1–15. ACM, New York, NY, USA (2001)
Flatt, M., Krishnamurthi, S., Felleisen, M.: Classes and mixins. In: Proceedings of the 25th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), pp. 171–183. ACM Press, New York, USA, January 1998
Hirschfeld, R., Costanza, P., Nierstrasz, O.: Context-oriented programming. J. Technol. 7(3), 125–151 (2008)
Katz, S.: Aspect categories and classes of temporal properties. In: Rashid, A., Akşit, M. (eds.) Transactions on Aspect-Oriented Software Development I. LNCS, vol. 3880, pp. 106–134. Springer, Heidelberg (2006)
Koppen, C., Störzer, M.: PCDiff: attacking the fragile pointcut problem. In: European Interactive Workshop on Aspects in Software (2004)
Leavens, G.T., Baker, A.L., Ruby, C.: Preliminary design of JML: a behavioral interface specification language for java. SIGSOFT Softw. Eng. Notes 31(3), 1–38 (2006)
Leavens, G.T., Naumann, D.A.: Behavioral subtyping, specification inheritance, and modular reasoning (2006)
Rustan, K., Leino, M.: Data groups: specifying the modification of extended state. SIGPLAN Not. 33(10), 144–153 (1998)
Rustan, K., Leino, M., Müller, P.: Object invariants in dynamic contexts. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 491–515. Springer, Heidelberg (2004)
Liskov, B.H., Wing, J.M.: A behavioral notion of subtyping. ACM Trans. Program. Lang. Syst. (TOPLAS) 16(6), 1811–1841 (1994)
Lorenz, D.H., Skotiniotis, T.: Extending design by contract for aspect-oriented programming, January 2005. http://arxiv.org/abs/cs/0501070
Meyer, B.: Object-Oriented Software Construction, vol. 2. Prentice Hall, New York (1988)
Meyer, B.: Applying “Design by contract”. Computer 25(10), 40–51 (1992)
Müller, P., Poetzsch-Heffter, A., Leavens, G.T.: Modular invariants for layered object structures. Sci. Comput. Program. 62(3), 253–286 (2006)
Naumann, D.A., Barnett, M.: Towards imperative modules: Reasoning. Theor. Comput. Sci. 365(1–2), 143–168 (2006)
Rajan, H., Leavens, G.T.: Ptolemy: a language with quantified, typed events. In: Vitek, J. (ed.) ECOOP 2008. LNCS, vol. 5142, pp. 155–179. Springer, Heidelberg (2008)
Rajan, H., Sullivan, K.J.: Classpects: unifying aspect- and object-oriented language design. In: 27th International Conference on Software Engineering (ICSE), pp. 59–68 (2005)
Rebelo, H., Leavens, G.T., Lima, R.M.F., Borba, P. Ribeiro, M.: Modular aspect-oriented design rule enforcement with XPIDRs. In: Proceedings of the 12th workshop on Foundations of Aspect-Oriented Languages, FOAL 2013, pp. 13–18. ACM, New York, NY, USA (2013)
Hähnle, R., Schaefer, I.: A Liskov principle for delta-oriented programming. In: Margaria, T., Steffen, B. (eds.) Leveraging Applications of Formal Methods, Verification and Validation. Technologies for Mastering Change. LNCS, vol. 7609, pp. 32–46. Springer, Heidelberg (2012)
Rinard, M., Salcianu, A., Bugrara, S.: A classification system and analysis for aspect-oriented programs. In: Proceedings of the 12th ACM SIGSOFT Twelfth International Symposium on Foundations of Software Engineering, SIGSOFT 2004/FSE-12, pp. 147–158. ACM, New York, NY, USA (2004)
Steimann, F., Pawlitzki, T., Apel, S., Kästner, C.: Types and modularity for implicit invocation with implicit announcement. ACM Trans. Softw. Eng. Methodol. 20(1), 1:1–1:43 (2010)
Sullivan, K., Griswold, W.G., Rajan, H., Song, Y., Cai, Y., Shonle, M., Tewari, N.: Modular aspect-oriented design with XPIs. ACM Trans. Softw. Eng. Methodol. 20(2), 5:1–5:42 (2010)
Thüm, T., Schaefer, I., Kuhlemann, M., Apel, S., Saake, G.: Applying design by contract to feature-oriented programming. In: de Lara, J., Zisman, A. (eds.) Fundamental Approaches to Software Engineering. LNCS, vol. 7212, pp. 255–269. Springer, Heidelberg (2012)
Wampler, D.: Aspect-oriented design principles: Lessons from object-oriented design. In: Sixth International Conference on Aspect-Oriented Software Development (2007). http://aosd.net/2007/program/industry/I6-AspectDesignPrinciples.pdf
Wright, A.K., Felleisen, M.: A syntactic approach to type soundness. Inf. Comput. 115(1), 38–94 (1994)
Zhao, J., Rinard, M.: Pipa: a behavioral interface specification language for AspectJ. In: Pezzé, M. (ed.) FASE 2003. LNCS, vol. 2621, pp. 150–165. Springer, Heidelberg (2003)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2015 Springer-Verlag Berlin Heidelberg
About this chapter
Cite this chapter
Molderez, T., Janssens, D. (2015). Modular Reasoning in Aspect-Oriented Languages from a Substitution Perspective. In: Chiba, S., Tanter, É., Ernst, E., Hirschfeld, R. (eds) Transactions on Aspect-Oriented Software Development XII. Lecture Notes in Computer Science(), vol 8989. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-662-46734-3_1
Download citation
DOI: https://doi.org/10.1007/978-3-662-46734-3_1
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-662-46733-6
Online ISBN: 978-3-662-46734-3
eBook Packages: Computer ScienceComputer Science (R0)