<p>I need to determine if a Class object representing an interface extends another interface, ie:</p>

<pre><code> package a.b.c.d;
    public Interface IMyInterface extends a.b.d.c.ISomeOtherInterface{
    }
</code></pre>

<p>according to <a href="http://web.archive.org/web/20100705124350/http://java.sun.com:80/j2se/1.4.2/docs/api/java/lang/Class.html" rel="nofollow noreferrer">the spec</a> Class.getSuperClass() will return null for an Interface.  </p>

<blockquote>
  <p>If this Class represents either the
  Object class, an interface, a
  primitive type, or void, then null is
  returned.</p>
</blockquote>

<p>Therefore the following won't work.</p>

<pre><code>Class interface = Class.ForName("a.b.c.d.IMyInterface")
Class extendedInterface = interface.getSuperClass();
if(extendedInterface.getName().equals("a.b.d.c.ISomeOtherInterface")){
    //do whatever here
}
</code></pre>

<p>any ideas?</p>

Use Class.getInterfaces such as:
```
```
Class<?> c; // Your class
for(Class<?> i : c.getInterfaces()) {
     // test if i is your interface
}
```
```
Also the following code might be of help, it will give you a set with all super-classes and interfaces of a certain class:
```
```
public static Set<Class<?>> getInheritance(Class<?> in)
{
    LinkedHashSet<Class<?>> result = new LinkedHashSet<Class<?>>();

    result.add(in);
    getInheritance(in, result);

    return result;
}

/**
 * Get inheritance of type.
 * 
 * @param in
 * @param result
 */
private static void getInheritance(Class<?> in, Set<Class<?>> result)
{
    Class<?> superclass = getSuperclass(in);

    if(superclass != null)
    {
        result.add(superclass);
        getInheritance(superclass, result);
    }

    getInterfaceInheritance(in, result);
}

/**
 * Get interfaces that the type inherits from.
 * 
 * @param in
 * @param result
 */
private static void getInterfaceInheritance(Class<?> in, Set<Class<?>> result)
{
    for(Class<?> c : in.getInterfaces())
    {
        result.add(c);

        getInterfaceInheritance(c, result);
    }
}

/**
 * Get superclass of class.
 * 
 * @param in
 * @return
 */
private static Class<?> getSuperclass(Class<?> in)
{
    if(in == null)
    {
        return null;
    }

    if(in.isArray() && in != Object[].class)
    {
        Class<?> type = in.getComponentType();

        while(type.isArray())
        {
            type = type.getComponentType();
        }

        return type;
    }

    return in.getSuperclass();
}
```
```
Edit: Added some code to get all super-classes and interfaces of a certain class.