Gradle Plugin warning/error on Java 15

I am running gradle on bitbucket with the command bash ./gradlew build sonarqube --stacktrace and
I am getting the error below.

> Task :sonarqube
Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared methods java.lang.NullPointerException: Cannot read the array length because "internalMembers" is null

I am still seeing the analysis results in sonar cloud but not sure what’s breaking. Does sonar support Java 15?

Hey there.

Java 15 is not yet supported – you can find more details about what dependencies we’re waiting on at SONARJAVA-3505. :crossed_fingers: for early next year.

1 Like

So if I understand correctly the analyzer runs JDT from eclipse and therefore you need that to support Java 15. Is the issue running JDT on Java 15 vs. running JDT on java 11 but JDT supporting Java 15 syntax? I am running Java gradle on Java 15 JVM.

In my case the gradle build is not failing so I assume I am getting partial results in sonar cloud.

Questions:

  • Is there a way to find how much of the analysis is not being done?
  • If I run the analyzer on Java 11 will it work with Java 15 sources and compiled bytecode?
  • are you planning to support gradle toolchains?

Hey there.

To be honest, I have no clue how our scanners behave running on Java 15 (only Java 11 is officially supported, but we try and keep compatibility with newer versions of Java). There have been no other reports of issues using the scanner with Java 15, and the log message you showed would be one it throws specifically during Java analysis (not running analysis overaell)

Java 15-specific syntax is definitely not yet supported.

Adding --debug to your Gradle command will show a lot more logs, and may give you some confidence that it’s just happening on a single file vs. many.

In the future, yes – as far as I’m aware you should be able to analyze Java 15 code (run the scanner) with Java 11.

I don’t know! I’ll ping the right person internally, and maybe they can take a look at the docs.

Hi @Colin_SonarSource and @asaikali at first glance it looks like a great tool to utilise, so I created https://jira.sonarsource.com/browse/SONARGRADL-72 to get support for this implemented.

Thanks for ticket to add toolchains it really makes things simpler for users like me. I have reviewed my CI pipeline logs and it seems that I am getting the warning even before I upgraded to Java 15, even when running on Java 11.

+ java --version
openjdk 11.0.9 2020-10-20
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9+11)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9+11, mixed mode)
> Task :sonarqube
Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared methods java.lang.NullPointerException
BUILD SUCCESSFUL in 6m 4s
128 actionable tasks: 128 executed
1 Like

Does that issue has fixed?

I got the same error with Java 11 (AdoptOpenJDK):
Task :sonarqube
Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared methods java.lang.NullPointerException