Rather than statically import every interesting subclass, forcing it all to
    be transferred and potentially disrupting the debugged environment,
    enumerate only those loaded in memory. Also returns the original class.
426580
def get_subclasses(klass):
    
    stack = [klass]
    seen = set()
    while stack:
        klass = stack.pop()
        seen.add(klass)
        stack.extend(klass.__subclasses__())
    return seen
542326
def _load_class(class_path):
    """"""
    parts = class_path.rsplit('.', 1)
    module = __import__(parts[0], fromlist=parts[1])
    return getattr(module, parts[1])
387799
def inspect_modules
      modules = []

      if constant.respond_to?(:ancestors)
        parent = inspect_superclass

        # Take all the modules included *directly* into the constant.
        modules = constant.ancestors.take_while do |ancestor|
          parent && ancestor != parent
        end

        # Get rid of non Module instances and modules that don't have a name.
        modules = modules.select do |mod|
          mod.instance_of?(Module) && mod.name
        end
      end

      return modules
    end
12039
private static ImmutableList<ImportTree> getWildcardImports(List<? extends ImportTree> imports) {
    ImmutableList.Builder<ImportTree> result = ImmutableList.builder();
    for (ImportTree tree : imports) {
      // javac represents on-demand imports as a member select where the selected name is '*'.
      Tree ident = tree.getQualifiedIdentifier();
      if (!(ident instanceof MemberSelectTree)) {
        continue;
      }
      MemberSelectTree select = (MemberSelectTree) ident;
      if (select.getIdentifier().contentEquals("*")) {
        result.add(tree);
      }
    }
    return result.build();
  }
396005
def _filter_classes(cls_list, cls_type):
    """"""
    for cls in cls_list:
        if isinstance(cls, type) and issubclass(cls, cls_type):
            if cls_type == TempyPlace and cls._base_place:
                pass
            else:
                yield cls
846082
@PublicAPI(usage = ACCESS)
    public JavaClasses importPackagesOf(Class<?>... classes) {
        return importPackagesOf(ImmutableSet.copyOf(classes));
    }
463038
def typelogged_class(cls):
    
    if not pytypes.typelogging_enabled:
        return cls
    assert(isclass(cls))
    # To play it safe we avoid to modify the dict while iterating over it,
    # so we previously cache keys.
    # For this we don't use keys() because of Python 3.
    # Todo: Better use inspect.getmembers here
    keys = [key for key in cls.__dict__]
    for key in keys:
        memb = cls.__dict__[key]
        if _check_as_func(memb):
            setattr(cls, key, typelogged_func(memb))
        elif isclass(memb):
            typelogged_class(memb)
    return cls
1360235
private static Method[] getAllDeclaredMethods(Class<?> classHierarchy)
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();

        Collection<MethodMap.MethodInfo> methodInfos = MethodMap.getAllDeclaredMethods(classHierarchy);
        Method[] methods = new Method[methodInfos.size()];
        int index = 0;

        for (MethodMap.MethodInfo methodInfo : methodInfos)
        {
            Method method = methodInfo.getMethod();
            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(tc, "adding method " + method);
            methods[index++] = method;
        }

        return methods;
    }
862014
def free_memory(cls, exclude=None):
        """"""

        annotations_in_memory = Annotation.__ANNOTATIONS_IN_MEMORY__

        exclude = () if exclude is None else exclude

        for annotation_cls in list(annotations_in_memory.keys()):

            if issubclass(annotation_cls, exclude):
                continue

            if issubclass(annotation_cls, cls):
                del annotations_in_memory[annotation_cls]
638982
def load_class_by_name(name: str):
    """"""
    mod_path, _, cls_name = name.rpartition('.')
    mod = importlib.import_module(mod_path)
    cls = getattr(mod, cls_name)
    return cls
774415
def all(self):
        
        class_list = list(self.get_class_list())
        if not class_list:
            self.cache = []
            return []

        if self.cache is not None:
            return self.cache

        results = []
        for cls_path in class_list:
            module_name, class_name = cls_path.rsplit('.', 1)
            try:
                module = __import__(module_name, {}, {}, class_name)
                cls = getattr(module, class_name)
                if self.instances:
                    results.append(cls())
                else:
                    results.append(cls)
            except Exception:
                logger.exception('Unable to import {cls}'.format(cls=cls_path))
                continue
        self.cache = results

        return results
170915
def get_classes_in_module(module, superclass=object):
    

    ret = []
    for classname in dir(module):
        attr = module.__getattribute__(classname)
        try:
            if issubclass(attr, superclass) and (attr != superclass):
                ret.append(attr)
        except TypeError:
            # "issubclass() arg 1 must be a class"
            pass
        except RuntimeError:
            # a99.get_python_logger().exception("Failed probing attribute '{}'".format(classname))
            # raise
            pass
    return ret
208887
public static Class<?>[] getClasses(Class<?> module) {
		HashSet<Class<?>> result = new HashSet<>();
		ClassLoader classLoader = Modules.class.getClassLoader();
		for (ClassModel info : Modules.getModuleModel(module)
				.getAllClassDependencies()) {
			try {
				result.add(classLoader.loadClass(info.getQualifiedName()));
			} catch (ClassNotFoundException e) {
				Modules.logger.error(
						"Error loading class " + info.getQualifiedName(), e);
			}
		}
		return result.toArray(new Class<?>[] {});
	}
441985
static JClassLoader getSystemClassLoader()
  {
    if (_staticClassLoader == null)
      _staticClassLoader = JClassLoaderWrapper.create(ClassLoader.getSystemClassLoader());

    return _staticClassLoader;
  }
378626
private static LookupResult findByClassLoading(String name, CompilationUnit compilationUnit, GroovyClassLoader loader) {
        Class cls;
        try {
            // NOTE: it's important to do no lookup against script files
            // here since the GroovyClassLoader would create a new CompilationUnit
            cls = loader.loadClass(name, false, true);
        } catch (ClassNotFoundException cnfe) {
            LookupResult lr = tryAsScript(name, compilationUnit, null);
            return lr;
        } catch (CompilationFailedException cfe) {
            throw new GroovyBugError("The lookup for " + name + " caused a failed compilation. There should not have been any compilation from this call.", cfe);
        }
        //TODO: the case of a NoClassDefFoundError needs a bit more research
        // a simple recompilation is not possible it seems. The current class
        // we are searching for is there, so we should mark that somehow.
        // Basically the missing class needs to be completely compiled before
        // we can again search for the current name.
        /*catch (NoClassDefFoundError ncdfe) {
            cachedClasses.put(name,SCRIPT);
            return false;
        }*/
        if (cls == null) return null;
        //NOTE: we might return false here even if we found a class,
        //      because  we want to give a possible script a chance to
        //      recompile. This can only be done if the loader was not
        //      the instance defining the class.
        ClassNode cn = ClassHelper.make(cls);
        if (cls.getClassLoader() != loader) {
            return tryAsScript(name, compilationUnit, cn);
        }
        return new LookupResult(null,cn);
    }
1106333
def getClass(self, tryImport=True):
        
        if not self.triedImport and tryImport:
            self.tryImportClass()

        return self._cls
1096986
public static ClassLoader getClassLoader(Class<?> cls) {
        ClassLoader cl = null;
        try {
            cl = Thread.currentThread().getContextClassLoader();
        } catch (Throwable ex) {
            // Cannot access thread context ClassLoader - falling back to system
            // class loader...
        }
        if (cl == null) {
            // No thread context class loader -> use class loader of this class.
            cl = cls.getClassLoader();
        }
        return cl;
    }