src/share/classes/javax/lang/model/element/Element.java

changeset 1491
9f42a06a49c0
parent 1484
7612fe48be90
child 1494
f805b5e3c9d1
     1.1 --- a/src/share/classes/javax/lang/model/element/Element.java	Thu Jan 10 19:38:57 2013 -0800
     1.2 +++ b/src/share/classes/javax/lang/model/element/Element.java	Mon Jan 14 19:52:36 2013 +0100
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -149,6 +149,56 @@
    1.11      <A extends Annotation> A getAnnotation(Class<A> annotationType);
    1.12  
    1.13      /**
    1.14 +     * Returns an array of all of this element's annotation for the
    1.15 +     * specified type if such annotations are present, else an empty
    1.16 +     * array.  The annotation may be either inherited or directly
    1.17 +     * present on this element. This method will look through a container
    1.18 +     * annotation (if present) if the supplied annotation type is
    1.19 +     * repeatable.
    1.20 +     *
    1.21 +     * <p> The annotations returned by this method could contain an element
    1.22 +     * whose value is of type {@code Class}.
    1.23 +     * This value cannot be returned directly:  information necessary to
    1.24 +     * locate and load a class (such as the class loader to use) is
    1.25 +     * not available, and the class might not be loadable at all.
    1.26 +     * Attempting to read a {@code Class} object by invoking the relevant
    1.27 +     * method on the returned annotation
    1.28 +     * will result in a {@link MirroredTypeException},
    1.29 +     * from which the corresponding {@link TypeMirror} may be extracted.
    1.30 +     * Similarly, attempting to read a {@code Class[]}-valued element
    1.31 +     * will result in a {@link MirroredTypesException}.
    1.32 +     *
    1.33 +     * <blockquote>
    1.34 +     * <i>Note:</i> This method is unlike others in this and related
    1.35 +     * interfaces.  It operates on runtime reflective information &mdash;
    1.36 +     * representations of annotation types currently loaded into the
    1.37 +     * VM &mdash; rather than on the representations defined by and used
    1.38 +     * throughout these interfaces.  Consequently, calling methods on
    1.39 +     * the returned annotation object can throw many of the exceptions
    1.40 +     * that can be thrown when calling methods on an annotation object
    1.41 +     * returned by core reflection.  This method is intended for
    1.42 +     * callers that are written to operate on a known, fixed set of
    1.43 +     * annotation types.
    1.44 +     * </blockquote>
    1.45 +     *
    1.46 +     * @param <A>  the annotation type
    1.47 +     * @param annotationType  the {@code Class} object corresponding to
    1.48 +     *          the annotation type
    1.49 +     * @return this element's annotations for the specified annotation
    1.50 +     *         type if present on this element, else an empty array
    1.51 +     *
    1.52 +     * @see #getAnnotationMirrors()
    1.53 +     * @see #getAnnotation()
    1.54 +     * @see java.lang.reflect.AnnotatedElement#getAnnotations
    1.55 +     * @see EnumConstantNotPresentException
    1.56 +     * @see AnnotationTypeMismatchException
    1.57 +     * @see IncompleteAnnotationException
    1.58 +     * @see MirroredTypeException
    1.59 +     * @see MirroredTypesException
    1.60 +     */
    1.61 +    <A extends Annotation> A[] getAnnotations(Class<A> annotationType);
    1.62 +
    1.63 +    /**
    1.64       * Returns the modifiers of this element, excluding annotations.
    1.65       * Implicit modifiers, such as the {@code public} and {@code static}
    1.66       * modifiers of interface members, are included.

mercurial