Uploaded image for project: 'SonarLint For IntelliJ'
  1. SonarLint For IntelliJ
  2. SLI-384

Some Java issues are not reported because wrong JDK classpath is used

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.9
    • Component/s: Java analysis
    • Labels:
      None

      Description

      Analyzing a Java file requires to provide its classpath to the Java analyzer (sonar.java.libraries). Since we are not passing rt.jar/jrt-fs.jar, the Java analyzer will fallback and use runtime JRE/JDK classes, which might not contains the same things.

      I have created 2 sample projects to exhibit the problem:

      • open the project in an IntelliJ having a Java 11 runtime
      • assign a JDK 8 to the first module
      • assign a JDK 13 to the second module


      • enable rule java:S4551

      In the first module (compiler with JDK 8), issue is not raised because the enum AWTUtilities.Translucency was removed in JDK 11, and because our Java analyzer is using the runtime JDK (11) it can't resolve the type.

      In the second module (compiled with JDK 13), issue is not raised because the enum value Tree.Kind.SWITCH_EXPRESSION was introduced in JDK 12, and because our analyzer is using the runtime JDK (11) it can't resolve the type.

        Attachments

        1. image-2020-04-10-14-12-51-820.png
          44 kB
          Julien Henry
        2. image-2020-04-10-14-14-20-510.png
          10 kB
          Julien Henry
        3. image-2020-04-10-14-14-43-074.png
          24 kB
          Julien Henry
        4. image-2020-04-10-14-14-59-287.png
          24 kB
          Julien Henry

          Issue Links

            Activity

              People

              Assignee:
              julien.henry Julien Henry
              Reporter:
              julien.henry Julien Henry
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: