Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-3588

Java Analyzer should be able to parse Jigsaw module-info.java files even when misconfigured

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.10
    • Component/s: Parser
    • Labels:

      Description

      If the java version property (sonar.java.version) is misconfigured and forces a java version <= Java 8, then the analyzer fails at parsing module-info.java files.

      For example, when parsing this file :

      module com.foo {
        requires com.google.guava;
      	
        exports org.foo;
      }
      

      These error messages appears in the log:

      [INFO] Configured Java source version (sonar.java.source): 8
      ...
      [ **ERROR** ] Unable to parse source file : 'module1/src/main/java/module-info.java'
      [ **ERROR** ] Parse error at line 1 column 0: Syntax error on token "module", package expected
      

      Having module-info.java files can only exists in java 9+ projects. Encountering such files in analysis while being forced a java 8 version is therefore unexpected.

      • The analyzer should not fail parsing (we know how to parse them)
      • The analyzer should emit a warning (logs) about misconfiguration

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                michael.gumowski Michael Gumowski
                Reporter:
                margarita.nedzelska Margarita Nedzelska
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: