EasyMock: How do I create a mock of a genericized class without a warning? [java]


I worked around this problem by introducing a subclass, e.g.

private abstract class MySpecialString implements MySpecial<String>{};

Then create a mock of that abstract class:

MySpecial<String> myMock = createControl().createMock(MySpecialString.class);


The code

private SomeClass<Integer> someClass;
someClass = EasyMock.createMock(SomeClass.class);

gives me a warning "Type safety: The expression of type SomeClass needs unchecked conversion to conform to SomeClass<Integer>".