private boolean isEnum(Class clazz) { Boolean result = (Boolean) invoke(clazz.getClass(), "isEnum", EMPTY_ARG_TYPES, clazz, EMPTY_ARGS); return result.booleanValue(); }
private boolean isAnnotation(Class clazz) { Boolean result = (Boolean) invoke(clazz.getClass(), "isAnnotation", EMPTY_ARG_TYPES, clazz, EMPTY_ARGS); return result.booleanValue(); }
private void initializeAttributeTypes(Class annotationClass) { Method[] methods = annotationClass.getDeclaredMethods(); for(int i = 0; i < methods.length; i++) { Object defaultValue = invoke(Method.class, "getDefaultValue", EMPTY_ARG_TYPES, methods[i], EMPTY_ARGS); if (defaultValue != null) { // by now we know JDK1.5 API is available so a null means no default value defaultAttrTypes.put(methods[i].getName(), methods[i].getReturnType()); } else { requiredAttrTypes.put(methods[i].getName(), methods[i].getReturnType()); } } }
private void initializeAnnotationMeta(Class annotationClass) { Object[] annotations = (Object[]) invoke(annotationClass.getClass(), "getAnnotations", EMPTY_ARG_TYPES, annotationClass, EMPTY_ARGS); if (annotations == null) { addError("Cannot retrieve annotation meta information. " + ExtendedVerifier.JVM_ERROR_MESSAGE); return; } for(int i = 0; i < annotations.length; i++) { Class annotationType = (Class) invoke(this.annotationRootClass, "annotationType", EMPTY_ARG_TYPES, annotations[i], EMPTY_ARGS); if (annotationType == null) continue; if ("java.lang.annotation.Retention".equals(annotationType.getName())) { initializeRetention(annotationClass, annotationType, annotations[i]); } else if("java.lang.annotation.Target".equals(annotationType.getName())) { initializeTarget(annotationClass, annotationType, annotations[i]); } } }
private void initializeRetention(Class annotationClass, Class retentionClass, Object retentionAnnotation) { Object retentionPolicyEnum = invoke(retentionClass, "value", EMPTY_ARG_TYPES, retentionAnnotation, EMPTY_ARGS); if (retentionPolicyEnum == null) { addError("Cannot read @RetentionPolicy on the @" + annotationClass.getName() + ExtendedVerifier.JVM_ERROR_MESSAGE); return; } if("RUNTIME".equals(retentionPolicyEnum.toString())) { this.annotation.setRuntimeRetention(true); } else if("SOURCE".equals(retentionPolicyEnum.toString())) { this.annotation.setSourceRetention(true); } }
private void initializeTarget(Class annotationClass, Class targetClass, Object targetAnnotation) { Object[] elementTypeEnum = (Object[]) invoke(targetClass, "value", EMPTY_ARG_TYPES, targetAnnotation, EMPTY_ARGS); if (elementTypeEnum == null) { addError("Cannot read @Target on the @" + annotationClass.getName()