[ERROR] When update sourceCompatibility and targetCompatibility to JavaVersion.VERSION_11

Hi sonar team!
I encountered with a very strange problem when I try to update my project’s java version

  • CI system used: Local, Travis CI
  • Scanner command used: ./gradlew sonar
  • Plugin: org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:4.3.0.3225
  • Languages of the repository: Java (Android)
  • Only thing I changed is
java {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

to

java {
    sourceCompatibility = JavaVersion.VERSION_11
    targetCompatibility = JavaVersion.VERSION_11
}

Environment for both runs (JavaVersion.VERSION_1_8 and JavaVersion.VERSION_11):

openjdk 11.0.14.1 2022-02-08
OpenJDK Runtime Environment JBR-11.0.14.1.1-2043.17-jcef (build 11.0.14.1+1-b2043.17)
OpenJDK 64-Bit Server VM JBR-11.0.14.1.1-2043.17-jcef (build 11.0.14.1+1-b2043.17, mixed mode)

Only sonar task affects, everything else works fine (tests, builds).
And that’s enough to get very long error stack trace (only very small part of it)

The property 'sonar.login' is deprecated and will be removed in the future. Please use the 'sonar.token' property instead when passing a token.
The version of Java (11.0.14.1) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17.
Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared methods org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(347) The type java.lang.Runnable cannot be resolved. It is indirectly referenced from required type io.reactivex.rxjava3.core.Flowable
ECJ Unable to resolve type android.content.ContentProvider
org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(347) The type java.lang.String cannot be resolved. It is indirectly referenced from required type android.content.ContentProvider
        at org.eclipse.jdt.internal.compiler.problem.ProblemHandler.handle(ProblemHandler.java:162)
        at org.eclipse.jdt.internal.compiler.problem.ProblemHandler.handle(ProblemHandler.java:229)
        at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.handle(ProblemReporter.java:2679)
        at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.isClassPathCorrect(ProblemReporter.java:5167)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromCompoundName(LookupEnvironment.java:1794)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromConstantPoolName(LookupEnvironment.java:1824)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromConstantPoolName(LookupEnvironment.java:1832)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromSignature(LookupEnvironment.java:1902)
        at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createMethod(BinaryTypeBinding.java:1022)
        at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createMethods(BinaryTypeBinding.java:1215)
        at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.cachePartsFrom(BinaryTypeBinding.java:618)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:1058)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:1039)
        at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:308)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:329)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getType(LookupEnvironment.java:1737)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getType(LookupEnvironment.java:1704)
        at org.eclipse.jdt.core.dom.ASTUtils.resolveType(ASTUtils.java:60)
        at org.sonar.java.model.JSema.resolveType(JSema.java:140)
        at org.sonar.java.model.JSema.lambda$getClassType$8(JSema.java:123)
        at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1134)
        at org.sonar.java.model.JSema.getClassType(JSema.java:122)
        at org.sonar.java.model.JType.isSubtypeOf(JType.java:60)
        at com.sonar.security.frontend.java.B.C(na:386)
        at com.sonar.security.frontend.java.B.A(na:1438)
        at com.sonar.security.frontend.java.F.A(na:2793)
        at com.sonar.security.frontend.java.F.A(na:510)
        at com.sonar.security.frontend.java.F.buildUCfg(na:3134)
        at com.sonar.security.frontend.java.F.serializeUCFG(na:2702)
        at com.sonar.security.frontend.java.F.visitMethod(na:1755)
        at org.sonar.java.model.declaration.MethodTreeImpl.accept(MethodTreeImpl.java:231)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:40)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:34)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitClass(BaseTreeVisitor.java:70)
        at com.sonar.security.frontend.java.F.visitClass(na:2980)
        at org.sonar.java.model.declaration.ClassTreeImpl.accept(ClassTreeImpl.java:242)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:40)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:34)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitCompilationUnit(BaseTreeVisitor.java:52)
        at org.sonar.java.model.JavaTree$CompilationUnitTreeImpl.accept(JavaTree.java:196)
        at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:40)
        at com.sonar.security.frontend.java.F.scanFile(na:2491)
        at com.sonar.security.frontend.java.rules.A.scanFile(na:72)
        at org.sonar.java.model.VisitorsBridge.lambda$runScanner$1(VisitorsBridge.java:260)
        at org.sonar.java.model.VisitorsBridge.runScanner(VisitorsBridge.java:265)
        at org.sonar.java.model.VisitorsBridge.runScanner(VisitorsBridge.java:260)
        at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:243)
        at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:132)
        at org.sonar.java.JavaFrontend.scanAsBatchCallback(JavaFrontend.java:246)
        at org.sonar.java.JavaFrontend.lambda$scanBatch$0(JavaFrontend.java:237)
        at org.sonar.java.model.JParserConfig$Batch$1.acceptAST(JParserConfig.java:181)
        at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1143)
        at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:739)
        at org.eclipse.jdt.core.dom.ASTParser.createASTs(ASTParser.java:1049)
        at org.sonar.java.model.JParserConfig$Batch.parse(JParserConfig.java:165)
        at org.sonar.java.JavaFrontend.scanBatch(JavaFrontend.java:237)
        at org.sonar.java.JavaFrontend.scanInBatches(JavaFrontend.java:227)
        at org.sonar.java.JavaFrontend.scanAsBatch(JavaFrontend.java:194)
        at org.sonar.java.JavaFrontend.scan(JavaFrontend.java:169)
        at org.sonar.plugins.java.JavaSensor.execute(JavaSensor.java:113)
        at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:62)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:75)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:48)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:66)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:48)
        at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:64)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
        at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:468)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:464)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:461)
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:420)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
        at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:128)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
        at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:57)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:51)
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
        at com.sun.proxy.$Proxy119.execute(Unknown Source)
        at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
        at org.sonarqube.gradle.SonarTask.run(SonarTask.java:131)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:58)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:51)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:29)
        at org.gradle.api.internal.tasks.execution.TaskExecution$3.run(TaskExecution.java:242)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
        at org.gradle.api.internal.tasks.execution.TaskExecution.executeAction(TaskExecution.java:227)
        at org.gradle.api.internal.tasks.execution.TaskExecution.executeActions(TaskExecution.java:210)
        at org.gradle.api.internal.tasks.execution.TaskExecution.executeWithPreviousOutputFiles(TaskExecution.java:193)
        at org.gradle.api.internal.tasks.execution.TaskExecution.execute(TaskExecution.java:171)
        at org.gradle.internal.execution.steps.ExecuteStep.executeInternal(ExecuteStep.java:89)
        at org.gradle.internal.execution.steps.ExecuteStep.access$000(ExecuteStep.java:40)
        at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:53)
        at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:50)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:50)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:40)
        at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:68)
        at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:38)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:48)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:36)
        at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:41)
        at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:74)
        at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:55)
        at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:51)
        at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:29)
        at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:61)
        at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:42)
        at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:60)
        at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:27)
        at org.gradle.internal.execution.steps.BuildCacheStep.executeWithoutCache(BuildCacheStep.java:180)
        at org.gradle.internal.execution.steps.BuildCacheStep.lambda$execute$1(BuildCacheStep.java:75)
        at org.gradle.internal.Either$Right.fold(Either.java:175)
        at org.gradle.internal.execution.caching.CachingState.fold(CachingState.java:59)
        at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:73)
        at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:48)
        at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:36)
        at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:25)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:36)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:22)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:110)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$2(SkipUpToDateStep.java:56)
        at java.base/java.util.Optional.orElseGet(Optional.java:369)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:56)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:38)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:73)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:44)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:37)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:27)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:89)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:50)
        at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:114)
        at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:57)
        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:76)
        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:50)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.executeWithNoEmptySources(SkipEmptyWorkStep.java:249)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:86)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:54)
        at org.gradle.internal.execution.steps.RemoveUntrackedExecutionStateStep.execute(RemoveUntrackedExecutionStateStep.java:32)
        at org.gradle.internal.execution.steps.RemoveUntrackedExecutionStateStep.execute(RemoveUntrackedExecutionStateStep.java:21)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:38)
        at org.gradle.internal.execution.steps.LoadPreviousExecutionStateStep.execute(LoadPreviousExecutionStateStep.java:43)
        at org.gradle.internal.execution.steps.LoadPreviousExecutionStateStep.execute(LoadPreviousExecutionStateStep.java:31)
        at org.gradle.internal.execution.steps.AssignWorkspaceStep.lambda$execute$0(AssignWorkspaceStep.java:40)
        at org.gradle.api.internal.tasks.execution.TaskExecution$4.withWorkspace(TaskExecution.java:287)
        at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:40)
        at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:30)
        at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:37)
        at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:27)
        at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:44)
        at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:33)
        at org.gradle.internal.execution.impl.DefaultExecutionEngine$1.execute(DefaultExecutionEngine.java:76)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:144)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:133)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:77)
        at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
        at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:74)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:333)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:320)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:313)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:299)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:143)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:227)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:218)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:140)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)

Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve interfaces org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(347) The type java.lang.String cannot be resolved. It is indirectly referenced from required type androidx.recyclerview.widget.ItemTouchHelper
Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared methods org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(347) The type java.lang.String cannot be resolved. It is indirectly referenced from required type androidx.fragment.app.FragmentActivity.HostCallbacks
Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared methods org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(347) The type java.lang.String cannot be resolved. It is indirectly referenced from required type android.content.Intent.ShortcutIconResource
Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared methods org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(347) The type java.lang.String cannot be resolved. It is indirectly referenced from required type androidx.recyclerview.widget.LinearLayoutManager.LayoutState
Error while generating IR for method createProductItem at file /Users/path_to_app/app/src/main/java/package/item/DefaultProductItemFactory.java
org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(347) The type java.lang.String cannot be resolved. It is indirectly referenced from required type com.xwray.groupie.GroupieViewHolder
        at org.eclipse.jdt.internal.compiler.problem.ProblemHandler.handle(ProblemHandler.java:162)
        at org.eclipse.jdt.internal.compiler.problem.ProblemHandler.handle(ProblemHandler.java:229)
        at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.handle(ProblemReporter.java:2679)

Here is an example of a project that reproduces this problem:

Hello @protoshadowmaker,

Thanks for the message and welcome to the community. It seems to me as a problem with a compiler, but I need to double-check. From your side, I’d love to see full analysis logs. And is it possible to have a reproducer without Android?

Also, I cloned the project but for some reason, I don’t have permission to the Gradle wrapper, could you, please double-check what attributes the files have, so I can proceed with your reproducer?

Best,
Margarita

Thanks for your reply.
Unfortunately I can share fully only reproducer log (check the attachments), but in the production app the log has the same similarities: full of The type java.lang.String cannot be resolved errors in all places where String is used.
I’ve fixed reproducer, now it works correctly, check it out again please (gradlew wasn’t executable, my mistake, built reproducer on PC and didn’t check it on *nix systems)
I don’t think it’s possible to reproduce this problem without Android, guess the problem somewhere in compatibility between Android and Sonar but honestly I’ve not checked it yet.
One more thing to successfully run ./gradlew sonar: make sure you created sonar-project.properties file in the root project directory with valid sonar.token=TOKEN property.


consoleout.txt (23.1 KB)
Regards, Yauhen

UPD: I’ve just tried to reproduce on pure java gradle project with 2 options

compileJava {
    sourceCompatibility JavaVersion.VERSION_11.toString()
    targetCompatibility JavaVersion.VERSION_11.toString()
}

and

compileJava {
    sourceCompatibility JavaVersion.VERSION_1_8.toString()
    targetCompatibility JavaVersion.VERSION_1_8.toString()
}

In both variants ./gradlew sonar works correct, without any errors. But there is a difference between Android and pure Java project - sourceCompatibility and targetCompatibility properties set in different places. For Android:

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
}

For Java:

compileJava {
    sourceCompatibility JavaVersion.VERSION_1_8.toString()
    targetCompatibility JavaVersion.VERSION_1_8.toString()
}

I think this detail matter and we can’t just ignore it and try to reproduce this problem without Android.

Thanks for the clarification. Yes, it looks like the problem is in Android.

I will have a look there and get back to you soon.

Best,
Margarita

1 Like

Hello @protoshadowmaker,

I tried the new reproducer with different Java versions, but everything seems to work without any exception. Could you, please, mention which Sonarqube version you’re using?

Best,
Margarita

@Margarita_Nedzelska thanks for your research!
I’m not using an explicit version of Sonar, but, as I understand, the plugin is using version 8.0.0.46037
The problem is also reproduced in running github actions e.g. you can check “Run Sonar” step here, in the reproducer project repo: [Print version · protoshadowmaker/sonarworkaround@137cb15 · GitHub](https://GitHub Action)
Maybe you have some specific Sonar configuration that makes you unable to reproduce this issue?

Hello @protoshadowmaker,

Looks like the problem is in the Android. We had similar issues before when users were migrating to Java 11.

You can probably find some insights and potential workarounds here and here.

Unfortunately, we can’t do much from our side as this is the error coming from the compiler (we’re using Eclipse to compile) and it doesn’t guarantee to be exactly the same as your Android one.

Best,
Margarita

1 Like

Hello @Margarita_Nedzelska
Potential workarounds you sent are related to pure Java projects and it’s slightly different from Android ecosystem because Android engineers can’t just exclude some dependency that Android build system used.
I found similar to my issue here Error compiling Sonarqube in android kotlin project with gradle but it also hasn’t been resolved.
As an Android community are big one let’s try to find solution together because other SonarCloud users will face with the same problem very soon in the process of upgrading to Gradle 8 that requires using Java 11 source compatibility. I created very basic Android app without any extra configuration and as Sonar user I expected it should works out of the box. During log analyzing it seems like sonarqube-gradle-plugin works well, the problem somewhere in scanner plugin that donwloads dynamically in IsolatedLauncherFactory.
Maybe we need to join Sonar Sources from related issue above to us to brainstorm ideas for workaround?
Regards, Yauhen

Hello @protoshadowmaker,

Thanks for your message and willingness to resolve the issue. I can understand your pain. The errors you see here don’t come from the scanner. These errors are coming from the Java Eclipse compiler (the one that we’re using to generate an AST and execute checks on Java files) This is happening because the compiler can’t resolve classes from java.lang package. This is most likely happening because Android has its own java.lang package and this is called Split-packages feature. It was working in Java 8 but isn’t allowed starting Java 9, when java modules appeared.

To double check this you can run, Gradle sonar task with an additional property -Dsonar.scanner.dumpToFile=out.properties. It won’t run the analysis but will save all your sonar properties into the file. And you need to share this file with me (if it contains secrets, make sure you removed them). I can also open a private conversation, so you can share it with me safely.

The potential solution to this problem could be to use sonar.java.jdkHome property (The Java analyzer relies on the JDK used to build your project and not the one used to run the scan) And as I can see it already solved a similar issue in another android project: Errors when running sonarqube-gradle-plugin:3.3 with Java 11

Please, read attentively the thread. A similar issue has already been solved and we have many users successfully using Java 11 with Android.

Best,
Margarita

1 Like

Hello @Margarita_Nedzelska ,
Thank you for your advice. I carefully analyze the thread and it’s looks like sonar.java.jdkHome property should help but it does not in my case.
I tried to set sonar.java.jdkHome to my JDK 8 location and run the task with java 11 environment, but the error the same.
I also analyze the log with --debug flag and didn’t find anything related to set sonar.java.jdkHome property, but dump file has it. Here is the log from ./gradlew sonar --debug run:

[INFO] [org.sonarqube.gradle.SonarTask] Sensor JavaSensor [java]
[INFO] [org.sonarqube.gradle.SonarTask] Configured Java source version (sonar.java.source): 11, preview features enabled (sonar.java.enablePreview): false
[DEBUG] [org.sonarqube.gradle.SonarTask] Property 'sonar.java.jdkHome' set with: /Users/user/.sdkman/candidates/java/11.0.20-ms
[DEBUG] [org.sonarqube.gradle.SonarTask] Property 'sonar.java.jdkHome' resolved with:
[/Users/user/.sdkman/candidates/java/11.0.20-ms/lib/jrt-fs.jar]
[DEBUG] [org.sonarqube.gradle.SonarTask] Property 'sonar.java.libraries' resolved with:
[/Users/user/Library/Android/sdk/platforms/android-33/android.jar,
/Users/user/Library/Android/sdk/build-tools/30.0.3/core-lambda-stubs.jar,
/Users/user/home/android/sonarworkaround/app/build/intermediates/compile_and_runtime_not_namespaced_r_class_jar/debug/R.jar]
[DEBUG] [org.sonarqube.gradle.SonarTask] Property 'sonar.java.jdkHome' set with: /Users/user/.sdkman/candidates/java/11.0.20-ms
[DEBUG] [org.sonarqube.gradle.SonarTask] Property 'sonar.java.jdkHome' resolved with:
[/Users/user/.sdkman/candidates/java/11.0.20-ms/lib/jrt-fs.jar]

Any ideas?

-Dsonar.scanner.dumpToFile=out.properties result:
out.txt (6.3 KB)

Hello @protoshadowmaker,

When I looked in the out.txt, I can see 2 lines:

\:app.sonar.java.jdkHome=/Users/user/.sdkman/candidates/java/11.0.20-ms
sonar.java.jdkHome=/Users/user/.sdkman/candidates/java/8.0.382-amzn

and in the logs I can see the following line:

[DEBUG] [org.sonarqube.gradle.SonarTask] Property ‘sonar.java.jdkHome’ resolved with:
[/Users/user/.sdkman/candidates/java/11.0.20-ms/lib/jrt-fs.jar]

It looks like you’ve set the property for the root project, but I haven’t set the property for the submodule app.

Could you, please, try to also set this property for the app submodule and check if you still see the error.

Regards,
Margarita

1 Like

I got the same issue when I try to run protoshadowmaker sample.

I just clone the project and run ./gradlew sonar.

Hello @hieu.nguyen,

Thanks for your message

Yes, I understand that there is a problem if you run this project. Nobody doubts it. There is a proposed workaround to specify the property sonar.java.jdkHome to Java 8.

In my last message

I asked to specify this property not only in the root but also in the submodule, as in the logs and properties output I can see, that it’s Java 8 in the root, but still Java 11 in the submodule.

Could you, please, follow this step and then answer if you still have the problem?

Best,
Margarita

@Margarita_Nedzelska
Wow, it was a long journey but finally, seems like the problem is solved. Thank you so much for your patience. The less obvious part here is we had to set sonar.java.jdkHome property at a module level, not in the root project (we can also set it here too, but it isn’t required).
Another thing that is not covered in the highlighted topics and out of my question is how to make everything work not only in one specific machine.
Let me share the final solution to help everyone who will search for the same answers to my question (I think it’s also nice to put these details someplace in the integration documentation because it isn’t possible to use sonar without this trick in any Android project that use Gradle 8+)
Pre requirements:
We have to install some tool that allows us to install and manage different Java versions. For instance it might be SDKMan, for GitHub it might be setup-java action.
Other tools are also applicable, 2 crucial requirements - possibility to install a few Java versions, and get the path to a specific one.
After we install the java management tool we have to put in the module build.gradle file the following code:

sonarqube {
    properties {
        property "sonar.java.jdkHome", project.findProperty('jdk8Home')
    }
}

You can choose any other name for jdk8Home property, doesn’t matter.
Then, when we run sonar command, we have to use our java management tool api to get java 8 path and pass it to Gradle. For SDKMan it might look following:

./gradlew sonar -Pjdk8Home=`sdk home java 8.0.382-amzn`

The step above is necessary because Gradle 8+ requires running tasks in a Java 17 environment.
For everyone who is looking for working example, check it out in the GitHub

2 Likes

One more question. Why do we have to set jdkHome= jdk8Home while our project is using Java 17.

Check Margarita’s explanation above please.

Thanks for your explanation.