Ensure the class iterator is pointin to a non empty class
Loads the first resource block to test this
506012
protected function ensureNotEmpty() {
        $this->currentInstance = 0;
        while ($this->resourceIterator->valid() && !$this->load($this->resourceIterator->current(), 0)) {
            $this->resourceIterator->next();
        }
    }
380846
public boolean load()
    {
    	_load();
    	java.util.Iterator it = this.alChildren.iterator();
    	while (it.hasNext())
    	{
    		Object o = it.next();
    		if (o instanceof OjbMetaTreeNode) ((OjbMetaTreeNode)o).load();
    	}
    	return true;
    }
1134235
public synchronized static void init() {
    if (!isInitialized()) {
      if (processEngines == null) {
        // Create new map to store process-engines if current map is
        // null
        processEngines = new HashMap<String, ProcessEngine>();
      }
      ClassLoader classLoader = ReflectUtil.getClassLoader();
      Enumeration<URL> resources = null;
      try {
        resources = classLoader.getResources("activiti.cfg.xml");
      } catch (IOException e) {
        throw new ActivitiIllegalArgumentException("problem retrieving activiti.cfg.xml resources on the classpath: " + System.getProperty("java.class.path"), e);
      }

      // Remove duplicated configuration URL's using set. Some
      // classloaders may return identical URL's twice, causing duplicate
      // startups
      Set<URL> configUrls = new HashSet<URL>();
      while (resources.hasMoreElements()) {
        configUrls.add(resources.nextElement());
      }
      for (Iterator<URL> iterator = configUrls.iterator(); iterator.hasNext();) {
        URL resource = iterator.next();
        log.info("Initializing process engine using configuration '{}'", resource.toString());
        initProcessEngineFromResource(resource);
      }

      try {
        resources = classLoader.getResources("activiti-context.xml");
      } catch (IOException e) {
        throw new ActivitiIllegalArgumentException("problem retrieving activiti-context.xml resources on the classpath: " + System.getProperty("java.class.path"), e);
      }
      while (resources.hasMoreElements()) {
        URL resource = resources.nextElement();
        log.info("Initializing process engine using Spring configuration '{}'", resource.toString());
        initProcessEngineFromSpringResource(resource);
      }

      setInitialized(true);
    } else {
      log.info("Process engines already initialized");
    }
  }
3324
function next() {
        $this->unmoved = false;
        if ($this->valid()) {
            $this->currentInstance++;
            if (!isset($this->instanceCache[$this->currentInstance])) {
                // try to load next block (unless we know it's empty)
                $remainingInstances = !$this->endOfResource && $this->load($this->resourceIterator->current(), $this->currentInstance);

                // endOfClass or failed loading
                if (!$remainingInstances) {
                    $this->resourceIterator->next();
                    $this->ensureNotEmpty();
                }
            }
            $this->ensureValidResult();
        }
    }
1020735
def iteritems(cls):
        
        for key in dir(cls):
            val = getattr(cls, key)
            if isinstance(cls, val):
                yield (key, val)
1315368
private static ClassLoader getInitParent(ClassLoader parent,
                                           boolean isRoot)
  {
    if (parent == null)
      parent = Thread.currentThread().getContextClassLoader();

    if (isRoot || parent instanceof DynamicClassLoader)
      return parent;
    else {
      //return RootDynamicClassLoader.create(parent);
      return parent;
    }
  }
1087371
private void loadAllInstances(ZooClassProxy def, boolean subClasses, 
			MergingIterator<ZooPC> iter, boolean loadFromCache) {
		for (Node n: nodes) {
			iter.add(n.loadAllInstances(def, loadFromCache));
		}
		
		if (subClasses) {
			for (ZooClassProxy sub: def.getSubProxies()) {
				loadAllInstances(sub, true, iter, loadFromCache);
			}
		}
	}
1374467
public void load(ClassLoader classLoader) {
        Map<String, GroovyRunner> map = runnerMap; // direct read
        if (map == null) {
            map = getMap(); // initialize and load (recursive call), result ignored
            if (classLoader == null) {
                // getMap() already loaded using a null classloader
                return;
            }
        }
        writeLock.lock();
        try {
            if (classLoader == null) {
                classLoader = Thread.currentThread().getContextClassLoader();
            }
            cachedValues = null;
            loadDefaultRunners();
            loadWithLock(classLoader);
        } catch (SecurityException se) {
            LOG.log(Level.WARNING, "Failed to get the context ClassLoader", se);
        } catch (ServiceConfigurationError sce) {
            LOG.log(Level.WARNING, "Failed to load GroovyRunner services from ClassLoader " + classLoader, sce);
        } finally {
            writeLock.unlock();
        }
    }
384404
Class loadAccessClass (String name) {
		// No need to check the parent class loader if the access class hasn't been defined yet.
		if (localClassNames.contains(name)) {
			try {
				return loadClass(name, false);
			} catch (ClassNotFoundException ex) {
				throw new RuntimeException(ex); // Should not happen, since we know the class has been defined.
			}
		}
		return null;
	}
964046
private static <T extends ChallengeHandler> T load0(Class<T>         clazz, 
                                                 ServiceLoader<T> serviceLoader) {
        for (ChallengeHandler challengeHandler: serviceLoader) {
            Class<?> c = challengeHandler.getClass();
            if ((clazz != null) && clazz.isAssignableFrom(c)) {
                try {
                    return clazz.cast(c.newInstance());
                } catch (InstantiationException e) {
                    String s = "Failed to instantiate class " + c;
                    throw new RuntimeException(s,e);
                } catch (IllegalAccessException e) {
                    String s = "Failed to access and instantiate class " + c;
                    throw new RuntimeException(s, e);
                }
            }
        }
        return null;
    }
478132
private void load() {
    Iterator iterator = loaders.iterator();
    while (iterator.hasNext()) {
      MacroLoader loader = (MacroLoader) iterator.next();
      loader.setRepository(this);
      log.debug("Loading from: " + loader.getClass());
      loader.loadPlugins(this);
    }
  }
557225
def terminal_attribute_iterator(self, mapped_class=None, key=None):
        
        for attr in self._attribute_iterator(mapped_class, key):
            if attr.kind == RESOURCE_ATTRIBUTE_KINDS.TERMINAL:
                yield attr
697900
def initialize_resources_class_accessors! #:nodoc:
        # First priority is the namespaced model, e.g. User::Group
        self.resource_class ||= begin
          namespaced_class = self.name.sub(/Controller$/, '').singularize
          namespaced_class.constantize
        rescue NameError
          nil
        end

        # Second priority is the top namespace model, e.g. EngineName::Article for EngineName::Admin::ArticlesController
        self.resource_class ||= begin
          namespaced_classes = self.name.sub(/Controller$/, '').split('::')
          namespaced_class = [namespaced_classes.first, namespaced_classes.last].join('::').singularize
          namespaced_class.constantize
        rescue NameError
          nil
        end

        # Third priority the camelcased c, i.e. UserGroup
        self.resource_class ||= begin
          camelcased_class = self.name.sub(/Controller$/, '').gsub('::', '').singularize
          camelcased_class.constantize
        rescue NameError
          nil
        end

        # Otherwise use the Group class, or fail
        self.resource_class ||= begin
          class_name = self.controller_name.classify
          class_name.constantize
        rescue NameError => e
          raise unless e.message.include?(class_name)
          nil
        end

        self.parents_symbols = self.parents_symbols.try(:dup) || []

        # Initialize resources configuration hash
        self.resources_configuration = self.resources_configuration.try(:dup) || {}
        self.resources_configuration.each do |key, value|
          next unless value.is_a?(Hash) || value.is_a?(Array)
          self.resources_configuration[key] = value.dup
        end

        config = (self.resources_configuration[:self] ||= {})
        config[:collection_name] = self.controller_name.to_sym
        config[:instance_name]   = self.controller_name.singularize.to_sym

        config[:route_collection_name] = config[:collection_name]
        config[:route_instance_name]   = config[:instance_name]

        # Deal with namespaced controllers
        namespaces = self.controller_path.split('/')[0..-2]

        # Remove namespace if its a mountable engine
        namespaces.delete_if do |namespace|
          begin
            "#{namespace}/engine".camelize.constantize.isolated?
          rescue StandardError, LoadError
            false
          end
        end

        config[:route_prefix] = namespaces.join('_') unless namespaces.empty?

        # Deal with default request parameters in namespaced controllers, e.g.
        # Forum::Thread#create will properly pick up the request parameter
        # which will be forum_thread, and not thread
        # Additionally make this work orthogonally with instance_name
        config[:request_name] = self.resource_class.to_s.underscore.gsub('/', '_')

        # Initialize polymorphic, singleton, scopes and belongs_to parameters
        polymorphic = self.resources_configuration[:polymorphic] || { symbols: [], optional: false }
        polymorphic[:symbols] = polymorphic[:symbols].dup
        self.resources_configuration[:polymorphic] = polymorphic
      end
610878
@SneakyThrows
    @SuppressWarnings("FutureReturnValueIgnored")
    public void init() {
        if (!validateConfiguration()) {
            return;
        }

        val results = this.fetcher.fetch(getResources());
        ResourceCRLRevocationChecker.this.addCrls(results);

        final Runnable scheduledFetcher = () -> {
            try {
                val fetchedResults = getFetcher().fetch(getResources());
                ResourceCRLRevocationChecker.this.addCrls(fetchedResults);
            } catch (final Exception e) {
                LOGGER.debug(e.getMessage(), e);
            }
        };

        this.scheduler.scheduleAtFixedRate(
            scheduledFetcher,
            this.refreshInterval,
            this.refreshInterval,
            TimeUnit.SECONDS);

    }
904454
private Iterable<URL> createServiceFileIterator() {
        if (classLoader == null) {
            ClassLoader classLoader = SchemaFactoryFinder.class.getClassLoader();
            return Collections.singleton(classLoader.getResource(SERVICE_ID));
        } else {
            try {
                Enumeration<URL> e = classLoader.getResources(SERVICE_ID);
                if (debug && !e.hasMoreElements()) {
                    debugPrintln("no "+SERVICE_ID+" file was found");
                }

                // wrap it into an Iterator.
                return Collections.list(e);
            } catch (IOException e) {
                if (debug) {
                    debugPrintln("failed to enumerate resources "+SERVICE_ID);
                    e.printStackTrace();
                }
                return Collections.emptySet();
            }
        }
    }
862865
private void prepareNextIterator()
	{
	    if (currentIterator == null || !currentIterator.hasNext())
	    {
	        currentIterator = null;
	        while (iteratorIterator.hasNext())
	        {
	            currentIterator = iteratorIterator.next();
	            if (currentIterator.hasNext())
	            {
	                break;
	            }
	            currentIterator = null;
	        }
	    }
	}
1110442
private synchronized static void initialize() {
    if(MASTER_CACHE != null) {
      return;
    }
    try {
      Enumeration<URL> cps = CLASSLOADER.getResources("");
      List<Class<?>> res = new ArrayList<>();
      while(cps.hasMoreElements()) {
        URL u = cps.nextElement();
        // Scan file sources only.
        if(!"file".equals(u.getProtocol())) {
          continue;
        }
        try {
          Iterator<String> it = new DirClassIterator(new File(u.toURI()));
          while(it.hasNext()) {
            try {
              Class<?> cls = CLASSLOADER.loadClass(it.next());
              // skip classes where we can't get a full name.
              if(cls.getCanonicalName() == null) {
                continue;
              }
              res.add(cls);
            }
            catch(Exception | Error e) {
              continue;
            }
          }
        }
        catch(URISyntaxException e) {
          LOG.warning("Incorrect classpath entry: " + u);
          continue;
        }
      }
      MASTER_CACHE = Collections.unmodifiableList(res);
      if(LOG.isDebuggingFinest()) {
        LOG.debugFinest("Classes found by scanning the development classpath: " + MASTER_CACHE.size());
      }
    }
    catch(IOException e) {
      LOG.exception(e);
      return;
    }
  }