Java Code Examples for java.lang.annotation.Target

The following examples show how to use java.lang.annotation.Target. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public Advice.OffsetMapping make(ParameterDescription.InDefinedShape target,
                                 AnnotationDescription.Loadable<SimpleMethodSignature> annotation,
                                 AdviceType adviceType) {
    return new Advice.OffsetMapping() {
        @Override
        public Target resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner,
                              Advice.ArgumentHandler argumentHandler, Sort sort) {
            final String className = instrumentedMethod.getDeclaringType().getTypeName();
            String simpleClassName = className.substring(className.lastIndexOf('$') + 1);
            simpleClassName = simpleClassName.substring(simpleClassName.lastIndexOf('.') + 1);
            final String signature = String.format("%s#%s", simpleClassName, instrumentedMethod.getName());
            return Target.ForStackManipulation.of(signature);
        }
    };
}
 
Example 2
Source Project: learnjavabug   Source File: SerializeMapForTransformer.java    License: MIT License 6 votes vote down vote up
private static void testStaticClassInitForDefineClass() throws Exception {
  Transformer[] transformers = new Transformer[]{
      new ConstantTransformer(DefiningClassLoader.class),
      new InvokerTransformer("getConstructor", new Class[]{Class[].class},
          new Object[]{new Class[0]}),
      new InvokerTransformer("newInstance", new Class[]{Object[].class},
          new Object[]{new Object[0]}),
      new InvokerTransformer("defineClass", new Class[]{String.class, byte[].class},
          new Object[]{"com.threedr3am.bug.collections.v3.no2.CallbackRuntime2",
              FileToByteArrayUtil.readCallbackRuntimeClassBytes(
                  "com/threedr3am/bug/collections/v3/no2/CallbackRuntime2.class")}),
      new InvokerTransformer("newInstance", new Class[]{}, new Object[]{})
  };
  Transformer transformer = new ChainedTransformer(transformers);
  Map inner = new HashMap();
  inner.put("value", "value");
  Map ouputMap = TransformedMap.decorate(inner, null, transformer);
  Constructor<?> ctor = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler")
      .getDeclaredConstructor(Class.class, Map.class);
  ctor.setAccessible(true);
  Object o = ctor.newInstance(Target.class, ouputMap);
  //序列化输出
  byte[] bytes = SerializeUtil.serialize(o);
  //反序列化
  SerializeUtil.deserialize(bytes);
}
 
Example 3
private static Set<Annotation> getAllMetaAnnotations(Annotation annotation) {

        Annotation[] metaAnnotations = annotation.annotationType().getAnnotations();

        if (ObjectUtils.isEmpty(metaAnnotations)) { // 没有找到,返回空集合
            return Collections.emptySet();
        }
        // 获取所有非 Java 标准元注解结合
        Set<Annotation> metaAnnotationsSet = Stream.of(metaAnnotations)
                // 排除 Java 标准注解,如 @Target,@Documented 等,它们因相互依赖,将导致递归不断
                // 通过 java.lang.annotation 包名排除
                .filter(metaAnnotation -> !Target.class.getPackage().equals(metaAnnotation.annotationType().getPackage()))
                .collect(Collectors.toSet());

        // 递归查找元注解的元注解集合
        Set<Annotation> metaMetaAnnotationsSet = metaAnnotationsSet.stream()
                .map(TransactionalServiceAnnotationReflectionBootstrap::getAllMetaAnnotations)
                .collect(HashSet::new, Set::addAll, Set::addAll);

        // 添加递归结果
        metaMetaAnnotationsSet.add(annotation);
        return metaMetaAnnotationsSet;
    }
 
Example 4
Source Project: lams   Source File: AnnotatedClassResolver.java    License: GNU General Public License v2.0 6 votes vote down vote up
private AnnotationCollector _addFromBundleIfNotPresent(AnnotationCollector c,
        Annotation bundle)
{
    for (Annotation ann : ClassUtil.findClassAnnotations(bundle.annotationType())) {
        // minor optimization: by-pass 2 common JDK meta-annotations
        if ((ann instanceof Target) || (ann instanceof Retention)) {
            continue;
        }
        if (!c.isPresent(ann)) {
            c = c.addOrOverride(ann);
            if (_intr.isAnnotationBundle(ann)) {
                c = _addFromBundleIfNotPresent(c, ann);
            }
        }
    }
    return c;
}
 
Example 5
Source Project: openjdk-jdk9   Source File: Utils.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns true if the {@code annotationDoc} is to be treated
 * as a declaration annotation, when targeting the
 * {@code elemType} element type.
 *
 * @param annotationDoc the annotationDoc to check
 * @param elemType  the targeted elemType
 * @return true if annotationDoc is a declaration annotation
 */
public boolean isDeclarationAnnotation(AnnotationTypeDoc annotationDoc,
        boolean isJava5DeclarationLocation) {
    if (!isJava5DeclarationLocation)
        return false;
    AnnotationDesc[] annotationDescList = annotationDoc.annotations();
    // Annotations with no target are treated as declaration as well
    if (annotationDescList.length==0)
        return true;
    for (AnnotationDesc anno : annotationDescList) {
        if (anno.annotationType().qualifiedName().equals(
                Target.class.getName())) {
            if (isDeclarationTarget(anno))
                return true;
        }
    }
    return false;
}
 
Example 6
Source Project: xtext-extras   Source File: XAnnotationUtil.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public Set<ElementType> getAnnotationTargets(JvmAnnotationType annotation) {
	EList<JvmAnnotationReference> annotations = annotation.getAnnotations();
	for (JvmAnnotationReference annoRef : annotations) {
		if (Target.class.getName().equals(annoRef.getAnnotation().getIdentifier())) {
			EList<JvmAnnotationValue> values = annoRef.getValues();
			JvmAnnotationValue value = values.isEmpty() ? null : values.get(0);
			if (value instanceof JvmEnumAnnotationValue) {
				Set<ElementType> result = newHashSet();
				for (JvmEnumerationLiteral elementType : ((JvmEnumAnnotationValue) value).getValues()) {
					final String simpleName = elementType.getSimpleName();
					result.add(ElementType.valueOf(simpleName));
				}
				return result;
			}
		}
	}
	return emptySet();
}
 
Example 7
Source Project: classpy   Source File: AnnotatedClass.java    License: MIT License 6 votes vote down vote up
@MyRuntimeAnnotation(
    intValue = 456,
    strValue = "test",
    enumValue = ElementType.METHOD,
    classValue = String.class,
    annotationValue = @Target({ElementType.METHOD}),
    arrayValue = {"X", "Y", "Z"}
)
@MyClassAnnotation(
    intValue = 456,
    strValue = "test",
    enumValue = ElementType.METHOD,
    classValue = String.class,
    annotationValue = @Target({}),
    arrayValue = {"X", "Y", "Z"}
)
public void testMethodAnnotations() {
    
}
 
Example 8
Source Project: classpy   Source File: AnnotatedClass.java    License: MIT License 6 votes vote down vote up
public void testParameterAnnotations(
    @MyRuntimeAnnotation(
        intValue = 456,
        strValue = "test",
        enumValue = ElementType.METHOD,
        classValue = String.class,
        annotationValue = @Target({ElementType.METHOD}),
        arrayValue = {"X", "Y", "Z"}
    )
    @MyClassAnnotation(
        intValue = 456,
        strValue = "test",
        enumValue = ElementType.METHOD,
        classValue = String.class,
        annotationValue = @Target({}),
        arrayValue = {"X", "Y", "Z"}
    )   
    int param1
) {
    // ...
}
 
Example 9
Source Project: immutables   Source File: Annotations.java    License: Apache License 2.0 6 votes vote down vote up
static boolean annotationMatchesTarget(Element annotationElement, ElementType elementType) {
  @Nullable Target target = annotationElement.getAnnotation(Target.class);
  if (target != null) {
    ElementType[] targetTypes = target.value();
    if (targetTypes.length == 0) {
      return false;
    }
    boolean found = false;
    for (ElementType t : targetTypes) {
      if (t == elementType) {
        found = true;
      }
    }
    if (!found) {
      return false;
    }
  }
  return true;
}
 
Example 10
Source Project: spring-fabric-gateway   Source File: AnnotationUtils.java    License: MIT License 5 votes vote down vote up
public static <A extends Annotation> AnnotatedElement getAnnotatedElement(Class<?> clazz, Class<A> annotationType) {
	if (clazz == null || annotationType == null) {
		return null;
	}
	Target target = annotationType.getAnnotation(Target.class);
	if (target == null) {
		return null;
	}
	AnnotatedElement element = null;
	ElementType[] value = target.value();
	for (ElementType elementType : value) {

		switch (elementType) {
		case FIELD:
			element = getField(clazz, annotationType);
			break;
		case METHOD:
			element = getMethod(clazz, annotationType);
			break;
		case TYPE:
			element = getType(clazz, annotationType);
			break;
		default:
			break;
		}
		if (element != null) {
			break;
		}
	}
	return element;
}
 
Example 11
@Override
public Advice.OffsetMapping make(final ParameterDescription.InDefinedShape target,
                                 final AnnotationDescription.Loadable<AnnotationValueExtractor> annotation,
                                 final AdviceType adviceType) {
    return new Advice.OffsetMapping() {
        @Override
        public Target resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Advice.ArgumentHandler argumentHandler, Sort sort) {
            return Target.ForStackManipulation.of(getAnnotationValue(instrumentedMethod, annotation.load()));
        }
    };
}
 
Example 12
Source Project: apm-agent-java   Source File: JaxRsOffsetMappingFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Advice.OffsetMapping make(ParameterDescription.InDefinedShape target, AnnotationDescription.Loadable<JaxRsPath> annotation, AdviceType adviceType) {
    return new Advice.OffsetMapping() {
        @Override
        public Target resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Advice.ArgumentHandler argumentHandler, Sort sort) {
            Object value = null;
            if (useAnnotationValueForTransactionName) {
                value = getTransactionAnnotationValueFromAnnotations(instrumentedMethod, instrumentedType);
            }
            return Target.ForStackManipulation.of(value);
        }
    };
}
 
Example 13
Source Project: learnjavabug   Source File: SerializeMapForTransformer.java    License: MIT License 5 votes vote down vote up
private static void testAnnotationInvocationHandlerForDefineClass() throws Exception {
  Transformer[] transformers = new Transformer[]{
      new ConstantTransformer(DefiningClassLoader.class),
      new InvokerTransformer("getConstructor", new Class[]{Class[].class},
          new Object[]{new Class[0]}),
      new InvokerTransformer("newInstance", new Class[]{Object[].class},
          new Object[]{new Object[0]}),
      new InvokerTransformer("defineClass", new Class[]{String.class, byte[].class},
          new Object[]{"com.threedr3am.bug.collections.v3.no2.CallbackRuntime",
              FileToByteArrayUtil.readCallbackRuntimeClassBytes(
                  "com/threedr3am/bug/collections/v3/no2/CallbackRuntime.class")}),
      new InvokerTransformer("newInstance", new Class[]{}, new Object[]{}),
      new InvokerTransformer("exec", new Class[]{String.class},
          new Object[]{"/Applications/Calculator.app/Contents/MacOS/Calculator"})
  };
  Transformer transformer = new ChainedTransformer(transformers);
  Map inner = new HashMap();
  inner.put("value", "value");
  Map ouputMap = TransformedMap.decorate(inner, null, transformer);
  Constructor<?> ctor = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler")
      .getDeclaredConstructor(Class.class, Map.class);
  ctor.setAccessible(true);
  Object o = ctor.newInstance(Target.class, ouputMap);
  //序列化输出
  byte[] bytes = SerializeUtil.serialize(o);
  //反序列化
  SerializeUtil.deserialize(bytes);
}
 
Example 14
Source Project: learnjavabug   Source File: SerializeMapForTransformer.java    License: MIT License 5 votes vote down vote up
/**
 * 测试AnnotationInvocationHandler反序列化中,直接触发Transformer
 *
 */
private static void testAnnotationInvocationHandlerMap(Transformer transformer) throws Exception{
    //转化map
    Map innerMap = new HashMap();
    innerMap.put("value","2");
    Map ouputMap = TransformedMap.decorate(innerMap,null,transformer);
    //jdk1.8该类的方法readObject()是使用了native方法安全更新map,无法再触发
    Constructor<?> ctor = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler").getDeclaredConstructor(Class.class,Map.class);
    ctor.setAccessible(true);
    InvocationHandler o = (InvocationHandler) ctor.newInstance(Target.class,ouputMap);
    //序列化输出
    byte[] bytes = SerializeUtil.serialize(o);
    //反序列化
    SerializeUtil.deserialize(bytes);
}
 
Example 15
Source Project: netbeans   Source File: TargetAnalyzer.java    License: Apache License 2.0 5 votes vote down vote up
public boolean hasTarget() {
    Map<String, ? extends AnnotationMirror> types = getHelper()
            .getAnnotationsByType(getElement().getAnnotationMirrors());
    AnnotationMirror target = types.get(Target.class.getCanonicalName());
    if (target == null) {
        handleNoTarget();
    }
    return hasReqiredTarget( target , getDeclaredTargetTypes( getHelper(), 
            target ));
}
 
Example 16
Source Project: netbeans   Source File: TargetAnalyzer.java    License: Apache License 2.0 5 votes vote down vote up
public Set<ElementType> getDeclaredTargetTypes() {
    Map<String, ? extends AnnotationMirror> types = getHelper()
            .getAnnotationsByType(getElement().getAnnotationMirrors());
    AnnotationMirror target = types.get(Target.class.getCanonicalName());
    if (target == null) {
        return Collections.emptySet();
    }
    return getDeclaredTargetTypes( getHelper(), target );
}
 
Example 17
Source Project: netbeans   Source File: TargetAnalyzer.java    License: Apache License 2.0 5 votes vote down vote up
public static Set<ElementType> getDeclaredTargetTypes( 
        AnnotationHelper helper, TypeElement element ) 
{
    Map<String, ? extends AnnotationMirror> types = helper
            .getAnnotationsByType(element.getAnnotationMirrors());
    AnnotationMirror target = types.get(Target.class.getCanonicalName());
    if (target == null) {
        return Collections.emptySet();
    }
    return getDeclaredTargetTypes( helper, target );
}
 
Example 18
Source Project: epoxy   Source File: BaseModelAttributeInfo.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Keeps track of annotations on the attribute so that they can be used in the generated setter
 * and getter method. Setter and getter annotations are stored separately since the annotation may
 * not target both method and parameter types.
 */
private void buildAnnotationLists(List<? extends AnnotationMirror> annotationMirrors) {
  for (AnnotationMirror annotationMirror : annotationMirrors) {
    if (!annotationMirror.getElementValues().isEmpty()) {
      // Not supporting annotations with values for now
      continue;
    }

    ClassName annotationClass =
        ClassName.bestGuess(annotationMirror.getAnnotationType().toString());
    if (annotationClass.equals(ClassName.get(EpoxyAttribute.class))) {
      // Don't include our own annotation
      continue;
    }

    DeclaredType annotationType = annotationMirror.getAnnotationType();
    // A target may exist on an annotation type to specify where the annotation can
    // be used, for example fields, methods, or parameters.
    Target targetAnnotation = annotationType.asElement().getAnnotation(Target.class);

    // Allow all target types if no target was specified on the annotation
    List<ElementType> elementTypes =
        Arrays.asList(targetAnnotation == null ? ElementType.values() : targetAnnotation.value());

    AnnotationSpec annotationSpec = AnnotationSpec.builder(annotationClass).build();
    if (elementTypes.contains(ElementType.PARAMETER)) {
      getSetterAnnotations().add(annotationSpec);
    }

    if (elementTypes.contains(ElementType.METHOD)) {
      getGetterAnnotations().add(annotationSpec);
    }
  }
}
 
Example 19
private static IAnnotationBinding findTargetAnnotation(IAnnotationBinding[] metaAnnotations) {
	for (int i= 0; i < metaAnnotations.length; i++) {
		IAnnotationBinding binding= metaAnnotations[i];
		ITypeBinding annotationType= binding.getAnnotationType();
		if (annotationType != null && annotationType.getQualifiedName().equals(Target.class.getName())) {
			return binding;
		}
	}
	return null;
}
 
Example 20
public SqliteMagicImplicitUsageProvider() {
  for (Class<? extends Annotation> annotation : ANNOTATIONS) {
    final EnumSet<ElementType> elementTypes = EnumSet.copyOf(Arrays.asList(annotation.getAnnotation(Target.class).value()));
    if (elementTypes.contains(ElementType.FIELD)) {
      FIELD_ANNOTATIONS.add(annotation.getName());
    }
    if (elementTypes.contains(ElementType.METHOD) || elementTypes.contains(ElementType.CONSTRUCTOR)) {
      METHOD_ANNOTATIONS.add(annotation.getName());
    }
    if (elementTypes.contains(ElementType.TYPE)) {
      CLASS_ANNOTATIONS.add(annotation.getName());
    }
  }
}
 
Example 21
Source Project: anno4j   Source File: RDFProperty.java    License: Apache License 2.0 5 votes vote down vote up
private void annotationHeader(JavaMessageBuilder builder)
		throws ObjectStoreConfigException {
	String pkg = builder.getPackageName(this.getURI());
	String simple = builder.getSimpleName(this.getURI());
	if (pkg == null) {
		builder.imports(simple);
	} else {
		builder.pkg(pkg);
		builder.imports(pkg + '.' + simple);
	}
	builder.comment(this);
	if (this.isA(OWL.DEPRECATEDPROPERTY)) {
		builder.annotate(Deprecated.class);
	}
	builder.annotateEnum(Retention.class, "value", RetentionPolicy.class, "RUNTIME");
	builder.annotateEnums(Target.class, "value", ElementType.class, "TYPE", "METHOD",
				"PARAMETER", "ANNOTATION_TYPE", "PACKAGE");
	builder.annotationName(simple);
	builder.annotationProperties(this);
	builder.annotateURI(Iri.class, "value", builder.getType(this.getURI()));
	if (this.isA(OWL.FUNCTIONALPROPERTY)) {
		builder.method("value", true).returnType(builder.imports(String.class)).end();
	} else {
		builder.method("value", true).returnType(builder.imports(String.class) + "[]")
				.end();
	}
}
 
Example 22
Source Project: annotation-tools   Source File: IndexFileWriter.java    License: MIT License 5 votes vote down vote up
private Collection<Annotation> requiredMetaannotations(
        Collection<Annotation> annos) {
    Set<Annotation> results = new HashSet<>();
    for (Annotation a : annos) {
        String aName = a.def.name;
        if (aName.equals(Retention.class.getCanonicalName())
            || aName.equals(Target.class.getCanonicalName())) {
            results.add(a);
        }
    }
    return results;
}
 
Example 23
Source Project: jfixture   Source File: TestFromListOf.java    License: MIT License 5 votes vote down vote up
@Test
public void Annotation_can_only_be_applied_to_fields() {
    Target target = FromListOf.class.getAnnotation(Target.class);
    assertEquals(1, target.value().length);
    ElementType type = target.value()[0];
    assertEquals(ElementType.FIELD, type);
}
 
Example 24
Source Project: jfixture   Source File: TestRange.java    License: MIT License 5 votes vote down vote up
@Test
public void Annotation_can_only_be_applied_to_fields() {
    Target target = Range.class.getAnnotation(Target.class);
    assertEquals(1, target.value().length);
    ElementType type = target.value()[0];
    assertEquals(ElementType.FIELD, type);
}
 
Example 25
Source Project: jfixture   Source File: TestFixture.java    License: MIT License 5 votes vote down vote up
@Test
public void Annotation_can_only_be_applied_to_fields() {
    Target target = Fixture.class.getAnnotation(Target.class);
    assertEquals(1, target.value().length);
    ElementType type = target.value()[0];
    assertEquals(ElementType.FIELD, type);
}
 
Example 26
Source Project: ldp4j   Source File: MetaAnnotationHelper.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean validTarget(Class<? extends Annotation> type) {
	final Target target = type.getAnnotation(Target.class);

	if(target==null) {
		return false;
	}

	final ElementType[] targets=target.value();

	return 
		targets.length == 1 && 
		targets[0] == ElementType.ANNOTATION_TYPE;
}
 
Example 27
Source Project: cxf   Source File: JAXBUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static boolean isJAXB22() {
    Target t = XmlElement.class.getAnnotation(Target.class);
    //JAXB 2.2 allows XmlElement on params.
    for (ElementType et : t.value()) {
        if (et == ElementType.PARAMETER) {
            return true;
        }
    }
    return false;
}
 
Example 28
Source Project: auto   Source File: PropertyAnnotationsTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Tests that when CopyAnnotationsToGeneratedField is present on a method, all non-inherited
 * annotations (except those appearing in CopyAnnotationsToGeneratedField.exclude) are copied to
 * the method implementation in the generated class.
 */
@Test
public void testCopyingMethodAnnotationsToGeneratedFields() {
  JavaFileObject inputFile =
      new InputFileBuilder()
          .setImports(getImports(PropertyAnnotationsTest.class, Target.class, ElementType.class))
          .addAnnotations(
              "@AutoValue.CopyAnnotations(exclude={PropertyAnnotationsTest."
                  + "TestAnnotation.class})",
              "@Deprecated",
              "@PropertyAnnotationsTest.TestAnnotation",
              "@PropertyAnnotationsTest.InheritedAnnotation",
              "@MethodsOnly")
          .addInnerTypes("@Target(ElementType.METHOD) @interface MethodsOnly {}")
          .build();

  JavaFileObject outputFile =
      new OutputFileBuilder()
          .setImports(getImports(PropertyAnnotationsTest.class))
          .addFieldAnnotations("@Deprecated", "@PropertyAnnotationsTest.InheritedAnnotation")
          .addMethodAnnotations(
              "@Deprecated",
              "@PropertyAnnotationsTest.InheritedAnnotation",
              "@Baz.MethodsOnly")
          .build();

  assertAbout(javaSource())
      .that(inputFile)
      .processedWith(new AutoValueProcessor())
      .compilesWithoutError()
      .and()
      .generatesSources(outputFile);
}
 
Example 29
Source Project: aircon   Source File: NonFieldTargetDetector.java    License: MIT License 4 votes vote down vote up
private boolean isTargetAnnotation(final UAnnotation annotation) {
	return ElementUtils.isOfType(annotation.getJavaPsi(), Target.class);
}
 
Example 30
Source Project: simple-robot-core   Source File: AnnotationUtils.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 从某个类上获取注解对象,注解可以深度递归
 * 如果存在多个继承注解,则优先获取浅层第一个注解,如果浅层不存在,则返回第一个获取到的注解
 * 请尽可能保证仅存在一个或者一种继承注解,否则获取到的类型将不可控
 *
 * @param from           获取注解的某个类
 * @param annotationType 想要获取的注解类型
 * @param ignored        获取注解列表的时候的忽略列表
 * @return 获取到的第一个注解对象
 */
public static <T extends Annotation> T getAnnotation(AnnotatedElement from, Class<T> annotationType, Class<T>... ignored) {
    // 首先尝试获取缓存
    T cache = getCache(from, annotationType);
    if(cache != null){
        return cache;
    }

    if(isNull(from, annotationType)){
        return null;
    }


    //先尝试直接获取
    T annotation = from.getAnnotation(annotationType);

    //如果存在直接返回,否则查询
    if (annotation != null) {
        saveCache(from, annotation);
        return annotation;
    }

    // 获取target注解
    Target target = annotationType.getAnnotation(Target.class);
    // 判断这个注解能否标注在其他注解上,如果不能,则不再深入获取
    boolean annotationable = false;
    if (target != null) {
        for (ElementType elType : target.value()) {
            if (elType == ElementType.TYPE || elType == ElementType.ANNOTATION_TYPE) {
                annotationable = true;
                break;
            }
        }
    }

    Annotation[] annotations = from.getAnnotations();
    annotation = annotationable ? getAnnotationFromArrays(annotations, annotationType, ignored) : null;


    // 如果还是获取不到,看看查询的注解类型有没有对应的ByNameType
    if (annotation == null) {
        annotation = getByNameAnnotation(from, annotationType);
    }

    // 如果无法通过注解本身所指向的byName注解获取,看看有没有反向指向此类型的注解
    // 此情况下不进行深层获取
    if(annotation == null){
        annotation = getAnnotationFromByNames(annotations, annotationType);
    }

    // 如果最终不是null,计入缓存
    if(annotation != null){
        saveCache(from, annotation);
    }else{
        nullCache(from, annotationType);
    }

    return annotation;
}