abstractj/kalium — pull request #5 by wmeissner (2013-04-05 00:52:21+00:00)
Title: Use the initialization-on-demand pattern to lazily load the native lib.

This leverages the jvm's lazy loading of classes to delay loading the native lib until the first call to one of its methods.

Previously, referencing any of the classes (such as KeyPair) in any way (e.g. even as a method parameter) could cause it to initialize its 'sodium' static variable, which would in turn cause NaCL to be initialized, and load the library.

With this patch, the native lib won't be loaded until the first time NaCL.sodium() is called, which in turn causes the SingletonHolder class to be loaded, which then loads the native lib.

See http://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom#Example_Java_Implementation