# Thursday, July 10, 2008

Overriding a method with a raw type, want to use generics in the override

I want to override that api.org.hibernate.Interceptor#postFlush(java.util.Iterator)
I want to do it like that:
@Override
public void postFlush( Iterator<?> entities ) throws CallbackException {...}
Does not work - the method is not with the same signature ?!

Then:
@Override
public void postFlush( Iterator<Object> entities ) throws CallbackException {...}
Does not work - the method is not with the same signature ?! WTF?

The only thing that does work (without a silly warning) is that:
@Override
public void postFlush( @SuppressWarnings( "unchecked" ) Iterator entities ) throws CallbackException {


Why?!!
OpenID
Please login with either your OpenID above, or your details below.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, blockquote@cite, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview