O
Owen Jacobson
An open challenge for the newsgroup at large, while I'm thinking about
this:
I'm trying to use JMock to create a mock instance of a generic
interface (EventDispatcher<T>). This is, quite obviously, the eight-
lane-express highway to hell, since generics and mockery do not mix in
any way.
While it's correct,
EventDispatcher<Foo> fooMock = mock (EventDispatcher.class)
generates an unchecked cast warning, which is ugly. Harmless, but
ugly. The challenge is to create a type signature for mock(Class c)
that allows this to succeed without warnings without allowing
nonsensical mocks like
String mockString = mock (CharSequence.class)
..
My initial attempt was this signature, which allows both the former
and the latter:
<C, T extends C> T mock (Class<C> c)
Any thoughts?
-o
this:
I'm trying to use JMock to create a mock instance of a generic
interface (EventDispatcher<T>). This is, quite obviously, the eight-
lane-express highway to hell, since generics and mockery do not mix in
any way.
While it's correct,
EventDispatcher<Foo> fooMock = mock (EventDispatcher.class)
generates an unchecked cast warning, which is ugly. Harmless, but
ugly. The challenge is to create a type signature for mock(Class c)
that allows this to succeed without warnings without allowing
nonsensical mocks like
String mockString = mock (CharSequence.class)
..
My initial attempt was this signature, which allows both the former
and the latter:
<C, T extends C> T mock (Class<C> c)
Any thoughts?
-o