@SuppressWarnings("unchecked")
  public static void addAnnotation(Field field, Annotation annotation) {
    field.getAnnotation(Annotation.class);// prevent declaredAnnotations haven't initialized
    Map<Class<? extends Annotation>, Annotation> annos;
    try {
      annos = (Map<Class<? extends Annotation>, Annotation>) Field_Field_DeclaredAnnotations.get(field);
    } catch (IllegalAccessException e) {
      throw new IllegalStateException(e);
    }
    if (annos.getClass() == Collections.EMPTY_MAP.getClass()) {
      annos = new HashMap<>();
      try {
        Field_Field_DeclaredAnnotations.set(field, annos);
      } catch (IllegalAccessException e) {
        throw new IllegalStateException(e);
      }
    }
    annos.put(annotation.annotationType(), annotation);
  }
@ SuppressWarnings ( "unchecked" ) public static void addAnnotation ( Field field , Annotation annotation ) { field . getAnnotation ( Annotation . class ) ; Map < Class < ? extends Annotation > , Annotation > annos ; try { annos = ( Map < Class < ? extends Annotation > , Annotation > ) Field_Field_DeclaredAnnotations . get ( field ) ; } catch ( IllegalAccessException e ) { throw new IllegalStateException ( e ) ; } if ( annos . getClass ( ) == Collections . EMPTY_MAP . getClass ( ) ) { annos = new HashMap < > ( ) ; try { Field_Field_DeclaredAnnotations . set ( field , annos ) ; } catch ( IllegalAccessException e ) { throw new IllegalStateException ( e ) ; } } annos . put ( annotation . annotationType ( ) , annotation ) ; }
Add annotation to Field<br>
Note that you may need to give the root field.

@param field
@param annotation
@author XDean
@see java.lang.reflect.Field
@see #createAnnotationFromMap(Class, Map)
@see ReflectUtil#getRootFields(Class)