Avoid writing configurations repeatedly, avoid retrieving class bytes twice, use sun.misc.Resource.getBytes if available.

Signed-off-by: Ross Allan <rallanpcl@gmail.com>