3
왜 후행 라인이 Java에서 컴파일 오류를 생성합니까? 아니면 어떻게 올바른 제네릭 구문을 쓸 수 있습니까?getAnnotation이 Class <를 허용하지 않는 이유는 무엇입니까? extends Annotation>
Class<? extends Annotation> annotation = annotations[i];
Class<? extends Annotation> anno = javaClass.getAnnotation(annotation);
메소드의 서명은 다음과 같습니다 이클립스에서
public <A extends Annotation> A getAnnotation(Class<A> annotationClass)
컴파일 오류 :
incompatible types
Class<? extends Annotation> anno = javaClass.getAnnotation(annotation);
^
required: Class<? extends Annotation>
found: CAP#1
where CAP#1 is a fresh type-variable:
CAP#1 extends Annotation from capture of ? extends Annotation