Type Annotations (JSR-308) Support

As you all know, JDK 7 includes new java syntax for Annotations on Types (JSR-308)

To enable JSR-308 support in Maia, set the Java language level level to 7:

Then you can declare and use your weird type annotations almost everywhere:

To enable type annotations compilation in IntelliJ IDEA, download the latest Open JDK build, patch it as described in Type Annotations Prototype Implementation FAQ, and attach it to an IntelliJ IDEA project via Project SDK on Project tab in the Project Structure dialog (Ctrl+Alt+Shift+S).

This entry was posted in New Features and tagged , . Bookmark the permalink.

3 Responses to Type Annotations (JSR-308) Support

  1. Eugene Kirpichov says:

    Thank you! I am craving for a release of JDK7 to finally beat the hell out of bugs in my programs :)

  2. Nick Fortescue says:

    I’m using IntelliJ 10. Is there a currently recommended way to enable type annotations compilation? I know JSR-308 has now been postponed to Java 8. I can see that the Project language level now says Annotations under Java 8.

    However, the instructions for patching the type annotations compiler no longer work. The recommended way of installing seems to be downloading the checker framework, and using the javac there. However, setting the project SDK insists on it being a JSDK or an IntelliJ IDEA plugin SDK, which doesn’t work with the javac for the JSR-308 project.

    Is there any way in IntelliJ I can do what the javac/javac.bat scripts do and set the bootclasspath to be jsr308-all.jar?

  3. Nick Fortescue says:

    I’ve found a workaround. For those also with this problem they might want to look at: http://blog.nickfortescue.com/2010/12/jsr308-type-annotations-compiler.html

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">