void () { ApplicationManager.getApplication().runWriteAction(() -> { Module module = createModule("a.iml"); myModuleRootListener.assertEventsCount(1); ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel(); model.setInvalidSdk("new-jdk", JavaSdk.getInstance().getName()); model.commit(); myModuleRootListener.assertEventsCount(1); Sdk unusedJdk = ProjectJdkTable.getInstance().createSdk("unused-jdk", JavaSdk.getInstance()); ProjectJdkTable.getInstance().addJdk(unusedJdk, getTestRootDisposable()); myModuleRootListener.assertNoEvents(); Sdk jdk = ProjectJdkTable.getInstance().createSdk("new-jdk", JavaSdk.getInstance()); ProjectJdkTable.getInstance().addJdk(jdk, getTestRootDisposable()); myModuleRootListener.assertEventsCount(1); final SdkModificator sdkModificator = jdk.getSdkModificator(); sdkModificator.addRoot(getTempDir().createVirtualDir(), OrderRootType.CLASSES); sdkModificator.commitChanges(); myModuleRootListener.assertEventsCount(1); }); }