NXP-14453: Don't use Java 7 specific code (cherry-picked)