Persistent memoization in Java