public static void javaOutputFlotsamUnitsToFileForModule(String classoutputfile, Module module, TranslationUnit classunit, Cons globals, Cons functions) {
    { Object old$CurrentJavaOutputClass$000 = Stella.$CURRENT_JAVA_OUTPUT_CLASS$.get();

      try {
        Native.setSpecial(Stella.$CURRENT_JAVA_OUTPUT_CLASS$, null);
        { Cons translation = Stella.NIL;
          Stella_Class renamed_Class = null;
          Cons classtranslation = 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())));
              { OutputFileStream classoutputstream = null;

                try {
                  classoutputstream = Stella.openOutputFile(classoutputfile, Stella.NIL);
                  if (classunit != null) {
                    Native.setSpecial(Stella.$CURRENT_JAVA_OUTPUT_CLASS$, ((Stella_Class)(classunit.theObject)));
                    System.out.println("Translating `" + renamed_Class + "'...");
                    classtranslation = Stella_Class.javaTranslateDefineNativeClass(((Stella_Class)(Stella.$CURRENT_JAVA_OUTPUT_CLASS$.get()))).rest;
                  }
                  { Object old$CurrentStream$000 = Stella.$CURRENT_STREAM$.get();

                    try {
                      Native.setSpecial(Stella.$CURRENT_STREAM$, classoutputstream);
                      if (((Integer)(Stella.$TRANSLATIONVERBOSITYLEVEL$.get())).intValue() >= 1) {
                        if (classunit != null) {
                          System.out.println("    Writing `" + classoutputfile + "' ...");
                        }
                        else {
                          System.out.println("Writing `" + classoutputfile + "'...");
                        }
                      }
                      OutputStream.javaOutputFileHeader(classoutputstream, Module.javaMakeGlobalOutputFileName(module, true));
                      if (classunit != null) {
                        Cons.javaOutputClassDeclaration(classtranslation);
                      }
                      else {
                        ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.print("public class " + Module.javaYieldFlotsamClassName(module) + " ");
                      }
                      ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println("{");
                      Stella.javaBumpIndent();
                      if (classunit != null) {
                        Cons.javaOutputClassVariableDefinitions(((Cons)(classtranslation.nth(6))));
                      }
                      { TranslationUnit global = null;
                        Cons iter000 = globals;

                        for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
                          global = ((TranslationUnit)(iter000.value));
                          translation = TranslationUnit.javaTranslateUnit(global);
                          Cons.javaOutputGlobalDefinition(translation.rest);
                          global.translation = null;
                          global.codeRegister = null;
                        }
                      }
                      if (classunit != null) {
                        Cons.javaOutputClassConstructors(((Cons)(classtranslation.nth(7))), Module.javaYieldFlotsamClassName(module), (((Stella_Class)(Stella.$CURRENT_JAVA_OUTPUT_CLASS$.get())) != null) &&
                            Stella_Class.exceptionClassP(((Stella_Class)(Stella.$CURRENT_JAVA_OUTPUT_CLASS$.get()))));
                        { TranslationUnit statement = null;
                          Cons iter001 = ((Cons)(classtranslation.nth(8)));

                          for (;!(iter001 == Stella.NIL); iter001 = iter001.rest) {
                            statement = ((TranslationUnit)(iter001.value));
                            Stella_Object.javaOutputStatement(TranslationUnit.javaTranslateUnit(statement));
                            statement.translation = null;
                            statement.codeRegister = null;
                          }
                        }
                      }
                      { TranslationUnit function = null;
                        Cons iter002 = functions;

                        for (;!(iter002 == Stella.NIL); iter002 = iter002.rest) {
                          function = ((TranslationUnit)(iter002.value));
                          Cons.javaOutputMethod(TranslationUnit.javaTranslateUnit(function).rest);
                          function.translation = null;
                          function.codeRegister = null;
                        }
                      }
                      Stella.javaUnbumpIndent();
                      ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println("}");

                    } finally {
                      Stella.$CURRENT_STREAM$.set(old$CurrentStream$000);
                    }
                  }

                } finally {
                  if (classoutputstream != null) {
                    classoutputstream.free();
                  }
                }
              }

            } finally {
              Stella.$CONTEXT$.set(old$Context$000);
              Stella.$MODULE$.set(old$Module$000);
            }
          }
        }

      } finally {
        Stella.$CURRENT_JAVA_OUTPUT_CLASS$.set(old$CurrentJavaOutputClass$000);
      }
    }
  }