Пример #1
0
 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'");
   }
 }
Пример #2
0
 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;
   }
 }
Пример #3
0
 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();
 }