Here you can find the source of instanceOf(Class clazz, Class target)
public static boolean instanceOf(Class clazz, Class target)
//package com.java2s; //License from project: Open Source License public class Main { public static boolean instanceOf(Class clazz, Class target) { if (clazz == null) return false; if (clazz == target) return true; if (target.isInterface()) { for (Class aClass : clazz.getInterfaces()) { if (aClass == target) return true; }//from w w w . j a v a 2 s . c o m } if (clazz.getSuperclass() == target) return true; else { if (clazz.isInterface()) { for (Class aClass : clazz.getInterfaces()) { if (instanceOf(aClass, target)) return true; } } return instanceOf(clazz.getSuperclass(), target); } } }