As in title.
using bazel-0.20.0-dist.zip
$ javac -version
javac 11.0.1
$
~/bazel$ ./compile.sh
...
ERROR: /home/user/bazel/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/BUILD:16:1: Building src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/libdependency.jar (3 source files) and running annotation processors (AutoAnnotationProcessor, AutoValueProcessor) failed (Exit 1): java failed: error executing command
(cd /tmp/bazel_scmN19fC/out/execroot/io_bazel && \
exec env - \
LC_CTYPE=en_US.UTF-8 \
external/embedded_jdk/bin/java -Xverify:none -Xmx512m -XX:+TieredCompilation '-XX:TieredStopAtLevel=1' -jar bazel-out/host/bin/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/bootstrap_VanillaJavaBuilder_deploy.jar @bazel-out/k8-opt/bin/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/libdependency.jar-0.params)
Execution platform: @bazel_tools//platforms:host_platform
src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/StrictJavaDepsPlugin.java:180: error: incompatible types: int cannot be converted to com.sun.tools.javac.code.Lint.LintCategory
note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
Target //src:bazel_nojdk failed to build
ERROR: /home/user/bazel/src/java_tools/buildjar/java/com/google/devtools/build/java/turbine/BUILD:3:1 Building src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/libdependency.jar (3 source files) and running annotation processors (AutoAnnotationProcessor, AutoValueProcessor) failed (Exit 1): java failed: error executing command
(cd /tmp/bazel_scmN19fC/out/execroot/io_bazel && \
exec env - \
LC_CTYPE=en_US.UTF-8 \
external/embedded_jdk/bin/java -Xverify:none -Xmx512m -XX:+TieredCompilation '-XX:TieredStopAtLevel=1' -jar bazel-out/host/bin/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/bootstrap_VanillaJavaBuilder_deploy.jar @bazel-out/k8-opt/bin/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/libdependency.jar-0.params)
Execution platform: @bazel_tools//platforms:host_platform
INFO: Elapsed time: 57.769s, Critical Path: 50.25s
INFO: 1350 processes: 1179 local, 171 worker.
FAILED: Build did NOT complete successfully
ERROR: Could not build Bazel
~/bazel$
Debian GNU/Linux, testing, amd64
ii openjdk-11-jdk:amd64 11.0.1+13-2
Using openjdk-8-jdk works, but bazel is the only dependency on my system that would need JDK 8, and I do not want to mess with my paths to compiler and libraries all the time in command line.
Line 180 is this:
log.warning(diagnostic.pos(), "proc.messager", diagnostic.message());
extra context:
switch (dependencyModule.getStrictJavaDeps()) {
case ERROR:
log.error(diagnostic.pos(), "proc.messager", diagnostic.message());
break;
case WARN:
log.warning(diagnostic.pos(), "proc.messager", diagnostic.message()); // Line 180
break;
I believe this is because javac.util.AbstractLog has a bunch of new methods:
class AbstractLog {
// ...
/** Report a warning, unless suppressed by the -nowarn option or the
* maximum number of warnings has been reached.
* @param key The key for the localized warning message.
* @param args Fields of the warning message.
*/
public void warning(String key, Object ... args) {
report(diags.warning(source, null, key, args));
}
/** Report a lint warning, unless suppressed by the -nowarn option or the
* maximum number of warnings has been reached.
* @param lc The lint category for the diagnostic
* @param key The key for the localized warning message.
* @param args Fields of the warning message.
*/
public void warning(LintCategory lc, String key, Object ... args) {
report(diags.warning(lc, key, args));
}
/** Report a warning, unless suppressed by the -nowarn option or the
* maximum number of warnings has been reached.
* @param pos The source position at which to report the warning.
* @param key The key for the localized warning message.
* @param args Fields of the warning message.
*/
public void warning(DiagnosticPosition pos, String key, Object ... args) {
report(diags.warning(source, pos, key, args));
}
/** Report a lint warning, unless suppressed by the -nowarn option or the
* maximum number of warnings has been reached.
* @param lc The lint category for the diagnostic
* @param pos The source position at which to report the warning.
* @param key The key for the localized warning message.
* @param args Fields of the warning message.
*/
public void warning(LintCategory lc, DiagnosticPosition pos, String key, Object ... args) {
report(diags.warning(lc, source, pos, key, args));
}
/** Report a warning, unless suppressed by the -nowarn option or the
* maximum number of warnings has been reached.
* @param pos The source position at which to report the warning.
* @param key The key for the localized warning message.
* @param args Fields of the warning message.
*/
public void warning(int pos, String key, Object ... args) {
report(diags.warning(source, wrap(pos), key, args));
...
}
And the problem is that diagnostic is defined as:
@AutoValue
abstract static class SjdDiagnostic {
abstract int pos();
...
I am not sure why compiler has issue selecting overload, as the last method matches exactly. But I know little about Java anyway.
BTW. LintCategory is an enum.
Maybe this is because of this https://hg.openjdk.java.net/jdk/jdk11/rev/ef3557eb4306 ?
public void warning(int pos, String key, Object ... args) {
was in fact removed
Only option now is usage one of these methods:
public void warning(Warning warningKey) {
public void warning(LintCategory lc, Warning warningKey) {
public void warning(DiagnosticPosition pos, Warning warningKey) {
public void warning(LintCategory lc, DiagnosticPosition pos, Warning warningKey) {
public void warning(int pos, Warning warningKey) {
public void warning(DiagnosticPosition pos, Warning warningKey) {
The compiler probably selects overload based on a number of arguments first (because there are no more variadic methods here), and this matches only warning(LintCategory lc, DiagnosticPosition pos, Warning warningKey)
One of the options to get a Warning for warningKey is using a Factory provided
public class JCDiagnostic implements Diagnostic<JavaFileObject> {
/** A factory for creating diagnostic objects. */
public static class Factory {
// ....
Warning warningKey(String code, Object... args);`
// ...
or using Warning constructor directly ( https://hg.openjdk.java.net/jdk/jdk11/file/ef3557eb4306/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JCDiagnostic.java#l561 )
public class JCDiagnostic implements Diagnostic<JavaFileObject> {
/// ...
public static final class Warning extends DiagnosticInfo {
public Warning(String prefix, String key, Object... args);
/// ...
cc @lberki @iirina @meisterT @dslomov
I believe this is working now, right? We're testing on Ubuntu 18.04 with OpenJDK 11 as the system JDK and bootstrap seems to work fine.
I successfully bootstraped bazel using bazel-1.2.1-dist.zip and using javac 11.0.5.
Documentation at https://docs.bazel.build/versions/master/install-compile-source.html#bootstrap-bazel should see an update, and suggest using openjdk-11-jdk, if possible, instead of current docs asking for openjdk-8-jdk.
I also noticed a separate issue, ./output/bazel bazel build //scripts:bazel-complete.bash downloading a Zulu JDK11. That is kind of silly if you ask me, when my OS JDK is probably sufficient.
Thank you.
This seems to have been fixed by:
https://github.com/bazelbuild/bazel/commit/d72d306d0ee8c0844f4212dc966b4e0b0cefb6cf
Can this bug now be closed? We've just had a bug filed against java-11-openjdk (https://bugzilla.redhat.com/show_bug.cgi?id=1761048) with regards to this issue, when the problem actually seems to have been with Babel using the old API.
@gnu-andrew Yes, I'll send a PR to re-enable the bootstrap test with Java 11 that will close this issue if it passes presubmit and gets merged. Thanks for reminding us that this has been fixed!