def initialize_autoloaded_paths(mods = ObjectSpace.each_object(Module)) # &do_autoload_block
      mods.each do |mod|
        # Module's constants are shared with Object. But if you set autoloads directly on Module, they
        # appear on multiple classes. So just skip, Object will take care of those.
        next if mod == Module
        # This happens with JRuby
        next unless mod.respond_to?(:constants)

        if mod.frozen?
          if mod.constants.any? { |name| mod.autoload?(name) }
            self.class.warn_frozen_module(mod)
          end
          next
        end

        mod.constants.each do |name|
          # JRuby can talk about deprecated constants here
          path = Tools.silence_warnings do
            mod.autoload?(name)
          end
          next unless path
          interceptor_path = setup_interceptor_for(mod, name, path)
          yield mod, name, interceptor_path
        end
      end
    end
def initialize_autoloaded_paths(mods = ObjectSpace.each_object(Module)) # &do_autoload_block
      mods.each do |mod|
        # Module's constants are shared with Object. But if you set autoloads directly on Module, they
        # appear on multiple classes. So just skip, Object will take care of those.
        next if mod == Module
        # This happens with JRuby
        next unless mod.respond_to?(:constants)

        if mod.frozen?
          if mod.constants.any? { |name| mod.autoload?(name) }
            self.class.warn_frozen_module(mod)
          end
          next
        end

        mod.constants.each do |name|
          # JRuby can talk about deprecated constants here
          path = Tools.silence_warnings do
            mod.autoload?(name)
          end
          next unless path
          interceptor_path = setup_interceptor_for(mod, name, path)
          yield mod, name, interceptor_path
        end
      end
    end
In JRuby, ObjectSpace.each_object is allowed for Module and Class, so we are good.