Abstract:
Some context-oriented programming languages are implemented, but all layers in these languages are compiled into executable codes of programs, which increases the size of executable codes and restricts application ranges of programs. In this paper, a VM-centric approach is proposed to address these issues. It incorporates object composition and delegation into VM to implement layer activation, and extends existing VM services to support dynamic layer binding. To assure that the approach preserves type safety properties of the program, a calculus built on Featherweight Java is developed to describe it. Based on the calculus, the influences that the approach imposes on the type safety of the program are formally analyzed, the constraints on it are also proposed, and a formally proof is presented which ensures that the approach preserves the type safety of the program when these constraints are satisfied. Under guidance of the calculus, an implementation of the approach is presented and evaluated. The calculus and the implementation illustrate how to extend Java-like languages to support dynamic layer binding in a type safe way.