[JSR308] How to do getAnnotation in Tree structure ?
Chester Chen
CChen at ascentmedia.com
Thu Dec 18 12:07:26 EST 2008
I was looking at the Tree class in Javac and hoping to find something something similar to
Element class's getAnnotation();
/**
* Returns this element's annotation for the specified type if
* such an annotation is present, else {@code null}. The
* annotation may be either inherited or directly present on this
* element.
*
* <p> The annotation returned by this method could contain an element
* whose value is of type {@code Class}.
* This value cannot be returned directly: information necessary to
* locate and load a class (such as the class loader to use) is
* not available, and the class might not be loadable at all.
* Attempting to read a {@code Class} object by invoking the relevant
* method on the returned annotation
* will result in a {@link MirroredTypeException},
* from which the corresponding {@link TypeMirror} may be extracted.
* Similarly, attempting to read a {@code Class[]}-valued element
* will result in a {@link MirroredTypesException}.
*
* <blockquote>
* <i>Note:</i> This method is unlike others in this and related
* interfaces. It operates on runtime reflective information —
* representations of annotation types currently loaded into the
* VM — rather than on the representations defined by and used
* throughout these interfaces. Consequently, calling methods on
* the returned annotation object can throw many of the exceptions
* that can be thrown when calling methods on an annotation object
* returned by core reflection. This method is intended for
* callers that are written to operate on a known, fixed set of
* annotation types.
* </blockquote>
*
* @param <A> the annotation type
* @param annotationType the {@code Class} object corresponding to
* the annotation type
* @return this element's annotation for the specified annotation
* type if present on this element, else {@code null}
*
* @see #getAnnotationMirrors()
* @see java.lang.reflect.AnnotatedElement#getAnnotation
* @see EnumConstantNotPresentException
* @see AnnotationTypeMismatchException
* @see IncompleteAnnotationException
* @see MirroredTypeException
* @see MirroredTypesException
*/
<A extends Annotation> A getAnnotation(Class<A> annotationType);
I couldn't find something similar on Tree, is there an reason for this ?
Obviously, this is a question for Sun, but I thought you might know some background information.
Chester
-----Original Message-----
From: jsr308-bounces at lists.csail.mit.edu on behalf of Mahmood Ali
Sent: Wed 12/17/2008 4:00 PM
To: JSR 308 (Annotations) mailing list
Subject: [JSR308] Release 0.8.4 of JSR 308 javac, Checker Framework,and checkers
We have released version 0.8.4 of the JSR 308 specification and
implementation and of the Checker Framework. You can always review
the latest version of the specification at: http://groups.csail.mit.edu/pag/jsr308/specification/java-annotation-design.html
; and download the latest version of these tools at:http://groups.csail.mit.edu/pag/jsr308/
.
The JSR 308 implementation is a backward-compatible extension to
javac. The Checker Framework makes it easy to write a tool that finds
or prevents errors; the tool is expressed as a type-checker for a
pluggable type system. The Checker Framework distribution includes
sample checkers.
This release includes support for ElementType.TYPE_USE, and many bug
fixes to the compiler and the checker framework.
The changlogs of the specification and the implementations appear below.
- Mahmood
---- Changelog for JSR 308 implementation ----
Version 0.8.4, 17 Dec 2008
Functionality
Added support for TYPE_USE annotation target
Bug fixes
javac rejects more some invalid type annotations
- e.g annotations with missing or repeated member values
javac and other programs properly handle filenames containing spaces
Testing
Added compiler tests for jsr308 implementation
---- Changelog for Checker Framework ----
Version 0.8.4, 17 Dec 2008
Distribution
Included checkers-quals.jar which contains the qualifiers only
Framework
Fixed bugs related to inner classes
Fixed a bug related to resolving polymorphic qualifiers
within static methods
Manual
Added 'Distributing your annotated project'
_______________________________________________
JSR308 mailing list
JSR308 at lists.csail.mit.edu
https://lists.csail.mit.edu/mailman/listinfo/jsr308
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.csail.mit.edu/pipermail/jsr308/attachments/20081218/cb711b45/attachment.htm
More information about the JSR308
mailing list