Correcting improper use of Java 7 API