lib/java: more Preconditions on Optional's