UnknownInvalidSdk (@NotNull Sdk sdk) { SdkTypeId type = sdk.getSdkType(); if (!(type instanceof SdkType sdkType)) return null; //for tests //noinspection TestOnlyProblems if (ApplicationManager.getApplication().isUnitTestMode() && sdk instanceof MockSdk) { return null; } try { String homePath = sdk.getHomePath(); if (homePath != null && sdkType.isValidSdkHome(homePath)) { return null; } } catch (ProcessCanceledException e) { throw e; } catch (Exception e) { LOG.warn("Failed to validate SDK " + sdk + ". " + e.getMessage(), e); return null; } return new UnknownInvalidSdk(sdk, sdkType); }