PluginException: getComponentAdapterOfType is used to get XXX, Probably constructor should be marked as NonInjectable.

Hey there,

In the latest EAP builds for at least Idea 2019.3 (idea-IU-193.3793.14) and PhpStorm 2019.3 (193.3793.21), several extensions throw exceptions like the one shown below.

I found a few recent commits about this, but no explanation about why - see http://git.jetbrains.org/?p=idea%2Fcommunity.git&a=search&st=commit&s=getComponentAdapterOfType

Is there something that we can fix as extension developers? Or is this a regression?

com.intellij.diagnostic.PluginException: getComponentAdapterOfType is used to get org.sonarlint.intellij.config.project.SonarLintProjectSettings (requestorClass=org.sonarlint.intellij.config.project.SonarLintProjectSettings, requestorConstructor=public org.sonarlint.intellij.config.project.SonarLintProjectSettings(org.sonarlint.intellij.config.project.SonarLintProjectSettings)).

Probably constructor should be marked as NonInjectable. [Plugin: org.sonarlint.idea]
at com.intellij.serviceContainer.ConstructorParameterResolver.findTargetAdapter(ConstructorParameterResolver.kt:109)
at com.intellij.serviceContainer.ConstructorParameterResolver.isResolvable(ConstructorParameterResolver.kt:37)
at com.intellij.serviceContainer.ConstructorInjectionKt.getGreediestSatisfiableConstructor(constructorInjection.kt:106)
at com.intellij.serviceContainer.ConstructorInjectionKt.instantiateUsingPicoContainer(constructorInjection.kt:36)
at com.intellij.serviceContainer.PlatformComponentManagerImpl.instantiateClassWithConstructorInjection(PlatformComponentManagerImpl.kt:500)
at com.intellij.serviceContainer.MyComponentAdapter.doCreateInstance(MyComponentAdapter.kt:35)
at com.intellij.serviceContainer.BaseComponentAdapter.getInstanceUncached(BaseComponentAdapter.kt:110)
at com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:72)
at com.intellij.serviceContainer.BaseComponentAdapter.getInstance$default(BaseComponentAdapter.kt:65)
at com.intellij.serviceContainer.ConstructorParameterResolver.resolveInstance(ConstructorParameterResolver.kt:62)
at com.intellij.serviceContainer.ConstructorInjectionKt.instantiateUsingPicoContainer(constructorInjection.kt:45)
at com.intellij.serviceContainer.PlatformComponentManagerImpl.instantiateClassWithConstructorInjection(PlatformComponentManagerImpl.kt:500)
at com.intellij.serviceContainer.MyComponentAdapter.doCreateInstance(MyComponentAdapter.kt:35)
at com.intellij.serviceContainer.BaseComponentAdapter.getInstanceUncached(BaseComponentAdapter.kt:110)
at com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:72)
at com.intellij.serviceContainer.BaseComponentAdapter.getInstance$default(BaseComponentAdapter.kt:65)
at com.intellij.serviceContainer.ConstructorParameterResolver.resolveInstance(ConstructorParameterResolver.kt:62)
at com.intellij.serviceContainer.ConstructorInjectionKt.instantiateUsingPicoContainer(constructorInjection.kt:45)
at com.intellij.serviceContainer.PlatformComponentManagerImpl.instantiateClassWithConstructorInjection(PlatformComponentManagerImpl.kt:500)
at com.intellij.serviceContainer.MyComponentAdapter.doCreateInstance(MyComponentAdapter.kt:35)
at com.intellij.serviceContainer.BaseComponentAdapter.getInstanceUncached(BaseComponentAdapter.kt:110)
at com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:72)
at com.intellij.serviceContainer.BaseComponentAdapter.getInstance$default(BaseComponentAdapter.kt:65)
at com.intellij.serviceContainer.PlatformComponentManagerImpl.createComponents(PlatformComponentManagerImpl.kt:177)
at com.intellij.openapi.project.impl.ProjectImpl.init(ProjectImpl.java:295)
at com.intellij.openapi.project.impl.ProjectManagerImpl.initProject(ProjectManagerImpl.java:322)
at com.intellij.openapi.project.impl.ProjectManagerImpl.convertAndLoadProject(ProjectManagerImpl.java:631)
at com.intellij.platform.PlatformProjectOpenProcessor.prepareProject(PlatformProjectOpenProcessor.java:297)
at com.intellij.platform.PlatformProjectOpenProcessor.lambda$openExistingProject$0(PlatformProjectOpenProcessor.java:229)
at com.intellij.platform.ProjectUiFrameAllocator$run$1$1.run(ProjectFrameAllocator.kt:77)
at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:254)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:895)
at com.intellij.openapi.progress.impl.CoreProgressManager$5.run(CoreProgressManager.java:448)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:170)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:592)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:538)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:59)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:157)
at com.intellij.openapi.application.impl.ApplicationImpl.lambda$null$4(ApplicationImpl.java:430)
at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:221)
at com.intellij.util.ConcurrencyUtil.lambda$underThreadNameRunnable$3(ConcurrencyUtil.java:209)
at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:235)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
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:834)

Cheers,

-- JB.L

1 comment
Comment actions Permalink

It seems that classes that trigger the exception indeed have a "non injectable", test-only constructor in addition to the one used by the platform DI.

I suggest that constructors that bear the @com.google.common.annotations.VisibleForTesting annotation are excluded (like the @java.lang.Deprecated ones).

1

Please sign in to leave a comment.