Using Annotations to Check Structural Properties of Classes

  • Michael Eichberg
  • Thorsten Schäfer
  • Mira Mezini
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3442)


The specification of meta-information, by using attributes in .NET or annotations in Java, along with the source code is gaining widespread use. Meta-information is used for different purposes such as code generation or configuration of the environment in which a class is deployed. However, in most cases using an annotation also implies that constraints, beyond those defined by the language’s semantics, have to be followed. E.g., a class must define a no-arguments constructor or the parameters of a method must have specific types. Currently, these constraints are not checked at all or only to a very limited extend. Hence, a violation can remain undetected and result in deployment-time or even subtle run-time errors. In this paper, we present a user-extensible framework that enables the definition of constraints to check the properties of annotated elements. Further, we demonstrate the application of the framework to check the constraints defined in the EJB 3.0 specification, and an evaluation of the approach based on checking the xPetstore-EJB3.0 project from within Eclipse to test the performance.


Query Language Path Expression Context Node Implementation Restriction Query Container 
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.


  1. 1.
    Team, X.: XDoclet: Attribute-Oriented Programming,
  2. 2.
    Foundation, A.S.: Commons attributes. (2004)Google Scholar
  3. 3.
    Inc., J.: JBoss AOP 1.0 beta3 (2004),
  4. 4.
    Beust, C.: SGen (2004),
  5. 5.
    DeMichiel, L.G.: Enterprise JavaBeans Specification, Version 2.1. SUN Microsystems (2003)Google Scholar
  6. 6.
    Russell, C.: Java Data Objects, Version 1.0. SUN Microsystems (2002)Google Scholar
  7. 7.
    Sun Microsystems: Java management extensions. White paper, Palo Alto, California, USA (1999)Google Scholar
  8. 8.
    Archer, T.: Inside C#. Microsoft Press (2001)Google Scholar
  9. 9.
    Bloch, J.: A metadata facility for the java programming language. Java Specification Request 175, SUN Microsystems (2002)Google Scholar
  10. 10.
    DeMichiel, L.G.: Enterprise javabeans specification, version 3.0. Java Specification Request 220 (2003)Google Scholar
  11. 11.
    Russell, C.: Java data objects 2.0 - an extension to the jdo specification. Java Specification Request 243 (2004)Google Scholar
  12. 12.
    Zotter, B.: Web services metadata for the java platform. Java Specification Request 181 (2004)Google Scholar
  13. 13.
    Bruce, J.: Jdbc 4.0 api specification. Java Specification Request 221 (2004)Google Scholar
  14. 14.
    Mordani, R.: Common annotations for the java platform. Java Specification Request 250 (2004)Google Scholar
  15. 15.
    Eichberg, M., Mezini, M., Ostermann, K., Schäfer, T.: A kernel for cross-artifact information engineering in software development environments. In: Proceedings of 11th IEEE Working Conference on Reverse Engineering (WCRE). IEEE Computer Society, Los Alamitos (2004) to appearGoogle Scholar
  16. 16.
    Eichberg, M.: Battoxml (2004),
  17. 17.
    Boag, S., Chamberlin, D., Fernández, M.F., Florescu, D., Robie, J., Siméon, J.: Xquery 1.0: an xml query language. Working Draft 23 Juli 2004, (W3C)Google Scholar
  18. 18.
    Clark, J., DeRose, S.: XML Path Language (XPath) Version 1.0 ,
  19. 19.
    Cepa, V., Mezini, M.: Declaring and enforcing dependencies custom attributes. In: Proceedings of the Third International Conference on Generative Programming and Component Engineering (2004)Google Scholar
  20. 20.
    Tchepannou, H., McSweeney, B., Cooley, J.: xPetstore (2003),
  21. 21.
    Hovemeyer, D., Pugh, W.: Finding bugs is easy. SIGPLAN Notices (December 2004)Google Scholar
  22. 22.
    Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns. Professional Computing Series. Addison-Wesley, Reading (1995)Google Scholar
  23. 23.
    Artho, C.: Finding faults in multi-threaded programs (2001),
  24. 24.
  25. 25.
    Eichberg, M., Mezini, M., Schäfer, T., Beringer, C., Hamel, K.M.: Enforcing system-wide properties. In: Proceedings of the 15th australian software engineering conference (ASWEC). IEEE Computer Society, Los Alamitos (2004)Google Scholar
  26. 26.
    Kiczales, G., Hilsdale, E., Hugunin, J., Kersten, M., Palm, J., Griswold, W.G.: An overview of aspectJ. In: Knudsen, J.L. (ed.) ECOOP 2001. LNCS, vol. 2072, pp. 327–355. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  27. 27.
    Shomrat, M., Yehudai, A.: Obvious or not? regulating architectural decisions using aspect-oriented programming. In: Kiczales, G. (ed.) Proceedings of 1st international conference on aspect-oriented software development (AOSD), Enschede, The Netherlands, pp. 3–9. ACM Press, New York (2002)CrossRefGoogle Scholar
  28. 28.
  29. 29.
    Kühne, L., Studman, M., Burn, O., Sukhodolsky, O., Giles, R.: Checkstyle (2004),
  30. 30.
    Evans, D., Larochelle, D.: Improving security using extensible lightweight static analysis. IEEE Software (January/February 2002)Google Scholar
  31. 31.
    Cok, D., Kiniry, J.: Esc/java2 (2004),
  32. 32.
    Rutar, N., Almazan, C.B., Foster, J.S.: A comparison of bug finding tools for java. In: 15th IEEE International Symposium on Software Reliability Engineering, ISSRE 2004 (2004), to appearGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2005

Authors and Affiliations

  • Michael Eichberg
    • 1
  • Thorsten Schäfer
    • 1
  • Mira Mezini
    • 1
  1. 1.Software Technology Group, Department of Computer ScienceDarmstadt University of TechnologyGermany

Personalised recommendations