public static void javaOutputAllUnitsToFile() {
    { StringWrapper startupclassname = null;
      StringHashTable startupht = StringHashTable.newStringHashTable();
      Cons startupclasslist = Stella.NIL;
      Cons methods = Stella.NIL;
      HashTable flotsamfunctionht = HashTable.newHashTable();
      HashTable globalsht = HashTable.newHashTable();
      List codemoduleslist = List.list(Stella.NIL);
      Cons verbatimstatements = Stella.NIL;
      Cons classes = Stella.NIL;
      Module codeoutputmodule = null;

      Stella.$JAVA_STELLA_PACKAGE_MAPPING$.insertAt(StringWrapper.wrapString("STELLAROOT"), StringWrapper.wrapString(Stella.javaStellaPackage()));
      Native.setSpecial(Stella.$TRANSLATIONUNITS$, ((List)(Stella.$TRANSLATIONUNITS$.get())).reverse());
      { TranslationUnit unit = null;
        Cons iter000 = ((List)(Stella.$TRANSLATIONUNITS$.get())).theConsList;

        for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
          unit = ((TranslationUnit)(iter000.value));
          { Symbol testValue000 = unit.category;

            if ((testValue000 == Stella.SYM_STELLA_METHOD) ||
                (testValue000 == Stella.SYM_STELLA_MACRO)) {
              if (MethodSlot.javaFlotsamFunctionP(((MethodSlot)(unit.theObject)))) {
                codeoutputmodule = unit.theObject.homeModule();
                HashTable.javaPushIntoHashTable(flotsamfunctionht, codeoutputmodule, unit);
                codemoduleslist.insertNew(codeoutputmodule);
              }
              else if (((MethodSlot)(unit.theObject)).methodStartupFunctionP()) {
                startupclassname = StringWrapper.javaTranslateClassNamestring(StringWrapper.wrapString(((StringWrapper)(KeyValueList.dynamicSlotValue(((MethodSlot)(unit.theObject)).dynamicSlots, Stella.SYM_STELLA_METHOD_STARTUP_CLASSNAME, Stella.NULL_STRING_WRAPPER))).wrapperValue));
                StringHashTable.javaPushIntoStringHashTable(startupht, startupclassname.wrapperValue, unit);
                if (!(startupclasslist.memberP(startupclassname))) {
                  startupclasslist = Cons.cons(startupclassname, startupclasslist);
                }
              }
              else {
                methods = Cons.cons(unit, methods);
              }
            }
            else if (testValue000 == Stella.SYM_STELLA_PRINT_METHOD) {
              methods = Cons.cons(unit, methods);
            }
            else if (testValue000 == Stella.SYM_STELLA_TYPE) {
            }
            else if (testValue000 == Stella.SYM_STELLA_VERBATIM) {
              verbatimstatements = Cons.cons(unit, verbatimstatements);
            }
            else if (testValue000 == Stella.SYM_STELLA_CLASS) {
              classes = Cons.cons(unit, classes);
            }
            else if (testValue000 == Stella.SYM_STELLA_GLOBAL_VARIABLE) {
              codeoutputmodule = unit.theObject.homeModule();
              HashTable.javaPushIntoHashTable(globalsht, codeoutputmodule, unit);
              codemoduleslist.insertNew(codeoutputmodule);
            }
            else {
              { OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

                stream000.nativeStream.print("`" + testValue000 + "' is not a valid case option");
                throw ((StellaException)(StellaException.newStellaException(stream000.theStringReader()).fillInStackTrace()));
              }
            }
          }
        }
      }
      { TranslationUnit classunit = null;
        Cons iter001 = classes;

        for (;!(iter001 == Stella.NIL); iter001 = iter001.rest) {
          classunit = ((TranslationUnit)(iter001.value));
          if (TranslationUnit.javaClassUnitDefinesFlotsamClassP(classunit)) {
            { Module module = classunit.theObject.homeModule();
              Cons globals = Stella.NIL;
              Cons functions = Stella.NIL;

              { Object old$Module$000 = Stella.$MODULE$.get();
                Object old$Context$000 = Stella.$CONTEXT$.get();

                try {
                  Native.setSpecial(Stella.$MODULE$, module);
                  Native.setSpecial(Stella.$CONTEXT$, ((Module)(Stella.$MODULE$.get())));
                  globals = ((Cons)(globalsht.lookup(module)));
                  if (!(globals != null)) {
                    globals = Stella.NIL;
                  }
                  functions = ((Cons)(flotsamfunctionht.lookup(module)));
                  if (!(functions != null)) {
                    functions = Stella.NIL;
                  }
                  Stella.javaOutputFlotsamUnitsToFileForModule(Module.javaMakeGlobalOutputFileName(module, false), module, classunit, globals, functions);
                  codemoduleslist.remove(module);

                } finally {
                  Stella.$CONTEXT$.set(old$Context$000);
                  Stella.$MODULE$.set(old$Module$000);
                }
              }
            }
          }
          else {
            TranslationUnit.javaOutputClassUnitToFile(classunit);
          }
        }
      }
      HashTable.javaOutputFlotsamUnitsToFile(globalsht, flotsamfunctionht, codemoduleslist.theConsList);
      StringHashTable.javaOutputStartupUnitsToFile(startupht, startupclasslist);
    }
  }