allowing programmers to see the result of code
changes instantly, without stopping application
execution (JRebel, 2017). Modified classes are
recompiled and reloaded in the running application.
JRebel allows changes in the structure of classes.
Classes are instrumented with a native Java agent
using the JVM Tool Interface, and a particular class
loader. Each class is changed to a master class and
different support anonymous classes that are
dynamically JIT compiled (Kabanov, 2017). JRebel
does not check that the whole application has no type
errors. Thus, application execution crashes when
changes in a class imply errors in a program (e.g., a
method is removed and it is later invoked).
MetaML is a statically typed programming
language that supports program manipulation (Taha,
2000). It allows the programmer to construct,
combine and execute code fragments in a type safe
manner. In this way, dynamically evaluated programs
do not produce type errors. MetaML does not support
the manipulation of dynamically evaluated code; i.e.,
evaluation of code represented as a string, unknown
at compile time. Therefore, its metaprogramming
features cannot be used to adapt applications to new
requirements emerged after their execution.
5 CONCLUSIONS
The proposed library shows how, with the existing
standard Java elements, it is possible to include
structural intercession and dynamic code evaluation
services in the standard Java platform and language,
modifying neither of them. Although the runtime
adaptation mechanism proposed has an execution
performance penalty, the system has been designed to
reduce it when the JVM reaches a steady state after
application adaptation. These metaprogramming
services bring Java closer to the runtime adaptability
of dynamic languages, without losing the benefits of
its static type system.
We have a running proof-of-concept prototype,
which successfully executed all the examples shown
in this article. Currently, it requires the use of Java
source code, and its runtime performance has not
been heavily optimized.
We plan to added services for allowing the
runtime adaptability of class hierarchies. Then, apply
heavy optimizations to make its steady state
execution time close to Java. The last step of the
project is to allow the dynamic adaptation of running
applications that have been modified and recompiled.
The objective of this last step is not only to adapt
single classes but also whole applications.
ACKNOWLEDGEMENTS
This work has been funded by the European Union,
through the European Regional Development Funds
(ERDF); and the Principality of Asturias, through its
Science, Technology and Innovation Plan (grant
GRUPIN14-100). We have also received funds from
the Banco Santander through its support to the
Campus of International Excellence.
REFERENCES
Andersson, J., Ritzau, T., 2000. Dynamic code update in
JDrums. In Proceedings of the ICSE’00 Workshop on
Software Engineering for Wearable and Pervasive
Computing.
Andersson, J., 2000. A deployment system for pervasive
computing. In International Conference on Software
Maintenance. Proceedings, pp. 262–270.
Conde, P., Ortin, F., 2014. Jindy: a Java library to support
invokedynamic. Computer Science and Information
Systems 11(1), pp. 47-68.
Gamma, E., Helm, R., Johnson, R., Vlissides, J., 1994.
Design patterns: elements of reusable object-oriented
software, Addison-Wesley Professional.
Garcia, M., Ortin, F., Quiroga, J., 2016. Design and
implementation of an efficient hybrid dynamic and
static typing language. Software: Practice and
Experience 46(2), pp. 199-226.
Georges, A., Buytaert, D., Eeckhout, L., 2007. Statistically
rigorous Java performance evaluation. In Object-
Oriented Programming Systems and Applications,
OOPSLA ’07, NY, USA, pp. 57–76.
JavaParser, 2017. Process Java code programmatically.
http://javaparser.org
JRebel, 2017. Zero Turnaround JRebel, Reload code
changes instantly.
https://zeroturnaround.com/software/jrebel
Kabanov, J., 2017. Reloading Java Classes 401: HotSwap
and JRebel — Behind the Scenes. Zero Turnaround.
https://zeroturnaround.com/rebellabs/reloading_java_c
lasses_401_hotswap_jrebel
Malabarba, S., Pandey, R., Gragg, J., Barr, E., Barnes, J.F.,
2000. Runtime Support for Type-Safe Dynamic Java
Classes. In Proceedings of the 14th European
Conference on Object-Oriented Programming, London,
UK, pp. 337–361.
Meijer, E., Drayton, P., 2004. Dynamic Typing When
Needed: The End of the Cold War Between
Programming Languages. In Proceedings of the
OOPSLA Workshop on Revival of Dynamic
Languages.
Oracle, 2011. JSR 292, supporting dynamically typed
languages on the Java platform.
https://www.jcp.org/en/jsr/detail?id=292