JENKINS-20441 Backport code to run on Java 1.6