java: avoid runtime dependency on Guava by shipping modified Optional