I'm trying to implement a generic java interface in scala. I have looked at: How do I extend Java interface containing generic methods in Scala? And Scala: Overriding Generic Java Methods II
But still I could not find an answer. Here's the method signature from Spring web:
T read(Class<? extends T> clazz, HttpInputMessage inputMessage)
throws IOException, HttpMessageNotReadableException;
I tried the following in scala:
@throws(classOf[IOException])
@throws(classOf[HttpMessageNotReadableException])
override def read[T](clazz : Class[_ <: T], inputMessage : HttpInputMessage) : T ={
}
But I get an error saying that this method overrides nothing. If I erase the type by doing:
override def read(clazz : Class[_], inputMessage : HttpInputMessage) : AnyRef ={
It marks the method as being overwritten. My question is how can I keep type safety here and force it to override the interface method?
Regards
EDIT
The spring interface:
public interface HttpMessageConverter<T> {
T read(Class<? extends T> clazz,
HttpInputMessage inputMessage)
throws IOException,
HttpMessageNotReadableException
}