Few JDK9 related fixes

Changes apply to older JDKs as well.