import java.lang.reflect.AnnotatedParameterizedType; 
import java.lang.reflect.AnnotatedType; 
import java.lang.reflect.Field; 
import java.util.List; 

public class AnnotationNotFoundTest { 

    private final List<InnerClass<@MyAnnotation String>> listOfGenericInnerType = null; 
    private final List<ExternalClass<@MyAnnotation String>> listOfGenericExternalType = null; 

    public static void main(String[] args) throws Exception { 
        checkAnnotationIsPresent( "listOfGenericExternalType" ); 
        checkAnnotationIsPresent( "listOfGenericInnerType" ); 
    } 

    private static void checkAnnotationIsPresent(String fieldName) throws Exception { 
        Field field = AnnotationNotFoundTest.class.getDeclaredField( fieldName ); 
        AnnotatedParameterizedType fieldType = (AnnotatedParameterizedType) field.getAnnotatedType(); 

        AnnotatedParameterizedType listElementType = (AnnotatedParameterizedType) fieldType.getAnnotatedActualTypeArguments()[0]; 
        AnnotatedType[] elementTypeTypeArguments = listElementType.getAnnotatedActualTypeArguments(); 

        if ( elementTypeTypeArguments[0].isAnnotationPresent( MyAnnotation.class ) ) { 
            System.out.println( "Success: annotation found for " + fieldName ); 
        } 
        else { 
            System.out.println( "ERROR: annotation not found for " + fieldName ); 
        } 
    } 

    private static class InnerClass<T> { 
    } 
} 