Allow specification of an alternate javac location.
Review Request #4124 — Created July 26, 2016 and submitted
Currently we always use the javac embedded in the JDK Zinc runs on.
This change supports experimenting with unreleased compiler versions
without having to use an unreleased, and possibly unstable, runtime.
Specifically, this allows running the (relatively stable but still unreleased)
javac 9 compiler on a Java 8 runtime, something that Bazel currently supports.
Note that this change also removes the explicit adding of tools.jar to the classpath,
since Zinc does this anyway (via
it doesn't find a compiler on the bootclasspath.
Note also that this does not support introducing alternate entry points
(such as would be required to use errorprone). The entry point must still
com.sun.tools.javac.api.JavacTool. All this change does is allow that
class to be loaded from somewhere outside the JDK's tools.jar.
Supporting alternate entry points will require changing how Zinc locates
the JavaCompiler implementation it uses. As mentioned above, it currently
javax.tools.ToolProvider.getSystemJavaCompiler, which locates
com.sun.tools.javac.api.JavacTool. But it would be pretty easy to add
a flag to zinc that names some other implementer of
This change also:
- Removes a comment that was obsoleted long ago, in b15a7cbb to be precise.
- Fixes a couple of references to a non-public member of a base class.
CI passes: https://travis-ci.org/pantsbuild/pants/builds/147580570