Java8 support - WIP for #738

This is based on work by @rmannibucau