Fix compilation on JDK7 on OS X. Closes #499, #487.