Posts

Showing posts from November, 2010

More uses for dynamic code in Java.

In 2008 I wrote a library for compiling and running dynamic code in Java. Essence JCF At the time the purpose was to load configuration files which were written in Java rather than XML or properites files. One advantage this library has is that it can load into the current class loader, rather than requiring an additonal class loader so the interface or class can be used immediately in code without the need for reflection. See below for an example. For me, it has been a very cool solution without a unique problem to solve. i.e. there wasn't a problem it solved particularly well. Since then, I have come across a few situations where it is particularly useful. Objects in direct memory Using dynamically generated code, you can build a data store from an interface which is row based or column based, stored either in the heap or in direct memory. Both can reduce the number of objects created improving cache locality and reducing GC times. Precompile expressions Expressions which are