我正在试图在 List<MyType>
上调用 EasyMock.isA(Class<T>)
。有没有一种方法可以不出现警告的情况下完成它?
我尝试了以下方法:
isA(List<MyType>.class); // doesn't compile
isA(List.<MyType>class); // syntax error on tokens (MyType), misplaced construct
isA(List.class); // This gives a warning: Type safety: The expression of type List needs unchecked conversion to conform to List<MyType>
编辑:
Jakub HR给出了正确的答案。然而,对于我的特定情况,我需要这个功能用于EasyMock,我可以简单地使用
EasyMock.<List<MyType>>anyObject()
Class <?>
对象(必须手动提供))。 - Display Name