* @param systemname
   * @param cache
   * @param errorP
   * @return java.lang.reflect.Method
   */
  public static java.lang.reflect.Method autoload(String qualifiedname, String systemname, Surrogate cache, boolean errorP) {
    { java.lang.reflect.Method function = null;

      if (cache != null) {
        { FunctionCodeWrapper functionwrapper = ((FunctionCodeWrapper)(cache.surrogateValue));

          if (functionwrapper != null) {
            return (functionwrapper.wrapperValue);
          }
        }
      }
      try {
        { String functionname = null;
          String functionmodulename = null;
          Keyword type = null;

          { Object [] caller_MV_returnarray = new Object[2];

            functionname = Stella.parseStellaName(qualifiedname, false, caller_MV_returnarray);
            functionmodulename = ((String)(((StringWrapper)(caller_MV_returnarray[0])).wrapperValue));
            type = ((Keyword)(caller_MV_returnarray[1]));
          }
          type = type;
          { Module functionmodule = null;
            Symbol functionnamesymbol = null;
            MethodSlot functionobject = null;

            if (functionmodulename != null) {
              functionmodule = Stella.getStellaModule(functionmodulename, errorP &&
                  (systemname == null));
            }
            if (functionmodule != null) {
              functionnamesymbol = Symbol.lookupSymbolInModule(functionname, functionmodule, false);
            }
            if (functionnamesymbol != null) {
              functionobject = Symbol.lookupFunction(functionnamesymbol);
            }
            if (functionobject != null) {
              function = functionobject.functionCode;
            }
            else if ((systemname != null) &&
                (!Stella.systemLoadedP(systemname))) {
              { Object old$Module$000 = Stella.$MODULE$.get();
                Object old$Context$000 = Stella.$CONTEXT$.get();

                try {
                  Native.setSpecial(Stella.$MODULE$, Stella.$STELLA_MODULE$);
                  Native.setSpecial(Stella.$CONTEXT$, ((Module)(Stella.$MODULE$.get())));
                  Stella.loadSystem(systemname, Stella.NIL);

                } finally {
                  Stella.$CONTEXT$.set(old$Context$000);
                  Stella.$MODULE$.set(old$Module$000);
                }
              }
              return (Stella.autoload(qualifiedname, null, cache, errorP));
            }
          }
        }
      } catch (StellaException e) {
        if (errorP) {
          if (systemname != null) {
            { OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

              stream000.nativeStream.print("autoload: failed to define `" + qualifiedname + "': `" + Stella.exceptionMessage(e) + "'");
              throw ((StellaException)(StellaException.newStellaException(stream000.theStringReader()).fillInStackTrace()));
            }
          }
          else {
            throw ((StellaException)(e.fillInStackTrace()));
          }
        }
      }
      if (function == null) {
        if (errorP) {
          { OutputStringStream stream001 = OutputStringStream.newOutputStringStream();

            stream001.nativeStream.print("autoload: failed to define `" + qualifiedname + "'");
            throw ((StellaException)(StellaException.newStellaException(stream001.theStringReader()).fillInStackTrace()));
          }
        }
        else {
          return (null);
        }
      }
      if (cache != null) {
        cache.surrogateValue = FunctionCodeWrapper.wrapFunctionCode(function);
      }
      return (function);
    }
  }