Unable to parse java source file using lombok

Hi,

We use SonarQube 8.5, Scanner 3.0 and the gradle plugin, Java11, gradle 6.7 on macOS 10.15.7.

When performing a scan a NullPointerException is thrown:

stacktrace.txt (16.8 KB)

The error can be reproduced with the attached gradle project: sq_bug.zip (59.8 KB)

If you uncomment the commented code the Exception will not be thrown.

Could it be a bug in the java scanner?

Hey Christian,

Thanks a lot for the feedback and the invaluable reproducer!

I reproduced the issue on my side and created the following ticket on our Java Analyzer to try to fix it: SONARJAVA-3607.

This is definitely a bug, which will probably be quite tricky to fix. Lombok is tricking the ECJ parser here, apparently because the static constructors of(), generated in bytecode thanks to the Lombok annotation, are not visible from within the class declaration itself, although being in the same compilation unit as the rest of the code.

We will see what we can do! In the meantime, only the file causing this parse error will be skipped during your analysis.

Cheers,
Michael

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