Modify

Opened 5 years ago

Closed 18 months ago

#19631 closed defect (fixed)

Compilation fails when javac is 8 and java is 11

Reported by: matthijs Owned by: team
Priority: normal Milestone:
Component: unspecified Version: latest
Keywords: Cc: matthijs

Description

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 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.

Attachments (0)

Change History (1)

comment:1 by stoecker, 18 months ago

Resolution: fixed
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.