Backport Java 8 fixes