Java GCJ fixes

This is my incomplete attempt to fix FTBFS with GCJ-JDK.
Ceph still FTBFS but at least with some bugs fixed we'll make it a bit further.