Sdk (@Nullable Project project) { if (project != null) { Sdk res = ProjectRootManager.getInstance(project).getProjectSdk(); if (res != null) return res; Module[] modules = ModuleManager.getInstance(project).getModules(); for (Module module : modules) { Sdk sdk = ModuleRootManager.getInstance(module).getSdk(); if (sdk != null && sdk.getSdkType() instanceof JavaSdkType) return sdk; } } // Workaround for projects without project Jdk SdkType jdkType = getJavaSdk(); return ProjectJdkTable.getInstance() .getSdksOfType(jdkType).stream() .filter(it -> isValidJdk(it)) .max(jdkType.versionComparator()) .orElseGet(ExternalSystemJdkUtil::getInternalJdk); }