The problem was caused by the way I added the Eclipse annotation jar to the project's build path. I used the Quick Fix called "Copy library with default null annotations to build path", which adds an old version of the jar (org.eclipse.jdt.annotation_1.1.0.v20140129-1625.jar
). This version is the pre-java-8 version, and does not support type annotations.
The fix is to put the correct (java-8) version of the jar on the build path. This version came with the Kepler Java 8 feature patch, and is located in the 'plugins' directory in the Eclipse installation directory: org.eclipse.jdt.annotation_2.0.0.v20140317-1808.jar
. If you add this jar to your build path, type annotations work fine.
Credits to Thomas Schindl!