How do I remove the warning from a EasyMock.anyObject(List.class) call
Solution 1
It's not possible. I'll call it a generic limitation. Sadly it's not always possible to remove a warning for some perfectly normal usage (like using the class of a generic class).
However, with EasyMock you can do the following:
EasyMock.<List<MyType>> anyObject()
which will do the same thing but without warning. The anyObject you used exist because it's a bit more readable and allows static imports.
Solution 2
Only as suggestion :
interface A extends List<MyType> {};
EasyMock.anyObject(A.class)
Michael Butler
A computer science student at the University of Sherbrooke, Quebec, Canada. I love programming more than anything else. My favorite languages are javascript, scala, C++ and C#.
Updated on July 06, 2022Comments
-
Michael Butler almost 2 years
Compiler can't stop complaining with this call :
EasyMock.anyObject(List.class)
I tried to specify list's type
EasyMock.anyObject(List<MyType>.class)
but it doesn't seems to be an option (anyway, it is stupid since java will erase the type during the compilation)
Is there a clean way (@SuppressWarning is not a clean way IMO) to remove this warning?
Thank you