Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash of dagger.lint.DaggerKotlinIssueDetector using AGP 8.1.0 #3980

Closed
mr-thierry opened this issue Jul 26, 2023 · 5 comments
Closed

Crash of dagger.lint.DaggerKotlinIssueDetector using AGP 8.1.0 #3980

mr-thierry opened this issue Jul 26, 2023 · 5 comments

Comments

@mr-thierry
Copy link

I have a crash after upgrading to AGP 8.1.0.

Stacktrace:

java.lang.NullPointerException
	at dagger.lint.DaggerKotlinIssueDetector$createUastHandler$1.visitMethod(DaggerKotlinIssueDetector.kt:207)
	at com.android.tools.lint.client.api.UElementVisitor$DispatchPsiVisitor.visitMethod(UElementVisitor.kt:751)
	at com.android.tools.lint.client.api.UElementVisitor$DelegatingPsiVisitor.visitMethod(UElementVisitor.kt:1118)
	at org.jetbrains.uast.UMethod.accept(UMethod.kt:42)
	at org.jetbrains.uast.internal.ImplementationUtilsKt.acceptList(implementationUtils.kt:14)
	at org.jetbrains.uast.kotlin.AbstractKotlinUClass.accept(AbstractKotlinUClass.kt:99)
	at org.jetbrains.uast.internal.ImplementationUtilsKt.acceptList(implementationUtils.kt:14)
	at org.jetbrains.uast.UFile.accept(UFile.kt:89)
	at com.android.tools.lint.detector.api.UastLintUtilsKt.acceptSourceFile(UastLintUtils.kt:826)
	at com.android.tools.lint.client.api.UElementVisitor$visitFile$3.run(UElementVisitor.kt:267)
	at com.android.tools.lint.client.api.LintClient.runReadAction(LintClient.kt:1700)
	at com.android.tools.lint.client.api.LintDriver$LintClientWrapper.runReadAction(LintDriver.kt:2867)
	at com.android.tools.lint.client.api.UElementVisitor.visitFile(UElementVisitor.kt:264)
	at com.android.tools.lint.client.api.LintDriver$visitUastDetectors$1.run(LintDriver.kt:2165)
	at com.android.tools.lint.client.api.LintClient.runReadAction(LintClient.kt:1700)
	at com.android.tools.lint.client.api.LintDriver$LintClientWrapper.runReadAction(LintDriver.kt:2867)
	at com.android.tools.lint.client.api.LintDriver.visitUastDetectors(LintDriver.kt:2165)
	at com.android.tools.lint.client.api.LintDriver.visitUast(LintDriver.kt:2127)
	at com.android.tools.lint.client.api.LintDriver.runFileDetectors(LintDriver.kt:1379)
	at com.android.tools.lint.client.api.LintDriver.checkProject(LintDriver.kt:1144)
	at com.android.tools.lint.client.api.LintDriver.checkProjectRoot(LintDriver.kt:615)
	at com.android.tools.lint.client.api.LintDriver.access$checkProjectRoot(LintDriver.kt:170)
	at com.android.tools.lint.client.api.LintDriver$analyzeOnly$1.invoke(LintDriver.kt:441)
	at com.android.tools.lint.client.api.LintDriver$analyzeOnly$1.invoke(LintDriver.kt:438)
	at com.android.tools.lint.client.api.LintDriver.doAnalyze(LintDriver.kt:497)
	at com.android.tools.lint.client.api.LintDriver.analyzeOnly(LintDriver.kt:438)
	at com.android.tools.lint.LintCliClient$analyzeOnly$1.invoke(LintCliClient.kt:237)
	at com.android.tools.lint.LintCliClient$analyzeOnly$1.invoke(LintCliClient.kt:237)
	at com.android.tools.lint.LintCliClient.run(LintCliClient.kt:279)
	at com.android.tools.lint.LintCliClient.run$default(LintCliClient.kt:262)
	at com.android.tools.lint.LintCliClient.analyzeOnly(LintCliClient.kt:237)
	at com.android.tools.lint.Main.run(Main.java:1689)
	at com.android.tools.lint.Main.run(Main.java:275)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at com.android.build.gradle.internal.lint.AndroidLintWorkAction.invokeLintMainRunMethod(AndroidLintWorkAction.kt:98)
	at com.android.build.gradle.internal.lint.AndroidLintWorkAction.runLint(AndroidLintWorkAction.kt:87)
	at com.android.build.gradle.internal.lint.AndroidLintWorkAction.execute(AndroidLintWorkAction.kt:62)
	at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
	at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:66)
	at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:62)
	at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100)
	at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:62)
	at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
	at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
	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.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
	at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:59)
	at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$0(DefaultWorkerExecutor.java:170)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:187)
	at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.access$700(DefaultConditionalExecutionQueue.java:120)
	at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner$1.run(DefaultConditionalExecutionQueue.java:162)
	at org.gradle.internal.Factories$1.create(Factories.java:31)
	at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:249)
	at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:109)
	at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:114)
	at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:157)
	at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:126)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)


@inktomi
Copy link

inktomi commented Jul 26, 2023

It's odd that Line 207 would fail to find the static annotation that the class claimed to have only a couple lines above 🤔

@Chang-Eric
Copy link
Member

Agree with the above that it seems really weird that it couldn't find the annotation after checking it. For the code that is failing, is it possible you're missing a dependency on the Kotlin stdlib? We've seen cases in other contexts where checking if something has an annotation may not use the dependency, but then trying to get the annotation fails because of that.

If that isn't it though, I think we'd need a repro example to investigate if you can make one.

@mr-thierry
Copy link
Author

Update:

@jsjeon
Copy link
Member

jsjeon commented Aug 29, 2023

This is caused by https://github.com/JetBrains/intellij-community/blob/0af2e7b5c59e57c3a0080d736d5a6732a540407e/plugins/kotlin/uast/uast-kotlin-base/src/org/jetbrains/uast/kotlin/declarations/KotlinUMethod.kt#L66 which drops to convert @JvmStatic in source PSI to UAnnotation if the corresponding method is already static (as per https://youtrack.jetbrains.com/issue/KTIJ-21655).

I left code review: #4023 (comment), along with a correct workaround.

@jsjeon
Copy link
Member

jsjeon commented Aug 29, 2023

Made an upstream issue: https://youtrack.jetbrains.com/issue/KTIJ-26803

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants