langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/AnnoConstruct.java
changeset 26266 2d24bda701dc
parent 25874 83c19f00452c
child 28341 8f015bb3a75f
equal deleted inserted replaced
26265:46aacfffd3b5 26266:2d24bda701dc
    30 import java.lang.reflect.Method;
    30 import java.lang.reflect.Method;
    31 
    31 
    32 import javax.lang.model.AnnotatedConstruct;
    32 import javax.lang.model.AnnotatedConstruct;
    33 
    33 
    34 import com.sun.tools.javac.model.AnnotationProxyMaker;
    34 import com.sun.tools.javac.model.AnnotationProxyMaker;
       
    35 import com.sun.tools.javac.util.DefinedBy;
       
    36 import com.sun.tools.javac.util.DefinedBy.Api;
    35 import com.sun.tools.javac.util.List;
    37 import com.sun.tools.javac.util.List;
    36 import com.sun.tools.javac.util.ListBuffer;
    38 import com.sun.tools.javac.util.ListBuffer;
    37 
    39 
    38 /**
    40 /**
    39  * Common super type for annotated constructs such as Types and Symbols.
    41  * Common super type for annotated constructs such as Types and Symbols.
    48  */
    50  */
    49 public abstract class AnnoConstruct implements AnnotatedConstruct {
    51 public abstract class AnnoConstruct implements AnnotatedConstruct {
    50 
    52 
    51 
    53 
    52     // Override to enforce a narrower return type.
    54     // Override to enforce a narrower return type.
    53     @Override
    55     @Override @DefinedBy(Api.LANGUAGE_MODEL)
    54     public abstract List<? extends Attribute.Compound> getAnnotationMirrors();
    56     public abstract List<? extends Attribute.Compound> getAnnotationMirrors();
    55 
    57 
    56 
    58 
    57     // This method is part of the javax.lang.model API, do not use this in javac code.
    59     // This method is part of the javax.lang.model API, do not use this in javac code.
    58     protected <A extends Annotation> Attribute.Compound getAttribute(Class<A> annoType) {
    60     protected <A extends Annotation> Attribute.Compound getAttribute(Class<A> annoType) {
    72         return (A[]) java.lang.reflect.Array.newInstance(annoType, 0);  // annoType is the Class for A
    74         return (A[]) java.lang.reflect.Array.newInstance(annoType, 0);  // annoType is the Class for A
    73     }
    75     }
    74 
    76 
    75 
    77 
    76     // This method is part of the javax.lang.model API, do not use this in javac code.
    78     // This method is part of the javax.lang.model API, do not use this in javac code.
       
    79     @DefinedBy(Api.LANGUAGE_MODEL)
    77     public <A extends Annotation> A[] getAnnotationsByType(Class<A> annoType) {
    80     public <A extends Annotation> A[] getAnnotationsByType(Class<A> annoType) {
    78 
    81 
    79         if (!annoType.isAnnotation())
    82         if (!annoType.isAnnotation())
    80             throw new IllegalArgumentException("Not an annotation type: "
    83             throw new IllegalArgumentException("Not an annotation type: "
    81                                                + annoType);
    84                                                + annoType);
   168         }
   171         }
   169         return compounds.toArray(new Attribute.Compound[compounds.size()]);
   172         return compounds.toArray(new Attribute.Compound[compounds.size()]);
   170     }
   173     }
   171 
   174 
   172     // This method is part of the javax.lang.model API, do not use this in javac code.
   175     // This method is part of the javax.lang.model API, do not use this in javac code.
       
   176     @DefinedBy(Api.LANGUAGE_MODEL)
   173     public <A extends Annotation> A getAnnotation(Class<A> annoType) {
   177     public <A extends Annotation> A getAnnotation(Class<A> annoType) {
   174 
   178 
   175         if (!annoType.isAnnotation())
   179         if (!annoType.isAnnotation())
   176             throw new IllegalArgumentException("Not an annotation type: " + annoType);
   180             throw new IllegalArgumentException("Not an annotation type: " + annoType);
   177 
   181