提交 9ff5c485 编写于 作者: J jfranck

8007279: Rename javax.l.model.element.Element.getAnnotations(Class) to getAnnotationsByType(Class)

Reviewed-by: darcy, abuckley
上级 5f2aa967
......@@ -479,7 +479,7 @@ public abstract class Symbol implements Element {
}
// This method is part of the javax.lang.model API, do not use this in javac code.
public <A extends java.lang.annotation.Annotation> A[] getAnnotations(Class<A> annoType) {
public <A extends java.lang.annotation.Annotation> A[] getAnnotationsByType(Class<A> annoType) {
return JavacElements.getAnnotations(this, annoType);
}
......
......@@ -149,12 +149,15 @@ public interface Element {
<A extends Annotation> A getAnnotation(Class<A> annotationType);
/**
* Returns an array of all of this element's annotation for the
* specified type if such annotations are present, else an empty
* array. The annotation may be either inherited or directly
* present on this element. This method will look through a container
* annotation (if present) if the supplied annotation type is
* repeatable.
* Returns annotations that are <em>present</em> on this element.
*
* If there are no annotations <em>present</em> on this element, the return
* value is an array of length 0.
*
* The difference between this method and {@link #getAnnotation(Class)}
* is that this method detects if its argument is a <em>repeatable
* annotation type</em> (JLS 9.6), and if so, attempts to find one or more
* annotations of that type by "looking through" a container annotation.
*
* <p> The annotations returned by this method could contain an element
* whose value is of type {@code Class}.
......@@ -189,14 +192,14 @@ public interface Element {
*
* @see #getAnnotationMirrors()
* @see #getAnnotation(java.lang.Class)
* @see java.lang.reflect.AnnotatedElement#getAnnotations
* @see java.lang.reflect.AnnotatedElement#getAnnotationsByType
* @see EnumConstantNotPresentException
* @see AnnotationTypeMismatchException
* @see IncompleteAnnotationException
* @see MirroredTypeException
* @see MirroredTypesException
*/
<A extends Annotation> A[] getAnnotations(Class<A> annotationType);
<A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType);
/**
* Returns the modifiers of this element, excluding annotations.
......
......@@ -366,7 +366,7 @@ public class ElementRepAnnoTester extends JavacTestingAbstractProcessor {
e.getEnclosingElement().toString())
|| unofficialAnno.contains(
e.getSimpleName().toString())) {
actualAnnosArgs = e.getAnnotations(Foo.class);
actualAnnosArgs = e.getAnnotationsByType(Foo.class);
}
if (singularInheritedAnno.contains(
e.getEnclosingElement().toString())
......@@ -376,25 +376,25 @@ public class ElementRepAnnoTester extends JavacTestingAbstractProcessor {
e.getEnclosingElement().toString())
|| unofficialInheritedAnno.contains(
e.getSimpleName().toString())) {
actualAnnosArgs = e.getAnnotations(FooInherited.class);
actualAnnosArgs = e.getAnnotationsByType(FooInherited.class);
}
if (repeatableAnno.contains(
e.getEnclosingElement().toString())
|| repeatableAnno.contains(
e.getSimpleName().toString())) {
actualAnnosArgs = e.getAnnotations(Bar.class);
actualAnnosArgs = e.getAnnotationsByType(Bar.class);
}
if (repeatableInheritedAnno.contains(
e.getEnclosingElement().toString())
|| repeatableInheritedAnno.contains(
e.getSimpleName().toString())) {
actualAnnosArgs = e.getAnnotations(BarInherited.class);
actualAnnosArgs = e.getAnnotationsByType(BarInherited.class);
}
if (repeatableContainerInheritedAnno.contains(
e.getEnclosingElement().toString())
|| repeatableContainerInheritedAnno.contains(
e.getSimpleName().toString())) {
actualAnnosArgs = e.getAnnotations(BarInheritedContainer.class);
actualAnnosArgs = e.getAnnotationsByType(BarInheritedContainer.class);
}
return actualAnnosArgs;
}
......@@ -406,31 +406,31 @@ public class ElementRepAnnoTester extends JavacTestingAbstractProcessor {
e.getEnclosingElement().toString())
|| repeatableAnnoContainer.contains(
e.getSimpleName().toString())) {
actualAnnosArgs = e.getAnnotations(BarContainer.class);
actualAnnosArgs = e.getAnnotationsByType(BarContainer.class);
}
if (repeatableInheritedAnnoContainer.contains(
e.getEnclosingElement().toString())
|| repeatableInheritedAnnoContainer.contains(
e.getSimpleName().toString())) {
actualAnnosArgs = e.getAnnotations(BarInheritedContainer.class);
actualAnnosArgs = e.getAnnotationsByType(BarInheritedContainer.class);
}
if (repeatableContainerInheritedAnnoContainer.contains(
e.getEnclosingElement().toString())
|| repeatableContainerInheritedAnnoContainer.contains(
e.getSimpleName().toString())) {
actualAnnosArgs = e.getAnnotations(BarInheritedContainerContainer.class);
actualAnnosArgs = e.getAnnotationsByType(BarInheritedContainerContainer.class);
}
if (unofficialAnnoContainer.contains(
e.getEnclosingElement().toString())
|| unofficialAnnoContainer.contains(
e.getSimpleName().toString())) {
actualAnnosArgs = e.getAnnotations(UnofficialContainer.class);
actualAnnosArgs = e.getAnnotationsByType(UnofficialContainer.class);
}
if (unofficialInheritedAnnoContainer.contains(
e.getEnclosingElement().toString())
|| unofficialInheritedAnnoContainer.contains(
e.getSimpleName().toString())) {
actualAnnosArgs = e.getAnnotations(UnofficialInheritedContainer.class);
actualAnnosArgs = e.getAnnotationsByType(UnofficialInheritedContainer.class);
}
return actualAnnosArgs;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册