Wrong "uncheched cast" inspection

if (entity instanceof BasebObj)
((BasebObj) entity).setDeleted(true);

this code provide "uncheched cast" inspection


Hello Andrew,

AD> if (entity instanceof BasebObj)
AD> {
AD> ((BasebObj) entity).setDeleted(true);
AD> }
AD> this code provide "uncheched cast" inspection

This is not wrong if BasebObj is a generic class. javac reports it as well.

Dmitry Jemerov
Software Developer
"Develop with Pleasure!"


no BasebObj is not generic class. :(

Class hierarchy Object -> NewBObj -> BasebObj -> .....
and fragment of code:

public boolean restore(Class]]> entityClass, Long id) throws Exception
T entity = getEntityManager().find(entityClass, id);
if (entity == null) return false;
if (entity instanceof BasebObj)
((BasebObj) entity).setDeleted(null); //inspection here!!!
return true;

I try to compile code and javac didn't report any warning


Please sign in to leave a comment.