JavacElements.java 文件源码

java
阅读 39 收藏 0 点赞 0 评论 0

项目:metricgenerator-jdk-compiler 作者:
/**
 * An internal-use utility that creates a reified annotation.
 * This overloaded version take annotation inheritance into account.
 */
public static <A extends Annotation> A getAnnotation(ClassSymbol annotated,
                                                     Class<A> annoType) {
    boolean inherited = annoType.isAnnotationPresent(Inherited.class);
    A result = null;
    while (annotated.name != annotated.name.table.java_lang_Object) {
        result = getAnnotation((Symbol)annotated, annoType);
        if (result != null || !inherited)
            break;
        Type sup = annotated.getSuperclass();
        if (sup.tag != TypeTags.CLASS || sup.isErroneous())
            break;
        annotated = (ClassSymbol) sup.tsym;
    }
    return result;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号