Sdk (@NotNull Disposable parentDisposable, @Nullable String testJdkName) { Sdk internalJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk(); if (testJdkName == null) { testJdkName = internalJdk.getName(); } String finalJdkName = testJdkName; return WriteAction.compute(() -> { ProjectJdkTable jdkTable = ProjectJdkTable.getInstance(); Sdk oldJdk = jdkTable.findJdk(finalJdkName); if (oldJdk != null) { jdkTable.removeJdk(oldJdk); } Sdk jdk = internalJdk; if (!internalJdk.getName().equals(finalJdkName)) { try { ProjectJdkImpl copy = (ProjectJdkImpl)internalJdk.clone(); copy.setName(finalJdkName); jdk = copy; } catch (CloneNotSupportedException e) { throw new RuntimeException(e); } } jdkTable.addJdk(jdk, parentDisposable); return jdk; }); }