Abstract
We present a technique for automatically weaving structural invariant checks into an existing collection of classes. Using variations on existing design patterns, we use a concise specification to generate from this collection a new set of classes that implement the interfaces of the originals, but with the addition of user-specified class invariant checks. Our work is notable in the scarcity of assumptions made. Unlike previous design pattern approaches to this problem, our technique requires no modification of the original source code, relies only on single inheritance, and does not require that the attributes used in the checks be publicly visible. We are able to instrument a wide variety of class hierarchies, including those with pure interfaces, abstract classes and classes with type parameters. We have implemented the construction as an Eclipse plug-in for Java development.
Chapter PDF
Similar content being viewed by others
Keywords
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.
References
Liskov, B.H., Wing, J.M.: A behavioral notion of subtyping. ACM TOPLAS 16(6), 1811–1841 (1994)
Liskov, B., Guttag, J.: Program Development in Java: Abstraction, Specification, and Object-Oriented Design. Addison-Wesley (2001)
Meyer, B.: Object-Oriented Software Construction, 2nd edn. Prentice Hall (1997)
Flanagan, C., Leino, K.R.M., Lillibridge, M., Nelson, G., Saxe, J.B., Stata, R.: Extended static checking for Java. In: PLDI 2002, pp. 234–245. ACM Press (2002)
Leavens, G.T., Baker, A.L., Ruby, C.: Preliminary design of JML: A behavioral interface specification language for Java. ACM SIGSOFT Software Engineering Notes 31(3), 1–38 (2006)
Liu, H., Qin, L., Wang, J., Vemuri, N., Jia, X.: Static and dynamic contract verifiers for Java. In: Hamza, M.H. (ed.) SEA 2003, pp. 593–598. ACTA Press (2003)
Karaorman, M., Hölze, U., Bruno, J.: jContractor: A Java library to support design by contract. Technical Report TRCS98-31, University of California at Santa Barbara (1998)
Prasetya, W., Vos, T., Baars, A.: Trace-based reflexive testing of OO programs. Technical Report UU-CS-2007-037, Dept. of Information and Computing Sciences, Utrecht University (2007)
Prasetya, W., Vos, T., Baars, A.: Trace-based reflexive testing of OO programs with T2. In: STVV 2008, pp. 151–160. IEEE Press (2008)
Java Modeling Language (JML) Homepage, http://www.eecs.ucf.edu/~leavens/JML/
Kiczales, G., Lamping, J., Mendhekar, A., Maeda, C., Lopes, C.V., Loingtier, J.M., Irwin, J.: Aspect-Oriented Programming. In: Akşit, M., Matsuoka, S. (eds.) ECOOP 1997. LNCS, vol. 1241, pp. 220–242. Springer, Heidelberg (1997)
The AspectJ programming guide, http://www.eclipse.org/aspectj/doc/released/progguide/
Briand, L.C., Dzidek, W., Labiche, Y.: Instrumenting contracts with aspect-oriented programming to increase observability and support debugging. In: ICSM 2005. IEEE Press (2005)
Skotiniotis, T., Lorenz, D.H.: Cona: Aspects for contracts and contracts for aspects. In: Vlissides, J.M., Schmidt, D.C. (eds.) OOPSLA 2004 Companion, pp. 196–197. ACM Press (2004)
Czarnecki, K., Eisenecker, U.W.: Generative Programming: Methods, Tools, and Applications. Addison-Wesley (2000)
Balzer, S., Eugster, P.T., Meyer, B.: Can Aspects Implement Contracts? In: Guelfi, N., Savidis, A. (eds.) RISE 2005. LNCS, vol. 3943, pp. 145–157. Springer, Heidelberg (2006)
Agostinho, S., Moreira, A., Guerreiro, P.: Contracts for aspect-oriented design. In: SPLAT 2008. ACM Press, New York (2008)
Klaeren, H., Pulvermüller, E., Rashid, A., Speck, A.: Aspect Composition Applying the Design by Contract Principle. In: Butler, G., Jarzabek, S. (eds.) GCSE 2000. LNCS, vol. 2177, pp. 57–69. Springer, Heidelberg (2001)
Gibbs, T.H., Malloy, B.A., Power, J.F.: Automated validation of class invariants in C++ applications. In: ASE 2002, pp. 205–214. IEEE Pr. (September 2002)
Malloy, B.A., Power, J.F.: Exploiting design patterns to automate validation of class invariants. Software Testing, Verification and Reliability 16(2), 71–95 (2006)
Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley (1995)
JSON Homepage, http://www.json.org/
Lambda expressions for the Java programming language, http://jcp.org/aboutJava/communityprocess/edr/jsr335/index2.html
McConnell, S.: Code Complete: A Practical Handbook of Software Construction. Microsoft Press (2004)
Shatnawi, R.: A quantitative investigation of the acceptable risk levels of object-oriented metrics in open-source systems. IEEE Transactions on Software Engineering 36(2), 216–225 (2010)
Briand, L.C., Dzidek, W., Labiche, Y.: Investigating the use of analysis contracts to improve the testability of object-oriented code. Software—Practice and Experience 33(7), 637–672 (2003)
Le Traon, Y., Baudry, B., Jézéquel, J.M.: Design by contract to improve software vigilance. IEEE Transactions on Software Engineering 32(6), 571–586 (2006)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2013 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Lasseter, J., Cipriano, J. (2013). Design Pattern-Based Extension of Class Hierarchies to Support Runtime Invariant Checks. In: Cortellessa, V., Varró, D. (eds) Fundamental Approaches to Software Engineering. FASE 2013. Lecture Notes in Computer Science, vol 7793. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-37057-1_12
Download citation
DOI: https://doi.org/10.1007/978-3-642-37057-1_12
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-37056-4
Online ISBN: 978-3-642-37057-1
eBook Packages: Computer ScienceComputer Science (R0)