src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java

changeset 946
31e5cfc5a990
parent 944
83260b3305ac
child 1055
7337295434b6
     1.1 --- a/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Fri Mar 25 07:39:30 2011 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Fri Mar 25 07:58:53 2011 -0700
     1.3 @@ -65,7 +65,7 @@
     1.4   * @author Jonathan Gibbons
     1.5   */
     1.6  public class JavacTaskImpl extends JavacTask {
     1.7 -    private JavacTool tool;
     1.8 +    private ClientCodeWrapper ccw;
     1.9      private Main compilerMain;
    1.10      private JavaCompiler compiler;
    1.11      private Locale locale;
    1.12 @@ -80,12 +80,11 @@
    1.13  
    1.14      private Integer result = null;
    1.15  
    1.16 -    JavacTaskImpl(JavacTool tool,
    1.17 -                Main compilerMain,
    1.18 +    JavacTaskImpl(Main compilerMain,
    1.19                  String[] args,
    1.20                  Context context,
    1.21                  List<JavaFileObject> fileObjects) {
    1.22 -        this.tool = tool;
    1.23 +        this.ccw = ClientCodeWrapper.instance(context);
    1.24          this.compilerMain = compilerMain;
    1.25          this.args = args;
    1.26          this.context = context;
    1.27 @@ -94,17 +93,15 @@
    1.28          // null checks
    1.29          compilerMain.getClass();
    1.30          args.getClass();
    1.31 -        context.getClass();
    1.32          fileObjects.getClass();
    1.33      }
    1.34  
    1.35 -    JavacTaskImpl(JavacTool tool,
    1.36 -                Main compilerMain,
    1.37 +    JavacTaskImpl(Main compilerMain,
    1.38                  Iterable<String> flags,
    1.39                  Context context,
    1.40                  Iterable<String> classes,
    1.41                  Iterable<? extends JavaFileObject> fileObjects) {
    1.42 -        this(tool, compilerMain, toArray(flags, classes), context, toList(fileObjects));
    1.43 +        this(compilerMain, toArray(flags, classes), context, toList(fileObjects));
    1.44      }
    1.45  
    1.46      static private String[] toArray(Iterable<String> flags, Iterable<String> classes) {
    1.47 @@ -131,7 +128,7 @@
    1.48          if (!used.getAndSet(true)) {
    1.49              initContext();
    1.50              notYetEntered = new HashMap<JavaFileObject, JCCompilationUnit>();
    1.51 -            compilerMain.setFatalErrors(true);
    1.52 +            compilerMain.setAPIMode(true);
    1.53              result = compilerMain.compile(args, context, fileObjects, processors);
    1.54              cleanup();
    1.55              return result == 0;
    1.56 @@ -185,32 +182,10 @@
    1.57          if (context.get(TaskListener.class) != null)
    1.58              context.put(TaskListener.class, (TaskListener)null);
    1.59          if (taskListener != null)
    1.60 -            context.put(TaskListener.class, wrap(taskListener));
    1.61 +            context.put(TaskListener.class, ccw.wrap(taskListener));
    1.62          //initialize compiler's default locale
    1.63          context.put(Locale.class, locale);
    1.64      }
    1.65 -    // where
    1.66 -    private TaskListener wrap(final TaskListener tl) {
    1.67 -        tl.getClass(); // null check
    1.68 -        return new TaskListener() {
    1.69 -            public void started(TaskEvent e) {
    1.70 -                try {
    1.71 -                    tl.started(e);
    1.72 -                } catch (Throwable t) {
    1.73 -                    throw new ClientCodeException(t);
    1.74 -                }
    1.75 -            }
    1.76 -
    1.77 -            public void finished(TaskEvent e) {
    1.78 -                try {
    1.79 -                    tl.finished(e);
    1.80 -                } catch (Throwable t) {
    1.81 -                    throw new ClientCodeException(t);
    1.82 -                }
    1.83 -            }
    1.84 -
    1.85 -        };
    1.86 -    }
    1.87  
    1.88      void cleanup() {
    1.89          if (compiler != null)

mercurial