Sdk (@NotNull Collection<? extends Module> modules) { List<Sdk> jdks = ContainerUtil.mapNotNull(modules, module -> { if (module == null) return null; Sdk sdk = ModuleRootManager.getInstance(module).getSdk(); if (sdk == null || !(sdk.getSdkType() instanceof JavaSdkType)) return null; return sdk; }); if (jdks.isEmpty()) { return null; } return jdks.stream().max(Comparator.comparing(jdk -> JavaVersion.tryParse(jdk.getVersionString()), Comparator.nullsFirst(Comparator.naturalOrder()))).orElse(null); }