gt:                 for (JavaFileObject file: fileObjects) {
context: /*
   * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Oracle designates this
   * particular file as subject to the "Classpath" exception as provided
   * by Oracle in the LICENSE file that accompanied this code.
   *
   * This code is distributed in the hope that it will be useful, but WITHOUT
   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   * version 2 for more details (a copy is included in the LICENSE file that
   * accompanied this code).
   *
   * You should have received a copy of the GNU General Public License version
   * 2 along with this work; if not, write to the Free Software Foundation,
   * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   *
   * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   * or visit www.oracle.com if you need additional information or have any
   * questions.
   */
  
  package openjdk7.com.sun.tools.javac.api;
  
  import java.io.File;
  import java.io.IOException;
  import java.nio.CharBuffer;
  import java.util.*;
  import java.util.concurrent.atomic.AtomicBoolean;
  
  import javax.annotation.processing.Processor;
  import javax.lang.model.element.Element;
  import javax.lang.model.element.TypeElement;
  import javax.lang.model.type.TypeMirror;
  import javax.tools.*;
  
  import openjdk7.com.sun.source.tree.*;
  import openjdk7.com.sun.source.util.*;
  import openjdk7.com.sun.tools.javac.code.*;
  import openjdk7.com.sun.tools.javac.code.Symbol.*;
  import openjdk7.com.sun.tools.javac.comp.*;
  import openjdk7.com.sun.tools.javac.file.JavacFileManager;
  import openjdk7.com.sun.tools.javac.main.*;
  import openjdk7.com.sun.tools.javac.model.*;
  import openjdk7.com.sun.tools.javac.parser.Parser;
  import openjdk7.com.sun.tools.javac.parser.ParserFactory;
  import openjdk7.com.sun.tools.javac.tree.*;
  import openjdk7.com.sun.tools.javac.tree.JCTree.*;
  import openjdk7.com.sun.tools.javac.util.*;
  import openjdk7.com.sun.tools.javac.util.List;
  import openjdk7.com.sun.tools.javac.main.JavaCompiler;
  
  /**
   * Provides access to functionality specific to the JDK Java Compiler, javac.
   *
   * <p><b>This is NOT part of any supported API.
   * If you write code that depends on this, you do so at your own
   * risk.  This code and its internal interfaces are subject to change
   * or deletion without notice.</b></p>
   *
   * @author Peter von der Ah&eacute;
   * @author Jonathan Gibbons
   */
  public class JavacTaskImpl extends JavacTask {
      private ClientCodeWrapper ccw;
      private Main compilerMain;
      private JavaCompiler compiler;
      private Locale locale;
      private String[] args;
      private String[] classNames;
      private Context context;
      private List<JavaFileObject> fileObjects;
      private Map<JavaFileObject, JCCompilationUnit> notYetEntered;
      private ListBuffer<Env<AttrContext>> genList;
      private TaskListener taskListener;
      private AtomicBoolean used = new AtomicBoolean();
      private Iterable<? extends Processor> processors;
  
      private Integer result = null;
  
      JavacTaskImpl(Main compilerMain,
                  String[] args,
                  String[] classNames,
                  Context context,
                  List<JavaFileObject> fileObjects) {
          this.ccw = ClientCodeWrapper.instance(context);
          this.compilerMain = compilerMain;
          this.args = args;
          this.classNames = classNames;
          this.context = context;
          this.fileObjects = fileObjects;
          setLocale(Locale.getDefault());
          // null checks
          compilerMain.getClass();
          args.getClass();
          fileObjects.getClass();
      }
  
      JavacTaskImpl(Main compilerMain,
                  Iterable<String> flags,
                  Context context,
                  Iterable<String> classes,
                  Iterable<? extends JavaFileObject> fileObjects) {
          this(compilerMain, toArray(flags), toArray(classes), context, toList(fileObjects));
      }
  
      static private String[] toArray(Iterable<String> iter) {
          ListBuffer<String> result = new ListBuffer<String>();
          if (iter != null)
              for (String s : iter)
                  result.append(s);
          return result.toArray(new String[result.length()]);
      }
  
      static private List<JavaFileObject> toList(Iterable<? extends JavaFileObject> fileObjects) {
          if (fileObjects == null)
              return List.nil();
          ListBuffer<JavaFileObject> result = new ListBuffer<JavaFileObject>();
          for (JavaFileObject fo : fileObjects)
              result.append(fo);
          return result.toList();
      }
  
      public Boolean call() {
          if (!used.getAndSet(true)) {
              initContext();
              notYetEntered = new HashMap<JavaFileObject, JCCompilationUnit>();
              compilerMain.setAPIMode(true);
              result = compilerMain.compile(args, classNames, context, fileObjects, processors);
              cleanup();
              return result == 0;
          } else {
              throw new IllegalStateException("multiple calls to method 'call'");
          }
      }
  
      public void setProcessors(Iterable<? extends Processor> processors) {
          processors.getClass(); // null check
          // not mt-safe
          if (used.get())
              throw new IllegalStateException();
          this.processors = processors;
      }
  
      public void setLocale(Locale locale) {
          if (used.get())
              throw new IllegalStateException();
          this.locale = locale;
      }
  
      private void prepareCompiler() throws IOException {
          if (used.getAndSet(true)) {
              if (compiler == null)
                  throw new IllegalStateException();
          } else {
              initContext();
              compilerMain.setOptions(Options.instance(context));
              compilerMain.filenames = new LinkedHashSet<File>();
              Collection<File> filenames = compilerMain.processArgs(CommandLine.parse(args), classNames);
              if (!filenames.isEmpty())
                  throw new IllegalArgumentException("Malformed arguments " + toString(filenames, " "));
              compiler = JavaCompiler.instance(context);
              compiler.keepComments = true;
              compiler.genEndPos = true;
              // NOTE: this value will be updated after annotation processing
              compiler.initProcessAnnotations(processors);
              notYetEntered = new HashMap<JavaFileObject, JCCompilationUnit>();
              for (JavaFileObject file: fileObjects)
                  notYetEntered.put(file, null);
              genList = new ListBuffer<Env<AttrContext>>();
              // endContext will be called when all classes have been generated
              // TODO: should handle the case after each phase if errors have occurred
              args = null;
              classNames = null;
          }
      }
  
      <T> String toString(Iterable<T> items, String sep) {
          String currSep = "";
          StringBuilder sb = new StringBuilder();
          for (T item: items) {
              sb.append(currSep);
              sb.append(item.toString());
              currSep = sep;
          }
          return sb.toString();
      }
  
      private void initContext() {
          context.put(JavacTaskImpl.class, this);
          if (context.get(TaskListener.class) != null)
              context.put(TaskListener.class, (TaskListener)null);
          if (taskListener != null)
              context.put(TaskListener.class, ccw.wrap(taskListener));
          //initialize compiler's default locale
          context.put(Locale.class, locale);
      }
  
      void cleanup() {
          if (compiler != null)
              compiler.close();
          compiler = null;
          compilerMain = null;
          args = null;
          classNames = null;
          context = null;
          fileObjects = null;
          notYetEntered = null;
      }
  
      /**
       * Construct a JavaFileObject from the given file.
       *
       * <p><b>TODO: this method is useless here</b></p>
       *
       * @param file a file
       * @return a JavaFileObject from the standard file manager.
       */
      public JavaFileObject asJavaFileObject(File file) {
          JavacFileManager fm = (JavacFileManager)context.get(JavaFileManager.class);
          return fm.getRegularFile(file);
      }
  
      public void setTaskListener(TaskListener taskListener) {
          this.taskListener = taskListener;
      }
  
      /**
       * Parse the specified files returning a list of abstract syntax trees.
       *
       * @throws java.io.IOException TODO
       * @return a list of abstract syntax trees
       */
      public Iterable<? extends CompilationUnitTree> parse() throws IOException {
          try {
              prepareCompiler();
              List<JCCompilationUnit> units = compiler.parseFiles(fileObjects);
              for (JCCompilationUnit unit: units) {
                  JavaFileObject file = unit.getSourceFile();
                  if (notYetEntered.containsKey(file))
                      notYetEntered.put(file, unit);
              }
              return units;
          }
          finally {
              parsed = true;
              if (compiler != null && compiler.log != null)
                  compiler.log.flush();
          }
      }
  
      private boolean parsed = false;
  
      /**
       * Translate all the abstract syntax trees to elements.
       *
       * @throws IOException TODO
       * @return a list of elements corresponding to the top level
       * classes in the abstract syntax trees
       */
      public Iterable<? extends TypeElement> enter() throws IOException {
          return enter(null);
      }
  
      /**
       * Translate the given abstract syntax trees to elements.
       *
       * @param trees a list of abstract syntax trees.
       * @throws java.io.IOException TODO
       * @return a list of elements corresponding to the top level
       * classes in the abstract syntax trees
       */
      public Iterable<? extends TypeElement> enter(Iterable<? extends CompilationUnitTree> trees)
          throws IOException
      {
          prepareCompiler();
  
          ListBuffer<JCCompilationUnit> roots = null;
  
          if (trees == null) {
              // If there are still files which were specified to be compiled
              // (i.e. in fileObjects) but which have not yet been entered,
              // then we make sure they have been parsed and add them to the
              // list to be entered.
              if (notYetEntered.size() > 0) {
                  if (!parsed)
                      parse(); // TODO would be nice to specify files needed to be parsed
  