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?!!

Leave a Reply

Your email address will not be published.

Notify me of followup comments via e-mail. You can also subscribe without commenting.

This site uses Akismet to reduce spam. Learn how your comment data is processed.