Efficient Layer Activation for Switching Context-Dependent Behavior

  • Pascal Costanza
  • Robert Hirschfeld
  • Wolfgang De Meuter
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4228)


Today’s programming platforms do not provide sufficient constructs that allow a program’s behavior to depend on the context in which it is executing. This paper presents the design and implementation of programming language extensions that explicitly support our vision of Context-oriented Programming. In this model, programs can be partitioned into layers that can be dynamically activated and deactivated depending on their execution context. Layers are sets of partial program definitions that can be composed in any order. Context-oriented Programming encourages rich, dynamic modifications of program behavior at runtime, requiring an efficient implementation. We present a dynamic representation of layers that yields competitive performance characteristics for both layer activation/deactivation and overall program execution. We illustrate the performance of our implementation by providing an alternative solution for one of the prominent examples of aspect-oriented programming.


Layer Activation Combination Class Primary Layer Multiple Inheritance Root Layer 
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.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Avgustinov, P., Tibble, J., Christensen, A.S., Hendren, L., Kuzins, S., Lhotak, J., Lhotak, O., de Moor, O., Sereni, D., Sittampalam, G.: Optimizing AspectJ. In: Proceedings of the 2005 ACM SIGPLAN conference on Programming Language Design and Implementation (2005)Google Scholar
  2. 2.
    Barrett, K., Cassels, B., Haahr, P., Moon, D.A., Playford, K., Withington, P.T.: A Monotonic Superclass Linearization for Dylan. In: OOPSLA 1996, Proceedings (1996)Google Scholar
  3. 3.
    Bobrow, D., Goldstein, I.: Representing Design Alternatives. In: Proceedings of the Conference on Artificial Intelligence and the Simulation of Behavior, Amsterdam (July 1980)Google Scholar
  4. 4.
    Bobrow, D., DeMichiel, L., Gabriel, R., Keene, S., Kiczales, G., Moon, D.: Common Lisp Object System Specification. Lisp and Symbolic Computation 1(3-4), 245–394 (1989)CrossRefGoogle Scholar
  5. 5.
    Bockisch, C., Dinkelaker, T., Haupt, M., Krebs, M.: The Steamloom Manual (December 2004), Available:
  6. 6.
    Bockisch, C., Haupt, M., Mezini, M., Ostermann, K.: Virtual Machine Support for Dynamic Join Points. In: AOSD 2004, Proceedings. ACM Press, New York (2004)Google Scholar
  7. 7.
    Bockisch, C., Kanthak, S., Haupt, M., Arnold, M., Mezini, M.: Efficient Control Flow Quantification. In: OOPSLA 2006, Proceedings. ACM Press, New York (2006)Google Scholar
  8. 8.
    Brichau, J., De Meuter, W., De Volder, K.: Jumping Aspects. In: ECOOP 2000 International Workshop on Aspects and Dimensions of Concerns (2000) Google Scholar
  9. 9.
    Büchi, M., Weck, W.: Generic Wrappers. In: Bertino, E. (ed.) ECOOP 2000. LNCS, vol. 1850, p. 201. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  10. 10.
    Chambers, C., Chen, W.: Efficient Multiple and Predicate Dispatching. In: OOPSLA 1999, Proceedings (1999)Google Scholar
  11. 11.
    Chan, P.: The Java Developers Almanac 1.4, Volume 1: Examples and Quick Reference. Addison-Wesley Professional, Reading (2002)Google Scholar
  12. 12.
    Chen, G., Kotz, D.: A Survey of Context-Aware Mobile Computing Research. Technical Report TR2000-381, Dept. of Computer Science, Dartmouth College, Hanover, USA (November 2000)Google Scholar
  13. 13.
    Clifton, C., Millstein, T., Leavens, G.T., Chambers, C.: MultiJava: Design Rationale, Compiler Implementation, and Applications. ACM Transactions on Programming Languages and Systems (TOPLAS) 28(3), 517–575 (2006)CrossRefGoogle Scholar
  14. 14.
    Costanza, P., Kniesel, G., Cremers, A.: Lava – Spracherweiterungen für Delegation in Java. In: JIT 1999 – Java-Informations-Tage 1999, Springer, Informatik Aktuell (1999)Google Scholar
  15. 15.
    Costanza, P.: Dynamically Scoped Functions as the Essence of AOP. In: ECOOP 2003 Workshop on Object-oriented Language Engineering for the Post-Java Era, Darmstadt, Germany, July 22, 2003; ACM Sigplan Notices, 38(8) (August 2003)Google Scholar
  16. 16.
    Costanza, P.: A Short Overview of AspectL. In: European Interactive Workshop on Aspects in Software (EIWAS 2004) Berlin, Germany, September 23–24 (2004)Google Scholar
  17. 17.
    Costanza, P.: How to Make Lisp More Special. In: Proceedings of International Lisp Conference, Stanford (2005)Google Scholar
  18. 18.
    Costanza, P., Hirschfeld, R.: Language Constructs for Context-oriented Programming. In: Proceedings of ACM Dynamic Languages Symposium, San Diego, USA (2005)Google Scholar
  19. 19.
    Dufour, B., Goard, C., Hendren, L., de Moor, O., Sittampalam, G., Verbrugge, C.: Measuring the dynamic behavior of AspectJ programs. In: Proceedings of OOPSLA 2004. ACM Press, New York (2004)Google Scholar
  20. 20.
    Forman, I.R., Forman, N.: Java Reflection in Action. Manning Publications Co. (2004)Google Scholar
  21. 21.
    Fugetta, A., Picco, G.P., Vigna, G.: Understanding Code Mobility. IEEE Transactions on Software Engineering 24(5) (May 1998)Google Scholar
  22. 22.
    Gassanenko, M.: Context-oriented Programming: Evolution of Vocabularies. In: Proceedings of the euroFORTH 1993 Conference. Marianske Lazne, Czech Republic (1993)Google Scholar
  23. 23.
    Gassenenko, M.: Context-oriented Programming. In: euroFORTH 1998, Schloss Dagstuhl, Germany (1998)Google Scholar
  24. 24.
    Gelernter, D., Jagannathan, S., London, T.: Environments as First Class Objects. In: POPL 1987, Proceedings (1987)Google Scholar
  25. 25.
    Hauswirth, M., Sweeney, P.F., Diwan, A., Hind, M.: Vertical Profiling: Understanding the Behavior of Object-Oriented Applications. In: OOPSLA 2004, Proceedings (2004)Google Scholar
  26. 26.
    Hirschfeld, R.: AspectS - Aspect-Oriented Programming with Squeak. In: Aksit, M., Mezini, M., Unland, R. (eds.) NODe 2002. LNCS, vol. 2591, pp. 216–232. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  27. 27.
    Hirschfeld, R., Costanza, P.: Extending Advice Activation in AspectS. In: European Interactive Workshop on Aspects in Software (EIWAS 2005), Brussels, Belgium (2005)Google Scholar
  28. 28.
    Hölzle, U.: Personal communication (1999)Google Scholar
  29. 29.
    Keays, R., Rakotonirainy, A.: Context-oriented Programming. In: International Workshop on Data Engineering for Wireless and Mobile Access, San Diego, USA. ACM Press, New York (2003)Google Scholar
  30. 30.
    Kiczales, G., Rodriguez, L.: Efficient method dispatch in PCL. In: Proceedings of the 1990 ACM conference on LISP and Functionl Programming (1990)Google Scholar
  31. 31.
    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, p. 327. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  32. 32.
    Kniesel, G.: Type-Safe Delegation for Run-Time Component Adaptation. In: Guerraoui, R. (ed.) ECOOP 1999. LNCS, vol. 1628. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  33. 33.
    Lieberman, H.: Using Prototypical Objects to Implement Shared Behavior in Object-oriented Systems. In: OOPSLA 1986, Proceedings (1986)Google Scholar
  34. 34.
    Mezini, M., Ostermann, K.: Conquering Aspects with Caesar. In: 2nd International Conference on Aspect-Oriented Software Development (AOSD 2003), Boston, USA, March 17-21, 2003, pp. 90–100. ACM Press, New York (2003)CrossRefGoogle Scholar
  35. 35.
    Mohnen, M.: Interfaces with Default Implementations in Java (extended abstract). In: Proceedings of Conference on the Principles and Practice of Programming in Java, Dublin, Ireland (June 2002)Google Scholar
  36. 36.
    Moors, A., Smans, J., Truyen, E., Piessens, F., Joosen, W.: Safe language support for feature composition through feature-based dispatch. In: Position paper at 2nd Workshop on Managing Variabilities Consistently in Design and Code (MVCDC 2005), OOPSLA 2005, San Diego, California, USA, October 20 (2005)Google Scholar
  37. 37.
    Nierstrasz, O., Ducasse, S., Reichhart, S., Schärli, N.: Adding Traits to (Statically Typed) Languages. Technical report no. IAM-05-006, Institut für Informatik, Universität Bern, Switzerland (December 2005)Google Scholar
  38. 38.
    Ostermann, K.: Dynamically Composable Collaborations with Delegation Layers. In: Magnusson, B. (ed.) ECOOP 2002. LNCS, vol. 2374, p. 89. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  39. 39.
    Salzman, L., Aldrich, J.: Prototypes with Multiple Dispatch: An Expressive and Dynamic Object Model. In: Black, A.P. (ed.) ECOOP 2005. LNCS, vol. 3586, pp. 312–336. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  40. 40.
    Smith, R., Ungar, D.: A Simple and Unifying Approach to Subjective Objects. Theory and Practice of Object Systems 2(3) (1996)Google Scholar
  41. 41.
    Steele, G.L.: Common Lisp the Language, 2nd edn. Digital Press (1990)Google Scholar
  42. 42.
    Tarr, P., D’Hondt, M., Bergmans, L., Lopes, C.V.: Worshop an Aspects and Dimensions of Concerns: Requirements on, and Challenge Problems For, Advanced Separation of Concerns. In: Malenfant, J., Moisan, S., Moreira, A.M.D. (eds.) ECOOP 2000 Workshops. LNCS, vol. 1964, p. 203. Springer, Heidelberg (2000)Google Scholar
  43. 43.
    Truyen, E., Vanhaute, B., Joosen, W., Verbaeten, P., Jorgensen, B.N.: Dynamic and Selective Combination of Extensions in Component-Based Applications. In: Proceeedings of the 23rd International Conference on Software Engineering, Toronto, Ontario, Canada, May 12-19, 2001, pp. 233–242 (2001)Google Scholar
  44. 44.
    Ungar, D., Smith, R.: Self: The Power of Simplicity. In: OOPSLA 1987, Proceedings (1987)Google Scholar
  45. 45.
    Veit, M., Herrman, S.: Model-View-Controller and ObjectTeams: A Perfect Match of Paradigms. In: 2nd International Conference on Aspect-Oriented Software Development (AOSD 2003), Boston, USA, March 17-21, 2003, pp. 90–100. ACM Press, New York (2003)Google Scholar
  46. 46.
    Wulf, V., Golombek, B.: Exploration Environments: Concept and Empirical Evaluation. In: Proceedings of GROUP 2001. ACM 2001 International Conference on Supporting Group Work, Boulder, Colorado, USA, September 30 - October 3, 2001. ACM Press, New York (2001)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Pascal Costanza
    • 1
  • Robert Hirschfeld
    • 2
  • Wolfgang De Meuter
    • 1
  1. 1.Programming Technology LabVrije Universiteit BrusselBrusselsBelgium
  2. 2.Hasso-Plattner-InstitutUniversität PotsdamPotsdamGermany

Personalised recommendations