Sdk (@NotNull Disposable disposable, @NotNull Function0<Sdk> getJdk) { Sdk jdk = getJdk.invoke(); Sdk[] allJdks = ReadAction.compute(() -> ProjectJdkTable.getInstance()).getAllJdks(); for (Sdk existingJdk : allJdks) { if (existingJdk == jdk) { return existingJdk; } } ApplicationManager.getApplication().runWriteAction(() -> ProjectJdkTable.getInstance().addJdk(jdk, disposable)); return jdk; }