Java 14 Support?

What exactly does Java 14 support mean with respect to SonarQube 8.5?

  • I have SonarQube 8.5.1 installed along with JDK 14.
  • Client is using JDK 14 to compile.
  • Client code uses the new Java switch statement.

<dependency> <groupId>org.sonarsource.scanner.maven</groupId> <artifactId>sonar-maven-plugin</artifactId> <version>3.7.0.1746</version> </dependency>

However, I’m seeing the following when running mvn sonar:sonar
[ERROR] Unable to parse source file : 'src/main/java/com/xyz/AbstractBaseModel.java' [ERROR] Parse error at line 71 column 21: Switch Expressions are supported from Java 14 onwards only

The most recent version of the sonar scanner, as noted above, was released in Oct 2019 while Java 14 was released in Mar 2020.

So, what exactly does it mean that Java 14 is supported in SonarQube when the scanner is not receiving the necessary updates to provide that support?

Hi,

Welcome to the community!

Are you passing a sonar.java.source value that’s lower than 14 to analysis? Either explicitly or perhaps implicitly by targeting compilation to a lower version?

 
Ann

Thanks. I added <sonar.java.source>14</sonar.java.source> to my pom properties and the error I reported above is gone. Thank you.

I’m now having a similar problem with the checkstyle sensor complaining about the new switch statement syntax:
Can not execute Checkstyle: Exception was thrown while processing ...\AbstractBaseModel.java:IllegalStateException occurred while parsing file AbstractBaseModel.java:71:13: unexpected token: result ->

Hi Ann, and to answer your questions about the version of Java my maven build is targeting I am specifying Java 14 via the compiler plugin:

            <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <release>14</release>
                <compilerId>groovy-eclipse-compiler</compilerId>

Hi,

Thanks for getting back to me.

For the Checkstyle error you’ll need to report that in that project to those maintainers.

 
HTH,
Ann