View Post
Development

registering jni methods when using proguard

When writing Java software, it’s sometimes needed to call some native code, and mostly this has been achieved by writing a JNI adapter, and relying on the magic of the java runtime to link the methods in the library to the abstract native java methods.

Here we show another way to do this, applicable mostly when using Java in an embedded device, but perhaps in other settings too, where the java code can be ProGuard’ed and all symbols removed from the C objects.

View Post
Development

Unit Testing Servlets Using Jetty

Jetty is a very lightweight servlet container, it starts up in just a handful of milliseconds, and easily allows you to unit test your HTTP Servlets.

Unfortunately, the Jetty API isn’t that easy to navigate. Here is a ServletRunner that will start up a Jetty container, and some useful stuff that is easy to integrate into your unit tests to test the servlets.

View Post
Development

Double Brace Initialization

Double brace initialization in Java is a great way to work around APIs that require loads of calls to setters to initialize initial object state.

I needed to create an ATOM feed, and found the ROME jar. This seemed to meet my needs, but I didn’t like the example code.