实现泛型时无法推断类型变量 class

cannot infer type-variable(s) while implementing a generic class

我定义了以下 class:

public class AttributeVisitor extends SimpleAnnotationValueVisitor8<Object, Object> {

    public AttributeVisitor() {
        super();
    }

    public AttributeVisitor(Object defaultValue) {
        super(defaultValue);
    }

    @Override
    public Object visitEnumConstant(VariableElement c, Object attribute) {
        return super.visitEnumConstant(c, attribute);
    }
}

我正在尝试在下面的片段中使用它

for(Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> mirrorValues: annotationMirror.getElementValues().entrySet()){
    mirrorValues.getValue().accept(new AttributeVisitor());
}

编译时出现以下错误:

method accept in interface javax.lang.model.element.AnnotationValue cannot be applied to given types;
[ERROR] required: javax.lang.model.element.AnnotationValueVisitor<R,P>,P
[ERROR] found: com.cvent.analytics.validator.AttributeVisitor
[ERROR] reason: cannot infer type-variable(s) R,P
[ERROR] (actual and formal argument lists differ in length)

知道吗,这里出了什么问题?

The accept method expects two arguments。编译:

mirrorValues.getValue().accept(new AttributeVisitor(), null);

错误:

cannot infer type arguments for `Resource<>`

原因:

cannot infer type-variable(s) T
    (argument mismatch; String cannot be converted to ResponseMessage)
  where T is a type-variable:
    T extends Object declared in class Resource

解决方案:

new ResponseMessage("Message", null, null)) by replacing string message