JavaSdkVersion (@Nullable String jdk) { if (jdk == null) { return null; } try { int version = Integer.parseInt(jdk.trim()); JavaSdkVersion sdkVersion = resolveSdkVersion(version); if (sdkVersion != null) { return sdkVersion; } } catch (NumberFormatException e) { // Ignore. } Matcher matcher = JDK_VERSION_PATTERN.matcher(jdk); if (!matcher.matches()) { return null; } String versionAsString = matcher.group(1); try { return resolveSdkVersion(Integer.parseInt(versionAsString)); } catch (NumberFormatException e) { // Ignore. } return null; }