以下是我的设置
public interface Test<T extends MyInterface>
{
someMethod(T... a)
}
public class TestImpl implements Test<MyInterfaceImpl>
{
someMethod(MyInterfaceImpl... a)
}
public class MyInterfaceImpl implements MyInterface {}
public someClass { @Autowired TestFactory testfactory
......
// getting an error -- Type mismatch Can't assign non-array value to an array
testfactory.getTest(Type type).someMethod(new MyInterfaceImpl())
}
public class TestFactoryImpl implements TestFactory { Test getTest(Type type) { return registry.get(type)}}
Run Code Online (Sandbox Code Playgroud)
反过来又导致java.lang.ClassCastException:[Lcom.test.MyInterface; 无法转换为[Lcom.test.Impl.MyInterfaceImpl;
但下面的工作
testfactory.getTest(Type type).someMethod(new MyInterfaceImpl[]{new MyInterfaceImpl()})
Run Code Online (Sandbox Code Playgroud)
不确定发生了什么.请帮忙