Make java 5 compatible
merged java 5 compatibility from branch