SetupJDKFix fails in LightCodeInsightFixtureTestCase



I am trying to write my first LightCodeInsightFixtureTestCases. Every time I invoke an IntentionAction via 


I get a not so nice exception [1]. After digging a bit I found out that SetupJdkQuickFix accesses the ProjectSettingsService (whose instance is of type IdeaProjectSettingsService), whose chooseAndSetJdk method accesses the main window frame. As the test runs headless this frame is null.

Unfortunately the fix tries to construct a JdkChooserPanel, which in turn is a DialogWrapper. The super(parent, true) call resolves to super(null, true). As parent may not be null IntelliJ throws a IllegalArgumentException.

Obviously I am doing something wrong. Is there any chance to stop Java from evaluating this annotation? I could not even find by whom that exception is thrown, as the thrower does not appear in the stack trace.

Is there any kind of different solution?





java.lang.IllegalArgumentException: Argument for @NotNull parameter 'parent' of com/intellij/openapi/ui/DialogWrapper.<init> must not be null

at com.intellij.openapi.ui.DialogWrapper.<init>(
at com.intellij.ide.util.projectWizard.JdkChooserPanel$MyDialog.<init>(
at com.intellij.ide.util.projectWizard.JdkChooserPanel.showDialog(
at com.intellij.ide.util.projectWizard.JdkChooserPanel.chooseAndSetJDK(
at com.intellij.openapi.roots.ui.configuration.IdeaProjectSettingsService.chooseAndSetSdk(
at com.intellij.codeInsight.daemon.impl.quickfix.SetupJDKFix.invoke(
at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler$
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(
at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.chooseActionAndInvoke(
at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.chooseActionAndInvoke(
at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.launchAction(
at org.jetbrains.plugins.akdb.jboss5.EJBInjectOnConcreteClassTest.testbla(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at junit.framework.TestCase.runTest(
at com.intellij.testFramework.UsefulTestCase.access$001(
at com.intellij.testFramework.UsefulTestCase$
at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$2.invoke(EdtTestUtil.kt:30)
at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$2.invoke(EdtTestUtil.kt:24)
at com.intellij.testFramework.EdtTestUtilKt.runInEdtAndWait(EdtTestUtil.kt:42)
at com.intellij.testFramework.EdtTestUtil$Companion.runInEdtAndWait(EdtTestUtil.kt:30)
at com.intellij.testFramework.EdtTestUtil.runInEdtAndWait(EdtTestUtil.kt)
at com.intellij.testFramework.UsefulTestCase.invokeTestRunnable(
at com.intellij.testFramework.UsefulTestCase.runTest(
at com.intellij.testFramework.UsefulTestCase.defaultRunBare(
at com.intellij.testFramework.UsefulTestCase$
at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:26)
at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:24)
at com.intellij.testFramework.EdtTestUtilKt$sam$Runnable$
at java.awt.event.InvocationEvent.dispatch(
at java.awt.EventQueue.dispatchEventImpl(
at java.awt.EventQueue.access$500(
at java.awt.EventQueue$
at java.awt.EventQueue$
at Method)
at java.awt.EventQueue.dispatchEvent(
at com.intellij.ide.IdeEventQueue.dispatchEvent(
at java.awt.EventDispatchThread.pumpOneEventForFilters(
at java.awt.EventDispatchThread.pumpEventsForFilter(
at java.awt.EventDispatchThread.pumpEventsForHierarchy(
at java.awt.EventDispatchThread.pumpEvents(
at java.awt.EventDispatchThread.pumpEvents(

Comment actions Permalink

Hi Matthias,

what intention do you test? Looks like it's SetupJDKFix and it is not test-ready as it tries to show the UI and our fixtures expect no UI at all. If you would suppress illegal access exception, you'll get NPE later and many other ugly exceptions.

BTW The UI test framework would be published shortly.


Comment actions Permalink

Hi Anna,

thanks for your fast response. Acutally I am not testing some UI but only a quickfix. Whenever I execute 


the code breaks [1]. Actually I thought the test runs headless. Do I really need a UI to test the quickfix change for the warning?

Thanks again,




public class EJBInjectOnConcreteClassTest extends LightCodeInsightFixtureTestCase {
//LightPlatformCodeInsightFixtureTestCase (I get the same effect here)

protected String getTestDataPath() {
return ...

public void testBla() throws Exception {

List<IntentionAction> quickFixes = myFixture.getAllQuickFixes();
for (IntentionAction intention : quickFixes) {
Comment actions Permalink

you need to setup jdk in tests as now you obviously doesn't have one (SetupJdkFix).

BTW If I were you, I won't test all fixes which are available (and which would change code/model/whatever) but would find mine fix (by name) and start only it. So I suggest to filter 


and start only one per test.

Comment actions Permalink

Hi Anna,

well this is exactly the thing I don't understand. If I look at tests in the groovy plugin (i.e. I can nowhere find an explicitly set SDK. 

From normal test frameworks I'd have guessed that, as a default value, IntelliJ just uses the SDK provided from the JVM running the test. This is wrong, obviously. But why does the Groovy test work and mine does not?

As far as I can see I could override getProjectDescriptor and provide some SDK in getSdk. However, this still feels wrong when not understanding why nobody else has this problem. There must be some different solution.

Thanks again,


Comment actions Permalink

One more thing ... if I set the JDK explicitly using the project descriptor, IntelliJ will still call the SetupJdkFix, which in turn opens up the dialog. In effect, I get the same behavior.

The reason for this is that


will still open up the dialog (which cannot be opened as there is no frame). There is no check for a JDK here.


Edit: By default LightCodeInsightFixtureTestCase uses a descriptor for JAVA_LATEST - so there's no need to set it myself. Still it does not work.

Edit 2: Your guess with filtering the quickfixes was a good one - filtering the SetupJDKFix makes it work. Still I don't know why the SetupJDKFix is available in this test case. It only checks for java.lang.Object to be available. As I've got a JDK configured this has to be true. Even more interesting, the isAvailable method of the fix is not even called (at least not in the debugger)

Comment actions Permalink

Never mind, I now use 

return JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();

which seems to work quite great :-)


Please sign in to leave a comment.