Is given class a subclass of given base class, or an inner class
of a subclass?
Return null if no such class exists.
@param c     The class which is the subclass or is contained in it.
@param base  The base class
438977
private boolean isInnerSubClass(ClassSymbol c, Symbol base) {
            while (c != null && !c.isSubClass(base, types)) {
                c = c.owner.enclClass();
            }
            return c != null;
        }
1166663
public static boolean isSubtype(final Class<? extends Entity> descendant, final Class<? extends Entity> ancestor) {
	return !ancestor.equals(descendant) && ancestor.isAssignableFrom(descendant);
    }
1373200
private boolean areClassesEqual(Class<?> c1, Class<?> c2) {
        if (isMap(c1)) {
            return isMap(c2);
        } else if (isList(c1)) {
            return isList(c2);
        } else {
            return c1.equals(c2);
        }
    }
242818
public static Klass<Class> java(Class c) {
        return c == null ? null : new Klass<Class>(c, KlassNavigator.JAVA);
    }
991582
public boolean isSubtypeOf(Class<?> clazz) {
		if (isType(clazz)) {
			return true;
		}
		// TODO interfaces don't inherit from non-interfaces, primitives, arrays, object
		// A final type does not have any subtypes
		JvmType type = findType(clazz);
		if (type == null) {
			return false;
		}
		return isSubtypeOf(type);
	}
230400
@Pure
	protected boolean isSubTypeOf(EObject context, JvmTypeReference subType, JvmTypeReference superType) {
		if (isTypeReference(superType) && isTypeReference(subType)) {
			StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, context);
			LightweightTypeReferenceFactory factory = new LightweightTypeReferenceFactory(owner, false);
			LightweightTypeReference reference = factory.toLightweightReference(subType);
			return reference.isSubtypeOf(superType.getType());
		}
		return false;
	}
223772
public final DocWorkUnit findWorkUnitForClass(final Class<?> c) {
        for (final DocWorkUnit workUnit : this.workUnits)
            if (workUnit.getClazz().equals(c))
                return workUnit;
        return null;
    }
107360
function c3mro(bases, className) {
        var result = [], roots = [
            {cls: 0, refs: []}
        ], nameMap = {}, clsCount = 1,
            l = bases.length, i = 0, j, lin, base, top, proto, rec, name, refs;

        // build a list of bases naming them if needed
        for (i = 0; i < l; i += 1) {
            base = bases[i];
            if (!base) {
                err("mixin #" + i + " is unknown. Did you use dojo.require to pull it in?", className);
            } else if (opts.call(base) !== "[object Function]") {
                err("mixin #" + i + " is not a callable constructor.", className);
            }
            lin = base._meta ? base._meta.bases : [base];
            top = 0;
            // add bases to the name map
            for (j = lin.length - 1; j >= 0; j -= 1) {
                proto = lin[j].prototype;
                if (!proto.hasOwnProperty("declaredClass")) {
                    proto.declaredClass = "uniqName_" + (counter += 1);
                }
                name = proto.declaredClass;
                if (!nameMap.hasOwnProperty(name)) {
                    nameMap[name] = {count: 0, refs: [], cls: lin[j]};
                    clsCount += 1;
                }
                rec = nameMap[name];
                if (top && top !== rec) {
                    rec.refs.push(top);
                    top.count += 1;
                }
                top = rec;
            }
            top.count += 1;
            roots[0].refs.push(top);
        }

        // remove classes without external references recursively
        while (roots.length) {
            top = roots.pop();
            result.push(top.cls);
            clsCount -= 1;
            // optimization: follow a single-linked chain
            while ((refs = top.refs).length === 1) {
                top = refs[0];
                if (!top || (top.count -= 1)) {
                    // branch or end of chain => do not end to roots
                    top = 0;
                    break;
                }
                result.push(top.cls);
                clsCount -= 1;
            }
            if (top) {
                // branch
                for (i = 0, l = refs.length; i < l; i += 1) {
                    top = refs[i];
                    if (!(top.count -= 1)) {
                        roots.push(top);
                    }
                }
            }
        }
        if (clsCount) {
            err("can't build consistent linearization", className);
        }

        // calculate the superclass offset
        base = bases[0];
        result[0] = base ?
            base._meta && base === result[result.length - base._meta.bases.length] ?
                base._meta.bases.length : 1 : 0;

        return result;
    }
1090679
public boolean hasSubtypes(ClassDescriptor classDescriptor) throws ClassNotFoundException {
        Set<ClassDescriptor> subtypes = getDirectSubtypes(classDescriptor);
        if (DEBUG) {
            System.out.println("Direct subtypes of " + classDescriptor + " are " + subtypes);
        }
        return !subtypes.isEmpty();
    }
1332332
@SuppressWarnings("unchecked")
	@Override
	public <E> E getBean(Class<E> c) {
		String name = c.getSimpleName();
		String beanName = name.substring(0, 1).toLowerCase() + name.substring(1);
		String className = c.getName();
		// System.out.println("name:" + name);
		logger.info("beanName:" + beanName + " className:" + className);
		return (E) getBean(beanName);
	}
1054276
private static boolean isPrimitive(Class<? extends Object> c) {
		return (null == c) || (Class.class == c) || (String.class == c) || c.isPrimitive() || (Integer.class == c) || (Long.class == c)
				|| (Short.class == c) || (Byte.class == c) || (Character.class == c) || (Float.class == c) || (Double.class == c)
				|| (Void.class == c) || (Boolean.class == c);
	}
909467
public static boolean classNodeImplementsType(ClassNode node, Class target) {
        ClassNode targetNode = ClassHelper.make(target);
        if (node.implementsInterface(targetNode)) {
            return true;
        }
        if (node.isDerivedFrom(targetNode)) {
            return true;
        }
        if (node.getName().equals(target.getName())) {
            return true;
        }
        if (node.getName().equals(target.getSimpleName())) {
            return true;
        }
        if (node.getSuperClass() != null && node.getSuperClass().getName().equals(target.getName())) {
            return true;
        }
        if (node.getSuperClass() != null && node.getSuperClass().getName().equals(target.getSimpleName())) {
            return true;
        }
        if (node.getInterfaces() != null) {
            for (ClassNode declaredInterface : node.getInterfaces()) {
                if (classNodeImplementsType(declaredInterface, target)) {
                    return true;
                }
            }
        }
        return false;
    }
414056
private static boolean isRootResourceClass(Class<?> c)
    {
        if ( c == null )
        {
            return false;
        }
        else if ( c.isAnnotationPresent(Path.class) )
        {
            return true;
        }
        else
        {
            Class[] arr = c.getInterfaces();
            int len = arr.length;

            //noinspection ForLoopReplaceableByForEach
            for ( int i = 0; i < len; ++i )
            {
                Class clazz = arr[i];
                if ( clazz.isAnnotationPresent(Path.class) )
                {
                    return true;
                }
            }

            return false;
        }
    }
286015
public static boolean isSubclass(Class a, Class b) {
		if (a == b)
			return false;
		if (!(b.isAssignableFrom(a)))
			return false;
		return true;
	}
347821
public static Class commonClass(Class c1, Class c2)
    {
        if (c1 == c2)
        {
            return c1;
        }

        if ((c1 == Object.class) || c1.isAssignableFrom(c2))
        {
            return c1;
        }

        if (c2.isAssignableFrom(c1))
        {
            return c2;
        }

        if (c1.isPrimitive() || c2.isPrimitive())
        {
            // REVISIT: we could try to autoconvert to Object or something appropriate
            throw new IllegalArgumentException("incompatible types " + c1 + " and " + c2);
        }

        // REVISIT: we could try to find a common supper class or interface
        return Object.class;
    }
1079096
static <T> List<Class> getTypeArguments(Class<T> baseClass, Class<? extends T> childClass) {
        Map<Type, Type> resolvedTypes = new LinkedHashMap<Type, Type>();
        Type type = childClass;
        // start walking up the inheritance hierarchy until we hit baseClass
        while (! getClass(type).equals(baseClass)) {
            if (type instanceof Class) {
                // there is no useful information for us in raw types, so just keep going.
                type = ((Class) type).getGenericSuperclass();
            }
            else {
                ParameterizedType parameterizedType = (ParameterizedType) type;
                Class<?> rawType = (Class) parameterizedType.getRawType();

                Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
                TypeVariable<?>[] typeParameters = rawType.getTypeParameters();
                for (int i = 0; i < actualTypeArguments.length; i++) {
                    resolvedTypes.put(typeParameters[i], actualTypeArguments[i]);
                }

                if (!rawType.equals(baseClass)) {
                    type = rawType.getGenericSuperclass();
                }
            }
        }

        // finally, for each actual type argument provided to baseClass, determine (if possible)
        // the raw class for that type argument.
        Type[] actualTypeArguments;
        if (type instanceof Class) {
            actualTypeArguments = ((Class) type).getTypeParameters();
        }
        else {
            actualTypeArguments = ((ParameterizedType) type).getActualTypeArguments();
        }
        List<Class> typeArgumentsAsClasses = new ArrayList<Class>();
        // resolve types by chasing down type variables.
        for (Type baseType: actualTypeArguments) {
            while (resolvedTypes.containsKey(baseType)) {
                baseType = resolvedTypes.get(baseType);
            }
            typeArgumentsAsClasses.add(getClass(baseType));
        }
        return typeArgumentsAsClasses;
    }
1334832
def is_base_and_derived(based, derived):
    """"""
    assert isinstance(based, class_declaration.class_t)
    assert isinstance(derived, (class_declaration.class_t, tuple))

    if isinstance(derived, class_declaration.class_t):
        all_derived = ([derived])
    else:  # tuple
        all_derived = derived

    for derived_cls in all_derived:
        for base_desc in derived_cls.recursive_bases:
            if base_desc.related_class == based:
                return True
    return False