A declarative enhancement of JavaScript programs by leveraging the Java metadata infrastructure

Abstract Web browsers have evolved into indispensable software platforms for modern applications. Although JavaScript has become a de-facto lingua franca for developing web applications, the JavaScript software development tools and methodologies lag behind those of languages such as Java and C#. In particular, to enhance JavaScript programs with non-functional concerns (e.g., persistence, security, transactions, and logging) JavaScript developers need to modify the source code by hand. Developers then often end up having to maintain the resulting modified version separately for reasons that include poor design, the complexities of program evolution, and fundamental language limitations. The necessity to modify code by hand could be avoided if JavaScript had metadata facilities for developers to specify non-functional concerns declaratively. To address this problem, we present a novel declarative approach, T ransparent A utomated E nhancement for J ava S cript (TAE-JS) that enhances JavaScript programs with the ability to use declarative metadata. The metadata is expressed by means of Java annotations. We have implemented our technique in an open-source plug-in for the Eclipse IDE. This plug-in allows a developer to enhance the original version of a JavaScript program by specifying concerns declaratively using Java annotations. It then analyzes an original version of the program to automatically generate enhanced program versions by adding the declared concerns. We evaluated TAE-JS with four practical examples that enhance JavaScript programs by declaratively adding concerns such as persistence, security, transactions, and logging. In a user study with ten student developers and three professional engineers at PayPal, the participants viewed favorably TAE-JS's flexible declarative enhancement capabilities, seeing them as a valuable mechanism for implementing non-functional concerns in JavaScript programs. Our evaluation results are promising in demonstrating the potential benefits of our approach to complement existing JavaScript development tools.

[1]  Alan Kaplan,et al.  The Exu approach to safe, transparent and lightweight interoperability , 2001, 25th Annual International Computer Software and Applications Conference. COMPSAC 2001.

[2]  Jörg Kienzle,et al.  AOP: Does It Make Sense? The Case of Concurrency and Failures , 2002, ECOOP.

[3]  Vinod Ganapathy,et al.  Enhancing JavaScript with Transactions , 2012, ECOOP.

[4]  Laurence Duchien,et al.  JAC: A Flexible Solution for Aspect-Oriented Programming in Java , 2001, Reflection.

[5]  Mira Mezini,et al.  Separation of Concerns with Procedures, Annotations, Advice and Pointcuts , 2005, ECOOP.

[6]  Michael J. Donahoo,et al.  Evaluation of Separated Concerns in Web-based Delivery of User Interfaces , 2015 .

[7]  Akihiko Tozawa,et al.  XML Validation for Context-Free Grammars , 2006, APLAS.

[8]  Ralf Lämmel,et al.  Declarative Software Development: Distilled Tutorial , 2014, PPDP '14.

[9]  Gregor Kiczales Aspect-oriented programming , 2005, ICSE '05.

[10]  Keith H. Bennett,et al.  Software maintenance and evolution: a roadmap , 2000, ICSE '00.

[11]  David M. Beazley,et al.  SWIG: An Easy to Use Tool for Integrating Scripting Languages with C and C++ , 1996, Tcl/Tk Workshop.

[12]  Christian Bauer,et al.  Hibernate in action , 2005 .

[13]  Michael L. Van de Vanter,et al.  The Pan language-based editing system , 1992, TSEM.

[14]  Eli Tilevich,et al.  Reusable enterprise metadata with pattern-based structural expressions , 2010, AOSD.

[15]  Eli Tilevich,et al.  Reusing non-functional concerns across languages , 2012, AOSD.

[16]  Kohei Nagashima,et al.  Aspect-jQuery: an aspect-oriented framework for jquery , 2013 .

[17]  Eric Wohlstadter,et al.  Automated object persistence for JavaScript , 2010, WWW '10.

[18]  Terence John Parr,et al.  Enforcing strict model-view separation in template engines , 2004, WWW '04.

[19]  Mira Mezini,et al.  Declaring and Enforcing Dependencies Between .NET Custom Attributes , 2004, GPCE.

[20]  John W. Stamey,et al.  The aspect-oriented web , 2005, SIGDOC '05.

[21]  Dan Grossman,et al.  Supporting dynamic, third-party code customizations in JavaScript using aspects , 2010, OOPSLA.

[22]  Frank Tip,et al.  Chianti: a tool for change impact analysis of java programs , 2004, OOPSLA.

[23]  Sunghun Kim,et al.  Partitioning Composite Code Changes to Facilitate Code Review , 2015, 2015 IEEE/ACM 12th Working Conference on Mining Software Repositories.

[24]  Martin Fowler,et al.  Refactoring - Improving the Design of Existing Code , 1999, Addison Wesley object technology series.

[25]  Ajay Chander,et al.  JavaScript instrumentation for browser security , 2007, POPL '07.

[26]  Ravi Chugh,et al.  Dependent types for JavaScript , 2012, OOPSLA '12.

[27]  Shriram Krishnamurthi,et al.  Semantics and scoping of aspects in higher-order languages , 2006, Sci. Comput. Program..

[28]  Hanspeter Mössenböck,et al.  An efficient native function interface for Java , 2013, PPPJ.

[29]  Andreas Zeller,et al.  The impact of tangled code changes , 2013, 2013 10th Working Conference on Mining Software Repositories (MSR).

[30]  Jacques Noyé,et al.  Towards modular instrumentation of interpreters in JavaScript , 2015, MODULARITY.

[31]  Hironori Washizaki,et al.  AOJS: aspect-oriented javascript programming framework for web development , 2009, ACP4IS '09.

[32]  Eli Tilevich,et al.  Metadata invariants: Checking and inferring metadata coding conventions , 2012, 2012 34th International Conference on Software Engineering (ICSE).

[33]  Barbara G. Ryder,et al.  Blended analysis for performance understanding of framework-based applications , 2007, ISSTA '07.

[34]  Bo Guo,et al.  Interactively Decomposing Composite Changes to Support Code Review and Regression Testing , 2017, 2017 IEEE 41st Annual Computer Software and Applications Conference (COMPSAC).

[35]  William G. Griswold,et al.  An Overview of AspectJ , 2001, ECOOP.

[36]  Harold Ossher,et al.  Hyper/J/sup TM/: multi-dimensional separation of concerns for Java/sup TM/ , 2000, Proceedings of the 2000 International Conference on Software Engineering. ICSE 2000 the New Millennium.

[37]  Craig Walls,et al.  XDoclet in action , 2004 .

[38]  Dan Boneh,et al.  Symmetric Cryptography in Javascript , 2009, 2009 Annual Computer Security Applications Conference.

[39]  Jacques Noyé,et al.  Aspectizing JavaScript security , 2013 .

[40]  Rob Gordon,et al.  Essential Jni: Java Native Interface , 1998 .

[41]  Emerson R. Murphy-Hill,et al.  Manual refactoring changes with automated refactoring validation , 2014, ICSE.

[42]  Miryung Kim,et al.  Refactoring Inspection Support for Manual Refactoring Edits , 2018, IEEE Transactions on Software Engineering.

[43]  Éric Tanter,et al.  AspectScript: expressive aspects for the web , 2010, AOSD.

[44]  Helen J. Wang,et al.  BrowserShield: vulnerability-driven filtering of dynamic HTML , 2006, OSDI '06.

[45]  Benjamin Livshits,et al.  AjaxScope: a platform for remotely monitoring the client-side behavior of web 2.0 applications , 2007, TWEB.