Esempio n. 1
0
  /** Construct the JobQueue. This is private; use getJobQueue() to get the job queue instance. */
  private JobQueue() {
    // determine which compiler we should be using
    String compilertype = Config.getPropString("bluej.compiler.type");

    // even though it is specified to use internal, the preferred compiler for a
    // system running Java 6 or greater is the JavaCompiler API
    if (compilertype.equals("internal")) {
      if (Config.isJava16()) {
        try {
          Class<?> c = Class.forName("bluej.compiler.CompilerAPICompiler");
          compiler = (Compiler) c.newInstance();
        } catch (Throwable e) {
          Debug.message(
              "Could not instantiate the compiler API compiler implementation; defaulting to old compiler");
          compiler = new JavacCompilerInternal();
        }
      } else {
        compiler = new JavacCompilerInternal();
      }
    } else if (compilertype.equals("javac")) {
      compiler =
          new JavacCompiler(Config.getJDKExecutablePath("bluej.compiler.executable", "javac"));
    } else {
      Debug.message(Config.getString("compiler.invalidcompiler"));
    }

    thread = new CompilerThread();

    // Lower priority to improve GUI response time during compilation
    int priority = Thread.currentThread().getPriority() - 1;
    priority = Math.max(priority, Thread.MIN_PRIORITY);
    thread.setPriority(priority);

    thread.start();
  }
Esempio n. 2
0
 /** Wait until the compiler job queue is empty, then return. */
 public void waitForEmptyQueue() {
   synchronized (thread) {
     while (thread.isBusy()) {
       try {
         thread.wait();
       } catch (InterruptedException ex) {
       }
     }
   }
 }
Esempio n. 3
0
  /**
   * Adds a job to the compile queue.
   *
   * @param sources The files to compile
   * @param observer Observer to be notified when compilation begins, errors/warnings, completes
   * @param classPath The classpath to use to locate objects/source code
   * @param destDir Destination for class files?
   * @param suppressUnchecked Suppress "unchecked" warning in java 1.5
   */
  public void addJob(
      File[] sources,
      CompileObserver observer,
      BPClassLoader bpClassLoader,
      File destDir,
      boolean suppressUnchecked) {
    List<String> options = new ArrayList<String>();
    if (bpClassLoader.loadsForJavaMEproject()) {
      String optionString = Config.getPropString(Compiler.JAVAME_COMPILER_OPTIONS, null);
      Compiler.tokenizeOptionString(options, optionString);
    }
    String optionString = Config.getPropString(Compiler.COMPILER_OPTIONS, null);
    Compiler.tokenizeOptionString(options, optionString);

    thread.addJob(
        new Job(sources, compiler, observer, bpClassLoader, destDir, suppressUnchecked, options));
  }