Added Java 6-compatible code of previous commit