Java 1.7 and cache code cleanup

@dbarashev review?