Abstract
Key features of context-oriented programming (COP) are layers—modules to describe context-dependent behavioral variations of a software system—and their dynamic activation, which can modify the behavior of multiple objects that have already been instantiated. Typechecking programs written in a COP language is difficult because the activation of a layer can even change objects’ interfaces. We formalize a small COP language called \(\text {ContextFJ}_{{<:}}\) with its operational semantics and type system and show its soundness. The language features (1) dynamically activated first-class layers, (2) inheritance of layer definitions, and (3) layer subtyping.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
Re-typechecking inherited methods under the new \(\mathchoice{\mathtt{{requires}}}{\mathtt{{requires}}}{\mathtt{{requires}}}{{\tiny \mathtt {requires}}}\) clause would be another way to relax this condition but this is against modular checking.
- 2.
References
Appeltauer, M., Hirschfeld, R.: The JCop language specification: Version 1.0, April 2012. Number 59. Universitätsverlag Potsdam (2012)
Appeltauer, M., Hirschfeld, R., Lincke, J.: Declarative layer composition with the JCop programming language. J. Object Technol. 12 (2013)
Bettini, L., Capecchi, S., Damiani, F.: On flexible dynamic trait replacement for Java-like languages. Sci. Comput. Program. 78(7), 907–932 (2013)
Bono, V., Patel, A., Shmatikov, V.: A core calculus of classes and mixins. In: Guerraoui, R. (ed.) ECOOP 1999. LNCS, vol. 1628, pp. 43–66. Springer, Heidelberg (1999)
Chiba, S., Igarashi, A., Zakirov, S.: Mostly modular compilation of crosscutting concerns by contextual predicate dispatch. In: Proceedings of the ACM OOPSLA, pp. 539–554 (2010)
Clifton, C., Millstein, T., Leavens, G.T., Chambers, C.: MultiJava: design rationale, compiler implementation, and applications. ACM Trans. Prog. Lang. Syst. 28(3), 517–575 (2006)
Drossopoulou, S., Damiani, F., Dezani-Ciancaglini, M., Giannini, P.: More dynamic object reclassification: Fickle\(_{\rm I\!I}\). ACM Trans. Prog. Lang. Syst. 24(2), 153–191 (2002)
Flatt, M., Krishnamurthi, S., Felleisen, M.: Classes and mixins. In: Proceedings of the ACM POPL, pp. 171–183. ACM (1998)
Hirschfeld, R., Costanza, P., Nierstrasz, O.: Context-oriented programming. J. Object Technol. 7(3), 125–151 (2008)
Hirschfeld, R., Igarashi, A., Masuhara, H.: ContextFJ: a minimal core calculus for context-oriented programming. In: Proceedings of Foundations of Aspect-Oriented Languages (FOAL), March 2011
Igarashi, A., Hirschfeld, R., Masuhara, H.: A type system for dynamic layer composition. In: Proceedings of FOOL, October 2012
Igarashi, A., Inoue, H., Hirschfeld, R., Masuhara, H.: ContextFJ: a minimal calculus for context-oriented programming (2015) (in preparation for submission)
Igarashi, A., Pierce, B.C., Wadler, P.: Featherweight Java: a minimal core calculus for Java and GJ. ACM TOPLAS 23(3), 396–450 (2001)
Inoue, H., Igarashi, A., Appeltauer, M., Hirschfeld, R.: Towards type-safe JCop: a type system for layer inheritance and first-class layers. In: Proceedings of the Workshop on Context-Oriented Programming, pp. 7:1–7:6. ACM (2014)
Kamina, T., Tamai, T.: McJava – a design and implementation of Java with mixin-types. In: Chin, W.-N. (ed.) APLAS 2004. LNCS, vol. 3302, pp. 398–414. Springer, Heidelberg (2004)
Liquori, L., Spiwack, A.: FeatherTrait: a modest extension of Featherweight Java. ACM Trans. Prog. Lang. Syst. 30(2), 11 (2008)
Wright, A.K., Felleisen, M.: A syntactic approach to type soundness. Inf. Comput. 115(1), 38–94 (1994)
Acknowledgments
We thank Tomoyuki Aotani, Malte Appeltauer, Robert Hirschfeld, and Tetsuo Kamina for valuable discussions on the subject. We appreciate valuable comments and suggestions from the anonymous reviewers. This work was supported in part by Kyoto University Design School (Inoue) and MEXT KAKENHI Grant Number 23220001 (Igarashi).
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2015 Springer International Publishing Switzerland
About this paper
Cite this paper
Inoue, H., Igarashi, A. (2015). A Sound Type System for Layer Subtyping and Dynamically Activated First-Class Layers. In: Feng, X., Park, S. (eds) Programming Languages and Systems. APLAS 2015. Lecture Notes in Computer Science(), vol 9458. Springer, Cham. https://doi.org/10.1007/978-3-319-26529-2_24
Download citation
DOI: https://doi.org/10.1007/978-3-319-26529-2_24
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-26528-5
Online ISBN: 978-3-319-26529-2
eBook Packages: Computer ScienceComputer Science (R0)