ReflectionUtils { public static boolean hasSuperClass(Class<?> classA, Class<?> classB) { if (classA.equals(classB)) return true; boolean superclass = false; Class<?> superClass = classA.getSuperclass(); if (superClass != null) { if (superClass.equals(classB)) superclass = true; else superclass = hasSuperClass(superClass, classB); } if (!superclass) { Class<?>[] interfaces = classA.getInterfaces(); for (Class<?> interfaze : interfaces) { if (interfaze.equals(classB)) return true; else { return hasSuperClass(interfaze, classB); } } } return superclass; }  static boolean hasSuperClass(Class<?> classA, Class<?> classB);  }
@Test public void testHasSuperClass() { assertTrue(ReflectionUtils.hasSuperClass(URI.class, Object.class)); assertFalse(ReflectionUtils.hasSuperClass(Object.class, URI.class)); assertTrue(ReflectionUtils.hasSuperClass(Object.class, Object.class)); assertTrue(ReflectionUtils.hasSuperClass(URI.class, URI.class)); assertTrue(ReflectionUtils.hasSuperClass(BufferedReader.class, Reader.class)); assertFalse(ReflectionUtils.hasSuperClass(Reader.class, BufferedReader.class)); assertTrue(ReflectionUtils.hasSuperClass(BufferedReader.class, Readable.class)); assertTrue(ReflectionUtils.hasSuperClass(Reader.class, Readable.class)); assertFalse(ReflectionUtils.hasSuperClass(URI.class, Readable.class)); assertFalse(ReflectionUtils.hasSuperClass(URI.class, Serializable.class)); assertTrue(ReflectionUtils.hasSuperClass(URI.class, Comparable.class)); }