Java Reflection Annotation getAnnotations(final Class clazz, final String fieldName)

Here you can find the source of getAnnotations(final Class clazz, final String fieldName)

Description

get Annotations

License

Apache License

Declaration

public static Annotation[] getAnnotations(final Class<?> clazz, final String fieldName) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;

public class Main {
    public static Annotation[] getAnnotations(final Class<?> clazz, final String fieldName) {
        try {/*from   www . j  a  va2s. com*/
            Field field = clazz.getDeclaredField(fieldName);
            field.setAccessible(true);
            return field.getAnnotations();
        } catch (ReflectiveOperationException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. getAnnotations(Class ann, Object o, Method m, int param)
  2. getAnnotations(Enum targetEnum, Class targetAnnotationClass)
  3. getAnnotations(Field field)
  4. getAnnotations(final Class c, final Class annClass)
  5. getAnnotations(final Class clazz, final Class annotation)
  6. getAnnotations(Method method)
  7. getAnnotations(Method method)
  8. getAnnotations(Method method)
  9. getAnnotations(Method method)