當前位置: 首頁>>代碼示例>>Java>>正文


Java AccessibleObject.isAnnotationPresent方法代碼示例

本文整理匯總了Java中java.lang.reflect.AccessibleObject.isAnnotationPresent方法的典型用法代碼示例。如果您正苦於以下問題:Java AccessibleObject.isAnnotationPresent方法的具體用法?Java AccessibleObject.isAnnotationPresent怎麽用?Java AccessibleObject.isAnnotationPresent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.reflect.AccessibleObject的用法示例。


在下文中一共展示了AccessibleObject.isAnnotationPresent方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createDynamicMethod

import java.lang.reflect.AccessibleObject; //導入方法依賴的package包/類
/**
 * Given a reflective method or a constructor, creates a dynamic method that represents it. This method will
 * distinguish between caller sensitive and ordinary methods/constructors, and create appropriate caller sensitive
 * dynamic method when needed.
 * @param m the reflective member
 * @return the single dynamic method representing the reflective member
 */
private static SingleDynamicMethod createDynamicMethod(final AccessibleObject m) {
    if (m.isAnnotationPresent(CallerSensitive.class)) {
        // Method has @CallerSensitive annotation
        return new CallerSensitiveDynamicMethod(m);
    }
    // Method has no @CallerSensitive annotation
    final MethodHandle mh;
    try {
        mh = unreflectSafely(m);
    } catch (final IllegalAccessError e) {
        // java.lang.invoke can in some case conservatively treat as caller sensitive methods that aren't
        // marked with the annotation. In this case, we'll fall back to treating it as caller sensitive.
        return new CallerSensitiveDynamicMethod(m);
    }
    // Proceed with non-caller sensitive
    final Member member = (Member)m;
    return new SimpleDynamicMethod(mh, member.getDeclaringClass(), member.getName(), m instanceof Constructor);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:AbstractJavaLinker.java

示例2: annotatedName

import java.lang.reflect.AccessibleObject; //導入方法依賴的package包/類
private static String annotatedName(AccessibleObject obj) {
  if (obj.isAnnotationPresent(PropertyName.class)) {
    PropertyName annotation = obj.getAnnotation(PropertyName.class);
    return annotation.value();
  }

  return null;
}
 
開發者ID:firebase,項目名稱:firebase-admin-java,代碼行數:9,代碼來源:CustomClassMapper.java

示例3: findAnnotatedMember

import java.lang.reflect.AccessibleObject; //導入方法依賴的package包/類
private static Member findAnnotatedMember(AccessibleObject[] members,
                                          Class<? extends Annotation> annotation) {
    for (AccessibleObject member : members) {
        if (member.isAnnotationPresent(annotation)) {
            return (Member) member;
        }
    }
    return null;
}
 
開發者ID:MikaGuraN,項目名稱:HL4A,代碼行數:10,代碼來源:ScriptableObject.java

示例4: getCascadeTypes

import java.lang.reflect.AccessibleObject; //導入方法依賴的package包/類
private CascadeType[] getCascadeTypes(AccessibleObject accessibleObject) {
    CascadeType[] cascadeTypes = null;
    if(accessibleObject.isAnnotationPresent(OneToMany.class)) {
        cascadeTypes = accessibleObject.getAnnotation(OneToMany.class).cascade();
    }else if(accessibleObject.isAnnotationPresent(ManyToOne.class)) {
        cascadeTypes = accessibleObject.getAnnotation(ManyToOne.class).cascade();
    }else if(accessibleObject.isAnnotationPresent(ManyToMany.class)) {
        cascadeTypes = accessibleObject.getAnnotation(ManyToMany.class).cascade();
    }
    return cascadeTypes;
}
 
開發者ID:chaokunyang,項目名稱:jkes,代碼行數:12,代碼來源:EventSupport.java

示例5: isCallerSensitive

import java.lang.reflect.AccessibleObject; //導入方法依賴的package包/類
private static boolean isCallerSensitive(final AccessibleObject e) {
    return e.isAnnotationPresent(CallerSensitive.class);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:4,代碼來源:JavaAdapterBytecodeGenerator.java


注:本文中的java.lang.reflect.AccessibleObject.isAnnotationPresent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。