Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

public boolean Class.isAssignableFrom(Class<?> cls)

807603Oct 31 2007 — edited Oct 31 2007
In my precondition checks on a constructor I want to check that a particular parameter is an instance of a particular class so I use code along the lines of
    public MessageMapper(final Class clazz, final Object object)
    {
        if (!clazz.isAssignableFrom(object.getClass()))
            throw new IllegalArgumentException("'object' must be instanceof 'clazz'");
This works great but this gives me the compilation warning
warning: [unchecked] unchecked call to isAssignableFrom(java.lang.Class<?>) as a member of the raw type java.lang.Class
and since I hate warnings I would like to get rid of it.

I don't see how though. What am I missing?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 28 2007
Added on Oct 31 2007
4 comments
842 views