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
  /**
   * 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));
  }
Esempio n. 3
0
  /**
   * Return a property associated with this extension from the standard BlueJ property repository.
   * You must use the setExtensionPropertyString to write any property that you want stored. You can
   * then come back and retrieve it using this function.
   *
   * @param property The name of the required global property.
   * @param def The default value to use if the property cannot be found.
   * @return the value of that property.
   */
  public String getExtensionPropertyString(String property, String def) {
    if (!myWrapper.isValid()) throw new ExtensionUnloadedException();

    String thisKey = myWrapper.getSettingsString(property);
    return Config.getPropString(thisKey, def);
  }
Esempio n. 4
0
  /**
   * Returns a property from BlueJ's properties, or the given default value if the property is not
   * currently set.
   *
   * @param property The name of the required global property
   * @param def The default value to use if the property cannot be found.
   * @return the value of the property.
   */
  public String getBlueJPropertyString(String property, String def) {
    if (!myWrapper.isValid()) throw new ExtensionUnloadedException();

    return Config.getPropString(property, def);
  }