NullPointerException when analyzing Java 14 code (record)

I’m trying to analyze a Maven-based Java 14 project via SonarCloud. It all started with this issue:

After the recent announcement on Java 14 support, I re-ran the builds but I’m still facing the following error:

2020-07-29T20:23:02.7430662Z [ERROR] 20:23:02.741 Unable to run check class org.sonar.java.Measurer -  on file 'src/main/java/com/github/beatngu13/knapsackproblem/so/ga/ItemGene.java', To help improve the SonarSource Java Analyzer, please report this problem to SonarSource: see https://community.sonarsource.com/
2020-07-29T20:23:02.7434374Z java.lang.NullPointerException: null

Debug-enabled logs can be found here.

As can be seen in the build configuration, I’m using the following command to run the build/analysis:

mvn --batch-mode verify sonar:sonar -Pcoverage -X
        -Dsonar.host.url=https://sonarcloud.io
        -Dsonar.organization=beatngu13-github
        -Dsonar.projectKey=com.github.beatngu13:knapsack-problem
        -Dsonar.java.source=14
        -Dsonar.java.target=14

Since I don’t know how to proceed from here, I’m following @dmeneses suggestion to open this issue.

Hi Daniel,

Sorry about the accuracy of the announcement and the wasted time. Our java analyzer does support Java 14 and it does not support Java 14 preview features like Records.
I analyzed the branch java-14 of your project github.com/beatngu13/knapsack-problem and I created:

  • SONARJAVA-3487 [Java 14 - Records preview feature] NPE when accessing recordComponent.owner()
  • SONARJAVA-3488 [Java 14 - Records preview feature] NPE when computing metrics of methods
  • SONARJAVA-3489 [Java 14 - Records preview feature] S1123 NPE when visiting records
  • SONARJAVA-3490 [Java 14 - Records preview feature] S1117 NPE when visiting records

Furthermore, Records will still be a preview feature of Java 15, so our priority will be to support Java 15 before supporting Java 15 preview features.

Thanks for your feedback,
Alban

2 Likes

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