﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
19631	Compilation fails when javac is 8 and java is 11	matthijs	team	"I just tried compiling josm (current trunk r16846), by runing {{{ant}}} in the root of a repository checkout. This failed with:

{{{
    [javac] Compiling 1629 source files to /home/matthijs/docs/src/upstream/josm/build   
    [javac]                                                                    
    [javac]  
    [javac] A plugin threw an uncaught exception.
    [javac] Consult the following stack trace for details.
    [javac] java.lang.NoSuchMethodError: com.sun.tools.javac.util.JavacMessages.add(Lcom/sun/tools/javac/util/JavacMessages$ResourceBundleHelper;)V
    [javac]     at com.google.errorprone.BaseErrorProneJavaCompiler.setupMessageBundle(BaseErrorProneJavaCompiler.java:200)
    [javac]     at com.google.errorprone.ErrorProneJavacPlugin.init(ErrorProneJavacPlugin.java:40)
    [javac]     at com.sun.tools.javac.main.Main.compile(Main.java:470)
    [javac]     at com.sun.tools.javac.main.Main.compile(Main.java:381)
    [javac]     at com.sun.tools.javac.main.Main.compile(Main.java:370)                                                                                        
    [javac]     at com.sun.tools.javac.main.Main.compile(Main.java:361)                                                                                        
    [javac]     at com.sun.tools.javac.Main.compile(Main.java:56)                                                                                              
    [javac]     at com.sun.tools.javac.Main.main(Main.java:42)
                                                                               
BUILD FAILED 
/home/matthijs/docs/src/upstream/josm/build.xml:275: Compile failed; see the compiler error output for details.
}}}

A little digging shows that this error occurs on JDK8 and [https://github.com/google/error-prone/issues/535#issuecomment-411965977 should be fixed] by this line from `build.xml`:

{{{
            <compilerarg value=""-J-Xbootclasspath/p:${toString:errorprone_javac.classpath}"" unless:set=""isJava9""/>
}}}

The problem turns out to be that my Java is version 11, but javac is version 8.

{{{
matthijs@grubby:~/docs/src/upstream/josm$ javac -fullversion
javac full version ""1.8.0_252-8u252-b09-1~19.10-b09""
matthijs@grubby:~/docs/src/upstream/josm$ java -fullversion
openjdk full version ""11.0.7+10-post-Ubuntu-2ubuntu219.10""
}}}

The {{{isJava9}}} check in the line above is against the java version, not the javac version, but this particular line should be applied based on the javac version, not the java version. Removing the ""unless"" tag from the above line makes the build complete succesfully for me.

Alternatively, just installing the {{{openjdk-11-jdk}}} Ubuntu package makes my java and javac version equal  and also fixes compilation.

Ideally, the javac version would be checked here instead of the java version, but I'm not sure how easy that is with ant. If not, this is not really important to fix, but having this bug report would at least point others to a fix."	defect	closed	normal		unspecified	latest	fixed		matthijs
