Skip to main content
Log in

Runtime support for type-safe and context-based behavior adaptation

  • Research Article
  • Published:
Frontiers of Computer Science Aims and scope Submit manuscript

Abstract

Context-awareness is becoming critical for mobile and ubiquitous computing, where the application needs dynamically adapt its behavior to its execution environment. Context-oriented programming (COP) languages support dynamic behavior adaptation, however, they do not support dynamic layer addition. As a result, they provide little support for the runtime adaptation of application behavior in case that unpredictable execution environments are encountered. Furthermore, block-structured constructs for layer activation hardly support fine-grain adaptation and separate changes of contexts and execution of context-specific methods with difficulty. In this paper, we propose a virtual machine (VM)-centric approach to address these issues. It incorporates object composition and delegation into the VM to implement layer activation, and extends existing VM services to support dynamic layer addition. To ensure that our approach preserves the type safety properties of the program, we develop a calculus built on featherweight Java (FJ) to describe the approach, focus on type-checking issues, and prove type soundness of the calculus. We also present the implementation and evaluation of our approach. The evaluation demonstrates that our approach has advantages over the compilerbased approach proposed by JCOP.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Hirschfeld R, Costanza P, Nierstrasz O. Context-oriented programming. Journal of Object Technology, 2008, 7(3): 125–151

    Article  Google Scholar 

  2. Appeltauer M, Hirschfeld R, Masuhara H, Haupt M, Kawauchi K. Event-specific software composition in context-oriented programming. In: Software Composition. 2010, 50–65

    Chapter  Google Scholar 

  3. Kamina T, Aotani T, Masuhara H. EventCJ: a context-oriented programming language with declarative event-based context transition. In: Proceedings of the 10th International Conference on Aspect-oriented Software Development. 2011, 253–264

    Google Scholar 

  4. Appeltauer M, Hirschfeld R, Haupt M, Masuhara H. ContextJ: context-oriented programming with Java. Information and Media Technologies, 2011, 6(2): 399–419

    Google Scholar 

  5. Rho T, Schmatz M, Cremers A B. Towards context-sensitive service aspects. In: Workshop on Object Technology for Ambient Intelligence and Pervasive Computing, co-located with ECOOP 06. 2006

    Google Scholar 

  6. Salvaneschi G, Ghezzi C, Pradella M. Contexterlang: introducing context-oriented programming in the actor model. In: Proceedings of the 11th Annual International Conference on Aspect-oriented Software Development. 2012, 191–202

    Chapter  Google Scholar 

  7. Bainomugisha E, Vallejos J, De Roover C, Carreton A L, DeMeuter W. Interruptible context-dependent executions: a fresh look at programming context-aware applications. In: Proceedings of the ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software. 2012, 67–84

    Chapter  Google Scholar 

  8. Würthinger T, Ansaloni D, Binder W, Wimmer C, Mössenböck H. Safe and atomic run-time code evolution for java and its application to dynamic aop. In: Proceedings of the 2011 ACM International Conference on Object Oriented Programming Systems Languages and Applications. 2011, 825–844

    Chapter  Google Scholar 

  9. Bettini L, Bono V, Venneri B. Delegation by object composition. Science Computer Programming, 2011, 76(11)

    Google Scholar 

  10. Lieberman H. Using prototypical objects to implement shared behavior in object-oriented systems. ACM SIGPLAN Notices, 1986, 21(11): 214–223

    Article  MathSciNet  Google Scholar 

  11. Igarashi A, Pierce B C, Wadler P. Featherweight Java: a minimal core calculus for Java and GJ. ACM Transactions on Programming Languages and Systems, 2001, 23(3): 396–450

    Article  Google Scholar 

  12. Lougher R. Jam VM. http://jamvm.sourceforge.net/, 2010

  13. Apel S, Kästner C, Lengauer C. Feature featherweight Java: a calculus for feature-oriented programming and stepwise refinement. In: Proceedings of the 7th International Conference on Generative Programming and Component Engineering. 2008, 101–112

    Google Scholar 

  14. Bettini L, Bono V, Venneri B. Object incompleteness and dynamic composition in Java-like languages. Lecture Notes in Computer Science, 2008, 11: 198–217

    Google Scholar 

  15. Wright A K, Felleisen M. A syntactic approach to type soundness. Information and Computation, 1994, 115(1): 38–94

    Article  MATH  MathSciNet  Google Scholar 

  16. Ekman T, Hedin G. The JastAdd extensible Java compiler. In: Proceedings of the 22nd annual ACM SIGPLAN Conference on Objectoriented Programming Systems and Applications. 2007, 1–18

    Chapter  Google Scholar 

  17. Hedin G, Magnusson E. JastAdd-an aspect-oriented compiler construction system. Science of Computer Programming, 2003, 47(1): 37–58

    Article  MATH  MathSciNet  Google Scholar 

  18. Bull M, Smith L, Westhead M, Henty D, Davey R. Benchmarking java grande applications. In: Proceedings of the 2nd International Conference on The Pratical Application of Java. 2000

    Google Scholar 

  19. Haupt M, Mezini M. Micro-measurements for dynamic aspect-oriented systems. Lecture Notes in Computer Science, 2004, 3263: 81–96

    Article  Google Scholar 

  20. Appeltauer M, Hirschfeld R, Haupt M, Lincke J, Perscheid M. A comparison of context-oriented programming languages. In: Proceedings of International Workshop on Context-oriented Programming. 2009, 6:1–6:6

    Article  Google Scholar 

  21. Costanza P, Hirschfeld R. Language constructs for context-oriented programming: an overview of ContextL. In: Proceedings of the 2005 Symposium on Dynamic Languages. 2005, 1–10

    Chapter  Google Scholar 

  22. Steele G L. Common lisp the language, 2nd ed. Digital Press, 1990

    MATH  Google Scholar 

  23. Hirschfeld R, Igarashi A, Masuhara H. Contextfj: a minimal core calculus for context-oriented programming. In: Proceedings of the 10th International Workshop on Foundations of Aspect-oriented Languages. 2011, 19–23

    Chapter  Google Scholar 

  24. Subramanian S, Hicks M, McKinley K S. Dynamic software updates: a VM-centric approach. ACM Sigplan Notices, 2009, 44(6): 1–12

    Article  Google Scholar 

  25. Malabarba S, Pandey R, Gragg J, Barr E, Barnes J F. Runtime support for type-safe dynamic Java classes. In: Proceedings of the 14th European Conference on Object Oriented Programming. 2000, 337–361

    Google Scholar 

  26. Gamma E, Helm R, Johnson R, Vlissides J. Design patterns elements of reusable object-oriented software. Addison-Wesley Longman, 1995

  27. Mukhija A, Glinz M. A framework for dynamically adaptive applications in a self-organized mobile network environment. In: Proceedings of the 24th International Conference on Distributed Computing Systems Workshops. 2004, 368–374

    Google Scholar 

  28. Tamai T, Ubayashi N, Ichiyama R. An adaptive object model with dynamic role binding. In: Proceedings of the 27th International Conference on Software Engineering. 2005, 166–175

    Google Scholar 

  29. Zhao Y. Granule-oriented programming. Sigplan Notices, 2004, 39(12): 107–118

    Article  Google Scholar 

  30. Zhao Y, Zhu C, Han B, Zeng Q. Calculus using fitness testing for method redirection. Journal of Software, 2013, 24(7): 1495–1511

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Yinliang Zhao.

Additional information

Changpeng Zhu is a doctoral candidate at the School of Electronic and Information Engineering at Xi’an Jiaotong University, China. His research interests focus on the Java virtual machine and type systems.

Yinliang Zhao is a professor of Computer Science at the School of Electronic and Information Engineering at Xi’an Jiaotong University, China. He received his PhD in Computer Science from Xi’an Jiaotong University at 1995. His research interests focus on theory and implementation of programming languages, Granule-oriented programming, etc.

Bo Han is a doctoral candidate of Computer Science at the School of Electronic and Information Engineering at Xi’an Jiaotong University, China. His research interests focus on in programming languages and applications.

Qinghua Zeng is a doctoral candidate at the School of Electronic and Information Engineering at Xi’an Jiaotong University, China. Her research interests focus on the areas of compilers and optimization.

Ying Ma is studying for a MS of Computer Science at the School of Electronic and Information Engineering at Xi’an Jiaotong University, China. Her research interests focus on speculative multithreading and compilers.

Rights and permissions

Reprints and permissions

About this article

Cite this article

Zhu, C., Zhao, Y., Han, B. et al. Runtime support for type-safe and context-based behavior adaptation. Front. Comput. Sci. 8, 17–32 (2014). https://doi.org/10.1007/s11704-013-2337-6

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s11704-013-2337-6

Keywords

Navigation