Type Annotations
JSR 308, Annotations on Java Types lays the foundations for stronger typing in Java by extending the language to allow annotations on essentially any use of a type. JSR 308 is part of JSR 337, Java SE 8 Release Contents.
The Type Annotations Project is sponsored by the Compiler Group to host the Reference Implementation of JSR 308. This Reference Implementation is planned for inclusion in JDK 8, the Reference Implementation of Java SE 8.
Design and Specification
-
September 2011: JDK Enhancement Proposal 104, Annotations on Java Types
-
April 2013: Early Draft Review of JSR 308
-
Current specification of JSR 308, with changelog
-
Public comments alias for sending feedback to the JSR 308 Expert Group (no subscription required!)
Implementation
-
Mailing list: type-annotations-dev (Previously jsr308-discuss)
-
Download JDK 8 binaries with support for type annotations. (Built from OpenJDK's type-annotations/type-annotations forest.)
-
Download a standalone
javac
with support for type annotations, with changelog. (Built from the University of Washington's Mercurial repository.)
Applications for type annotations
-
The Checker Framework makes it easy to write and use compiler plug-ins that implement a custom type system. A compiler plug-in enables a programmer to find bugs or to verify their absence. The Checker Framework comes with several type-checking plug-ins that you can try right away.
Inference tools automatically add annotations to your code, making it even easier to start using custom type systems:
-
To infer the
@Nullable
type qualifier, use Daikon. -
To infer the
@NonNull
type qualifier, use the Julia Analyzer, Nit, or JastAdd. -
To infer the
@ReadOnly
type qualifier, use Javarifier.
-
-
Annotation file utilities allow annotations to be managed separately from
.java
and.class
files.
Awards
-
JSR 308 won the Most Innovative Java SE/EE JSR of the Year award in 2007.
-
Co-spec lead Prof. Michael Ernst was nominated as Most Outstanding Spec Lead for Java SE/EE in 2008 and as Outstanding Spec Lead in 2012. Prof. Ernst won a Rock Star award for a presentation at JavaOne 2009.