Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8225495: Note whether returned annotations are declaration annotation…
…s or type annotations

Reviewed-by: jjg
  • Loading branch information
jddarcy committed Feb 27, 2020
1 parent efdc003 commit ed620249786b710353e69146c476a0f8ca9c300e
@@ -39,10 +39,16 @@
* are on a <em>declaration</em>, whereas annotations on a type are on
* a specific <em>use</em> of a type name.
*
* As defined by <cite>The Java&trade; Language Specification</cite>
* section {@jls 9.7.4}, an annotation on an element is a
* <em>declaration annotation</em> and an annotation on a type is a
* <em>type annotation</em>.
*
* The terms <em>directly present</em>, <em>present</em>,
* <em>indirectly present</em>, and <em>associated </em> are used
* throughout this interface to describe precisely which annotations
* are returned by the methods defined herein.
* throughout this interface to describe precisely which annotations,
* either declaration annotations or type annotations, are returned by
* the methods in this interface.
*
* <p>In the definitions below, an annotation <i>A</i> has an
* annotation type <i>AT</i>. If <i>AT</i> is a repeatable annotation
@@ -53,7 +59,10 @@
*
* <ul>
*
* <li><i>A</i> is explicitly or implicitly declared as applying to
* <li><i>A</i> is {@linkplain
* javax.lang.model.util.Elements#getOrigin(AnnotatedConstruct,
* AnnotationMirror) explicitly or implicitly}
* declared as applying to
* the source code representation of <i>C</i>.
*
* <p>Typically, if exactly one annotation of type <i>AT</i> appears in
@@ -122,6 +131,8 @@
* @since 1.8
* @jls 9.6 Annotation Types
* @jls 9.6.4.3 {@code @Inherited}
* @jls 9.7.4 Where Annotations May Appear
* @jls 9.7.5 Multiple Annotations of the Same Type
*/
public interface AnnotatedConstruct {
/**
@@ -35,7 +35,6 @@
import javax.lang.model.type.*;
import javax.lang.model.util.*;


/**
* Represents a program element such as a module, package, class, or method.
* Each element represents a static, language-level construct
@@ -268,26 +267,43 @@ public interface Element extends javax.lang.model.AnnotatedConstruct {
@Override
int hashCode();


/**
* {@inheritDoc}
*
* <p> To get inherited annotations as well, use {@link
* <p>To get inherited annotations as well, use {@link
* Elements#getAllAnnotationMirrors(Element)
* getAllAnnotationMirrors}.
*
* <p>Note that any annotations returned by this method are
* declaration annotations.
*
* @since 1.6
*/
@Override
List<? extends AnnotationMirror> getAnnotationMirrors();

/**
* {@inheritDoc}
*
* <p>Note that any annotation returned by this method is a
* declaration annotation.
*
* @since 1.6
*/
@Override
<A extends Annotation> A getAnnotation(Class<A> annotationType);

/**
* {@inheritDoc}
*
* <p>Note that any annotations returned by this method are
* declaration annotations.
*
* @since 8
*/
@Override
<A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType);

/**
* Applies a visitor to this element.
*
@@ -137,6 +137,39 @@ public interface TypeMirror extends javax.lang.model.AnnotatedConstruct {
*/
String toString();

/**
* {@inheritDoc}
*
* <p>Note that any annotations returned by this method are type
* annotations.
*
* @since 8
*/
@Override
List<? extends AnnotationMirror> getAnnotationMirrors();

/**
* {@inheritDoc}
*
* <p>Note that any annotation returned by this method is a type
* annotation.
*
* @since 8
*/
@Override
<A extends Annotation> A getAnnotation(Class<A> annotationType);

/**
* {@inheritDoc}
*
* <p>Note that any annotations returned by this method are type
* annotations.
*
* @since 8
*/
@Override
<A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType);

/**
* Applies a visitor to this type.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -514,6 +514,9 @@ default ModuleElement getModuleOf(Element e) {
* Returns all annotations <i>present</i> on an element, whether
* directly present or present via inheritance.
*
* <p>Note that any annotations returned by this method are
* declaration annotations.
*
* @param e the element being examined
* @return all annotations of the element
* @see Element#getAnnotationMirrors

0 comments on commit ed62024

Please sign in to comment.