private void validateAnnotationMethods(Method[] memberMethods){
  boolean valid=true;
  for (  Method method : memberMethods) {
    if (method.getModifiers() != (Modifier.PUBLIC | Modifier.ABSTRACT) || method.isDefault() || method.getParameterCount() != 0 || method.getExceptionTypes().length != 0) {
      valid=false;
      break;
    }
    Class<?> returnType=method.getReturnType();
    if (returnType.isArray()) {
      returnType=returnType.getComponentType();
      if (returnType.isArray()) {
        valid=false;
        break;
      }
    }
    if (!((returnType.isPrimitive() && returnType != void.class) || returnType == java.lang.String.class || returnType == java.lang.Class.class || returnType.isEnum() || returnType.isAnnotation())) {
      valid=false;
      break;
    }
    String methodName=method.getName();
    if ((methodName.equals("toString") && returnType == java.lang.String.class) || (methodName.equals("hashCode") && returnType == int.class) || (methodName.equals("annotationType") && returnType == java.lang.Class.class)) {
      valid=false;
      break;
    }
  }
  if (valid)   return;
 else   throw new AnnotationFormatError("Malformed method on an annotation type");
}

private void validateAnnotationMethods ( Method [ ] memberMethods ) { boolean valid = true ; for ( Method method : memberMethods ) { if ( method . getModifiers ( ) != ( Modifier . PUBLIC | Modifier . ABSTRACT ) || method . isDefault ( ) || method . getParameterCount ( ) != 0 || method . getExceptionTypes ( ) . length != 0 ) { valid = false ; break ; } Class < ? > returnType = method . getReturnType ( ) ; if ( returnType . isArray ( ) ) { returnType = returnType . getComponentType ( ) ; if ( returnType . isArray ( ) ) { valid = false ; break ; } } if ( ! ( ( returnType . isPrimitive ( ) && returnType != void . class ) || returnType == java . lang . String . class || returnType == java . lang . Class . class || returnType . isEnum ( ) || returnType . isAnnotation ( ) ) ) { valid = false ; break ; } String methodName = method . getName ( ) ; if ( ( methodName . equals ( "toString" ) && returnType == java . lang . String . class ) || ( methodName . equals ( "hashCode" ) && returnType == int . class ) || ( methodName . equals ( "annotationType" ) && returnType == java . lang . Class . class ) ) { valid = false ; break ; } } if ( valid ) return ; else throw new AnnotationFormatError ( "Malformed method on an annotation type" ) ; }
validates that a method is structurally appropriate for an annotation type . as of java se 8 , annotation types cannot contain static methods and the declared methods of an annotation type must take zero arguments and there are restrictions on the return type .
