Enable preview features for versions other than the maximum supported

We are using Java 17 preview features in our projects and would like to analyse them with Sonarqube. Instead of being actually analyzed we just get a lot of “Parse Errors”.

We are sure this is due to preview features not being enabled in the SonarJava plugin. Our way of verifying this was to set the “sonar.java.source” to 18. The analysis did not produce any errors.

As per this Issue [SONARJAVA-4214] - Jira the preview compiler flag is automatically set if the used Java version is equal to the maximum supported Java version of SonarJava.

Are we missing something or is there no way to influence this from the used scanner tool? We had a look at the source code of the SonarJava plugin and to us it looks hard coded. This seems like an oversight to us as we would’ve expected that we could influence this from the outside other than effectively lying about our used java version.

We are currently running SonarQube Community Edition in version 9.8.0

No acknowledgement or any sort of comment on this for almost a week feels kind of weird.

Is this such an outlandish issue/request?

Hey Daniel.

This is a free community forum – and you are running a Community Edition of SonarQube. We care deeply about feedback from our users, but operators are not standing by. Please be patient – it doesn’t mean your report isn’t important to us, it just means that our teams are already hard-at-work developing new language analysis features, and your report is in the queue.

1 Like

Hello Daniel!

In general, the SonarJava plugin does not support preview features. We try to stay up to date with current developments in Java, so are often compatible with the preview features of the latest (and only latest) Java version that is supported by the plugin.

If you would like to use Java 17 preview features, then the easiest solution would indeed be to set sonar.java.source to 18.

Obviously I would prefer a way to configure if preview features were enabled or not I do concede that using an “older” version of Java with enabled preview features might be a rather odd use case.

The solution you proposed might not be my preferred one but doesn’t interfere with anything so we’ll just live with it.

Thanks for looking into this!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.