Type (@NotNull Type subType, @NotNull String superType) { if (typeEquals(subType, superType)) { return subType; } Type result; if (subType instanceof ClassType) { try { ClassType clsType = (ClassType)subType; result = getSuperType(clsType.superclass(), superType); if (result != null) { return result; } for (InterfaceType iface : clsType.interfaces()) { result = getSuperType(iface, superType); if (result != null) { return result; } } } catch (ClassNotPreparedException e) { LOG.info(e); } return null; } if (subType instanceof InterfaceType) { try { for (InterfaceType iface : ((InterfaceType)subType).superinterfaces()) { result = getSuperType(iface, superType); if (result != null) { return result; } } } catch (ClassNotPreparedException e) { LOG.info(e); } } else if (subType instanceof ArrayType) { if (superType.endsWith("[]")) { try { String superTypeItem = superType.substring(0, superType.length() - 2); Type subTypeItem = ((ArrayType)subType).componentType(); return instanceOf(subTypeItem, superTypeItem) ? subType : null; } catch (ClassNotLoadedException e) { LOG.info(e); } } } return null; }