private static void checkTargetJPDAInstalled(JavaParameters parameters) throws ExecutionException { final Sdk jdk = parameters.getJdk(); if (jdk == null) { throw new ExecutionException(DebuggerBundle.message("error.jdk.not.specified")); } final JavaSdkVersion version = JavaSdk.getInstance().getVersion(jdk); String versionString = jdk.getVersionString(); if (version == JavaSdkVersion.JDK_1_0 || version == JavaSdkVersion.JDK_1_1) { throw new ExecutionException(DebuggerBundle.message("error.unsupported.jdk.version", versionString)); } if (SystemInfo.isWindows && version == JavaSdkVersion.JDK_1_2) { final VirtualFile homeDirectory = jdk.getHomeDirectory(); if (homeDirectory == null || !homeDirectory.isValid()) { throw new ExecutionException(DebuggerBundle.message("error.invalid.jdk.home", versionString)); } //noinspection HardCodedStringLiteral File dllFile = new File( homeDirectory.getPath().replace('/', File.separatorChar) + File.separator + "bin" + File.separator + "jdwp.dll" ); if (!dllFile.exists()) { GetJPDADialog dialog = new GetJPDADialog(); dialog.show(); throw new ExecutionException(DebuggerBundle.message("error.debug.libraries.missing")); } } }
@Nullable private static Sdk findJdk(@NotNull JavaSdkVersion version) { JavaSdk javaSdk = JavaSdk.getInstance(); List<Sdk> javaSdks = ProjectJdkTable.getInstance().getSdksOfType(javaSdk); Sdk candidate = null; for (Sdk sdk : javaSdks) { JavaSdkVersion v = javaSdk.getVersion(sdk); if (v == version) { return sdk; } else if (candidate == null && v != null && version.getMaxLanguageLevel().isAtLeast(version.getMaxLanguageLevel())) { candidate = sdk; } } return candidate; }
private void createUIComponents() { myLanguageLevelCombo = new LanguageLevelCombo(JavaCoreBundle.message("default.language.level.description")) { @Override protected LanguageLevel getDefaultLevel() { Sdk sdk = myProjectJdkConfigurable.getSelectedProjectJdk(); if (sdk == null) return null; JavaSdkVersion version = JavaSdk.getInstance().getVersion(sdk); return version == null ? null : version.getMaxLanguageLevel(); } }; final JTextField textField = new JTextField(); final FileChooserDescriptor outputPathsChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); InsertPathAction.addTo(textField, outputPathsChooserDescriptor); outputPathsChooserDescriptor.setHideIgnored(false); BrowseFilesListener listener = new BrowseFilesListener(textField, "", ProjectBundle.message("project.compiler.output"), outputPathsChooserDescriptor); myProjectCompilerOutput = new FieldPanel(textField, null, null, listener, EmptyRunnable.getInstance()); FileChooserFactory.getInstance().installFileCompletion(myProjectCompilerOutput.getTextField(), outputPathsChooserDescriptor, true, null); }
@Nullable private static String detectJdkPath(@Nullable AtomicBoolean cancellationFlag) { String topVersion = null; String chosenPath = null; for (String path : getCandidatePaths()) { if (cancellationFlag != null && cancellationFlag.get()) { return null; } if (StringUtil.isEmpty(validateJdkLocation(new File(path)))) { String version = JavaSdk.getInstance().getVersionString(path); if (topVersion == null || version == null || topVersion.compareTo(version) < 0) { topVersion = version; chosenPath = path; } } } return chosenPath; }
private static boolean isBuiltByJdk7OrHigher(@NotNull Module module) { Sdk sdk = ModuleRootManager.getInstance(module).getSdk(); if (sdk == null) { return false; } if (isAndroidSdk(sdk)) { AndroidSdkAdditionalData data = getAndroidSdkAdditionalData(sdk); if (data != null) { Sdk jdk = data.getJavaSdk(); if (jdk != null) { sdk = jdk; } } } return sdk.getSdkType() instanceof JavaSdk && JavaSdk.getInstance().isOfVersionOrHigher(sdk, JavaSdkVersion.JDK_1_7); }
@Nullable public static String getJdkHomePath(@NotNull LanguageLevel langLevel) { Collection<String> jdkHomePaths = new ArrayList<String>(JavaSdk.getInstance().suggestHomePaths()); if (jdkHomePaths.isEmpty()) { return null; } // prefer jdk path of getJavaHome(), since we have to allow access to it in tests // see AndroidProjectDataServiceTest#testImportData() final List<String> list = new ArrayList<String>(); String javaHome = SystemProperties.getJavaHome(); if (javaHome != null && !javaHome.isEmpty()) { for (Iterator<String> it = jdkHomePaths.iterator(); it.hasNext(); ) { final String path = it.next(); if (path != null && javaHome.startsWith(path)) { it.remove(); list.add(path); } } } list.addAll(jdkHomePaths); return getBestJdkHomePath(list, langLevel); }
@Override protected void collectAllowedRoots(final List<String> roots) throws IOException { JavaSdk javaSdk = JavaSdk.getInstance(); final List<String> jdkPaths = Lists.newArrayList(javaSdk.suggestHomePaths()); jdkPaths.add(SystemProperties.getJavaHome()); roots.addAll(jdkPaths); for (final String jdkPath : jdkPaths) { FileUtil.processFilesRecursively(new File(jdkPath), new Processor<File>() { @Override public boolean process(File file) { try { String path = file.getCanonicalPath(); if (!FileUtil.isAncestor(jdkPath, path, false)) { roots.add(path); } } catch (IOException ignore) { } return true; } }); } }
@NotNull public static Sdk createAndSetJdk(@NotNull final Project project) { String[] names = {"JAVA6_HOME", "JAVA_HOME"}; String jdkHomePath = AndroidTestCaseHelper.getSystemPropertyOrEnvironmentVariable(names); assertNotNull("Please set one of the following env vars (or system properties) to point to the JDK: " + Joiner.on(",").join(names), jdkHomePath); final Sdk jdk = SdkConfigurationUtil.createAndAddSDK(jdkHomePath, JavaSdk.getInstance()); assertNotNull(jdk); ExternalSystemApiUtil.executeProjectChangeAction(true, new DisposeAwareProjectChange(project) { @Override public void execute() { NewProjectUtil.applyJdkToProject(project, jdk); } }); return jdk; }
@Override public void setUp() throws Exception { myJdkHome = IdeaTestUtil.requireRealJdkHome(); super.setUp(); assumeThat(gradleVersion, versionMatcherRule.getMatcher()); new WriteAction() { @Override protected void run(@NotNull Result result) throws Throwable { Sdk oldJdk = ProjectJdkTable.getInstance().findJdk(GRADLE_JDK_NAME); if (oldJdk != null) { ProjectJdkTable.getInstance().removeJdk(oldJdk); } VirtualFile jdkHomeDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(myJdkHome)); Sdk jdk = SdkConfigurationUtil.setupSdk(new Sdk[0], jdkHomeDir, JavaSdk.getInstance(), true, null, GRADLE_JDK_NAME); assertNotNull("Cannot create JDK for " + myJdkHome, jdk); ProjectJdkTable.getInstance().addJdk(jdk); } }.execute(); myProjectSettings = new GradleProjectSettings(); GradleSettings.getInstance(myProject).setGradleVmOptions("-Xmx64m -XX:MaxPermSize=64m"); System.setProperty(ExternalSystemExecutionSettings.REMOTE_PROCESS_IDLE_TTL_IN_MS_KEY, String.valueOf(GRADLE_DAEMON_TTL_MS)); configureWrapper(); }
public void updateJavaParameters(RunConfigurationBase configuration, JavaParameters params, RunnerSettings runnerSettings) { if (!isApplicableFor(configuration)) { return; } final JavaCoverageEnabledConfiguration coverageConfig = JavaCoverageEnabledConfiguration.getFrom(configuration); //noinspection ConstantConditions coverageConfig.setCurrentCoverageSuite(null); final CoverageRunner coverageRunner = coverageConfig.getCoverageRunner(); if (runnerSettings instanceof CoverageRunnerData && coverageRunner != null) { final CoverageDataManager coverageDataManager = CoverageDataManager.getInstance(configuration.getProject()); coverageConfig.setCurrentCoverageSuite(coverageDataManager.addCoverageSuite(coverageConfig)); coverageConfig.appendCoverageArgument(configuration, params); final Sdk jdk = params.getJdk(); if (jdk != null && JavaSdk.getInstance().isOfVersionOrHigher(jdk, JavaSdkVersion.JDK_1_7) && coverageRunner instanceof JavaCoverageRunner && !((JavaCoverageRunner)coverageRunner).isJdk7Compatible()) { Notifications.Bus.notify(new Notification("Coverage", "Coverage instrumentation is not fully compatible with JDK 7", coverageRunner.getPresentableName() + " coverage instrumentation can lead to java.lang.VerifyError errors with JDK 7. If so, please try IDEA coverage runner.", NotificationType.WARNING)); } } }
@Nullable private static String getJdkHomePath(LanguageLevel langLevel) { Collection<String> jdkHomePaths = new ArrayList<>(JavaSdk.getInstance().suggestHomePaths()); if (jdkHomePaths.isEmpty()) { return null; } // prefer jdk path of getJavaHome(), since we have to allow access to it in tests // see AndroidProjectDataServiceTest#testImportData() final List<String> list = new ArrayList<>(); String javaHome = SystemProperties.getJavaHome(); if (javaHome != null && !javaHome.isEmpty()) { for (Iterator<String> it = jdkHomePaths.iterator(); it.hasNext(); ) { final String path = it.next(); if (path != null && javaHome.startsWith(path)) { it.remove(); list.add(path); } } } list.addAll(jdkHomePaths); return getBestJdkHomePath(list, langLevel); }
/** * Find if pants sdk is already configured, return the existing sdk if it exists, * otherwise add to the config and return. */ private Sdk addIfNotExists(final Sdk pantsSdk) { final JavaSdk javaSdk = JavaSdk.getInstance(); List<Sdk> sdks = ProjectJdkTable.getInstance().getSdksOfType(javaSdk); for (Sdk sdk : sdks) { if (javaSdk.getVersion(sdk) == javaSdk.getVersion(pantsSdk)) { return sdk; } } ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { ProjectJdkTable.getInstance().addJdk(pantsSdk); } }); return pantsSdk; }
@Contract("null, _ -> false") public static boolean isJdkAtLeast(@Nullable Sdk jdk, @NotNull JavaSdkVersion expected) { if(jdk != null) { SdkTypeId type = jdk.getSdkType(); if(type instanceof JavaSdk) { JavaSdkVersion actual = ((JavaSdk) type).getVersion(jdk); if(actual != null) { return actual.isAtLeast(expected); } } } return false; }
@Nullable private static Sdk findJdk(@NotNull JavaSdkVersion version) { JavaSdk javaSdk = JavaSdk.getInstance(); List<Sdk> javaSdks = SdkTable.getInstance().getSdksOfType(javaSdk); Sdk candidate = null; for(Sdk sdk : javaSdks) { JavaSdkVersion v = javaSdk.getVersion(sdk); if(v == version) { return sdk; } else if(candidate == null && v != null && version.getMaxLanguageLevel().isAtLeast(version.getMaxLanguageLevel())) { candidate = sdk; } } return candidate; }
private static Sdk createAlternativeJdk(@NotNull String jreHome) throws CantRunException { final Sdk configuredJdk = SdkTable.getInstance().findSdk(jreHome); if(configuredJdk != null) { return configuredJdk; } if(!OwnJdkUtil.checkForJre(jreHome)) { throw new CantRunException(JavaExecutionBundle.message("jre.path.is.not.valid.jre.home.error.message", jreHome)); } final JavaSdk javaSdk = JavaSdk.getInstance(); return javaSdk.createJdk(ObjectUtil.notNull(javaSdk.getVersionString(jreHome), ""), jreHome); }
public void updateJavaParameters(RunConfigurationBase configuration, OwnJavaParameters params, RunnerSettings runnerSettings) { if (!isApplicableFor(configuration)) { return; } final JavaCoverageEnabledConfiguration coverageConfig = JavaCoverageEnabledConfiguration.getFrom(configuration); //noinspection ConstantConditions coverageConfig.setCurrentCoverageSuite(null); final CoverageRunner coverageRunner = coverageConfig.getCoverageRunner(); if (runnerSettings instanceof CoverageRunnerData && coverageRunner != null) { final CoverageDataManager coverageDataManager = CoverageDataManager.getInstance(configuration.getProject()); coverageConfig.setCurrentCoverageSuite(coverageDataManager.addCoverageSuite(coverageConfig)); coverageConfig.appendCoverageArgument(params); final Sdk jdk = params.getJdk(); if (jdk != null && JavaSdk.getInstance().isOfVersionOrHigher(jdk, JavaSdkVersion.JDK_1_7) && coverageRunner instanceof JavaCoverageRunner && !((JavaCoverageRunner)coverageRunner).isJdk7Compatible()) { Notifications.Bus.notify(new Notification("Coverage", "Coverage instrumentation is not fully compatible with JDK 7", coverageRunner.getPresentableName() + " coverage instrumentation can lead to java.lang.VerifyError errors with JDK 7. If so, please try IDEA coverage runner.", NotificationType.WARNING)); } } }
@NotNull @RequiredReadAction private static JavaSdkVersion getJavaVersion(PsiElement element) { final Module module = ModuleUtilCore.findModuleForPsiElement(element); if(module != null) { final Sdk sdk = ModuleUtilCore.getSdk(element, JavaModuleExtension.class); if(sdk != null && sdk.getSdkType() instanceof JavaSdk) { final JavaSdkVersion version = JavaSdk.getInstance().getVersion(sdk); if(version != null) { return version; } } } return JavaSdkVersion.MAX_JDK; }
private void checkVirtualMachineVersion(VirtualMachine vm) { final String version = vm.version(); if("1.4.0".equals(version)) { DebuggerInvocationUtil.swingInvokeLater(myProject, () -> Messages.showMessageDialog(myProject, DebuggerBundle.message("warning.jdk140.unstable"), DebuggerBundle.message("title.jdk140" + ".unstable"), Messages.getWarningIcon())); } if(getSession().getAlternativeJre() == null) { Sdk runjre = getSession().getRunJre(); if((runjre == null || runjre.getSdkType() instanceof JavaSdkType) && !versionMatch(runjre, version)) { SdkTable.getInstance().getSdksOfType(JavaSdk.getInstance()).stream().filter(sdk -> versionMatch(sdk, version)).findFirst().ifPresent(sdk -> { XDebugSessionImpl.NOTIFICATION_GROUP.createNotification(DebuggerBundle.message("message.remote.jre.version.mismatch", version, runjre != null ? runjre.getVersionString() : "unknown", sdk.getName()), MessageType.INFO).notify(myProject); getSession().setAlternativeJre(sdk); }); } } }
@Override public Sdk getSdk() { return _sdk == null ? _sdk = JavaSdk.getInstance().createJdk( getJdkVersion(), getPath_JdkRoot() + File.separatorChar + getJdkVersion(), false ) : _sdk; }
private static Sdk createAlternativeJdk(@NotNull String jreHome) throws CantRunException { final Sdk configuredJdk = ProjectJdkTable.getInstance().findJdk(jreHome); if (configuredJdk != null) { return configuredJdk; } if (!JdkUtil.checkForJre(jreHome) && !JdkUtil.checkForJdk(jreHome)) { throw new CantRunException(ExecutionBundle.message("jre.path.is.not.valid.jre.home.error.message", jreHome)); } final Sdk jdk = JavaSdk.getInstance().createJdk("", jreHome); if (jdk == null) throw CantRunException.noJdkConfigured(); return jdk; }
public boolean isJre50Configured(final CommonJavaRunConfigurationParameters configuration) { if (configuration.isAlternativeJrePathEnabled()) { if (Comparing.equal(configuration.getAlternativeJrePath(), myLastAlternativeJrePath)) { return myLastIsJre50; } myLastAlternativeJrePath = configuration.getAlternativeJrePath(); final String versionString = JavaSdk.getJdkVersion(myLastAlternativeJrePath); myLastIsJre50 = versionString != null && isJre50(versionString); return myLastIsJre50; } return false; }
@Override public boolean isAvailable(@NotNull final Project project, final Editor editor, final PsiFile file) { if (!myMethodCall.isValid()) return false; final Module module = ModuleUtilCore.findModuleForPsiElement(file); if (module == null) return false; final Sdk jdk = ModuleRootManager.getInstance(module).getSdk(); if (jdk == null || !JavaSdk.getInstance().isOfVersionOrHigher(jdk, JavaSdkVersion.JDK_1_5)) return false; final PsiReferenceExpression expression = myMethodCall.getMethodExpression(); final PsiElement element = expression.resolve(); if (element instanceof PsiMethod) { final PsiMethod method = (PsiMethod)element; final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project); final PsiClass collectionsClass = psiFacade.findClass("java.util.Collection", GlobalSearchScope.allScope(project)); if (collectionsClass != null && InheritanceUtil.isInheritorOrSelf(method.getContainingClass(), collectionsClass, true)) { if (Comparing.strEqual(method.getName(), "addAll") && PsiType.BOOLEAN.equals(method.getReturnType())) { final PsiParameter[] psiParameters = method.getParameterList().getParameters(); if (psiParameters.length == 1 && psiParameters[0].getType() instanceof PsiClassType && InheritanceUtil.isInheritorOrSelf(((PsiClassType)psiParameters[0].getType()).resolve(), collectionsClass, true)) { final PsiExpressionList list = myMethodCall.getArgumentList(); final PsiExpression[] expressions = list.getExpressions(); if (expressions.length == 1) { if (expressions[0].getType() instanceof PsiArrayType) { return true; } } } } } } return false; }
public JavaDocInfoGenerator(Project project, PsiElement element) { myProject = project; myElement = element; Sdk jdk = JavadocGeneratorRunProfile.getSdk(myProject); mySdkVersion = jdk == null ? null : JavaSdk.getInstance().getVersion(jdk); }
private void projectSdkChanged(@Nullable Sdk sdk) { if (isDefault() && sdk != null) { JavaSdkVersion version = JavaSdk.getInstance().getVersion(sdk); if (version != null) { setLanguageLevel(version.getMaxLanguageLevel()); } } }
private void setupExeParams(final Sdk jdk, GeneralCommandLine cmdLine) throws ExecutionException { final String jdkPath = jdk != null && jdk.getSdkType() instanceof JavaSdkType ? ((JavaSdkType)jdk.getSdkType()).getBinPath(jdk) : null; if (jdkPath == null) { throw new CantRunException(JavadocBundle.message("javadoc.generate.no.jdk.path")); } JavaSdkVersion version = JavaSdk.getInstance().getVersion(jdk); if (myConfiguration.HEAP_SIZE != null && myConfiguration.HEAP_SIZE.trim().length() != 0) { if (version == null || version.isAtLeast(JavaSdkVersion.JDK_1_2)) { cmdLine.getParametersList().prepend("-J-Xmx" + myConfiguration.HEAP_SIZE + "m"); } else { cmdLine.getParametersList().prepend("-J-mx" + myConfiguration.HEAP_SIZE + "m"); } } cmdLine.setWorkDirectory((File)null); @NonNls final String javadocExecutableName = File.separator + (SystemInfo.isWindows ? "javadoc.exe" : "javadoc"); @NonNls String exePath = jdkPath.replace('/', File.separatorChar) + javadocExecutableName; if (new File(exePath).exists()) { cmdLine.setExePath(exePath); } else { //try to use wrapper jdk exePath = new File(jdkPath).getParent().replace('/', File.separatorChar) + javadocExecutableName; if (!new File(exePath).exists()) { final File parent = new File(System.getProperty("java.home")).getParentFile(); //try system jre exePath = parent.getPath() + File.separator + "bin" + javadocExecutableName; if (!new File(exePath).exists()) { throw new CantRunException(JavadocBundle.message("javadoc.generate.no.jdk.path")); } } cmdLine.setExePath(exePath); } }
@Nullable private static JavaSdkVersion getJavaVersion(PsiElement element) { if (ApplicationManager.getApplication().isUnitTestMode()) { return JavaSdkVersion.JDK_1_9; } final Module module = ModuleUtilCore.findModuleForPsiElement(element); if (module != null) { final Sdk sdk = ModuleRootManager.getInstance(module).getSdk(); if (sdk != null && sdk.getSdkType() instanceof JavaSdk) { return JavaSdk.getInstance().getVersion(sdk); } } return null; }
void sdkUpdated(Sdk sdk) { LanguageLevel newLevel = null; if (sdk != null) { JavaSdkVersion version = JavaSdk.getInstance().getVersion(sdk); if (version != null) { newLevel = version.getMaxLanguageLevel(); } } updateDefaultLevel(newLevel); }
public static void applyJdkToProject(@NotNull Project project, @NotNull Sdk jdk) { ProjectRootManagerEx rootManager = ProjectRootManagerEx.getInstanceEx(project); rootManager.setProjectSdk(jdk); JavaSdkVersion version = JavaSdk.getInstance().getVersion(jdk); if (version != null) { LanguageLevel maxLevel = version.getMaxLanguageLevel(); LanguageLevelProjectExtension extension = LanguageLevelProjectExtension.getInstance(ProjectManager.getInstance().getDefaultProject()); LanguageLevelProjectExtension ext = LanguageLevelProjectExtension.getInstance(project); if (extension.isDefault() || maxLevel.compareTo(ext.getLanguageLevel()) < 0) { ext.setLanguageLevel(maxLevel); } } }
private boolean validateAndUpdateJdkPath(@NotNull File file) { if (JavaSdk.checkForJdk(file)) { return true; } if (SystemInfo.isMac) { File potentialPath = new File(file, IdeSdks.MAC_JDK_CONTENT_PATH); if (potentialPath.isDirectory() && JavaSdk.checkForJdk(potentialPath)) { myJdkLocationTextField.setText(potentialPath.getPath()); return true; } } return false; }
/** * @return {@code true} if the configurable is needed: e.g. if we're missing a JDK or an Android SDK setting. */ public static boolean isNeeded() { String jdkPath = getDefaultJdkPath(); String sdkPath = getDefaultSdkPath(); boolean validJdk = !jdkPath.isEmpty() && JavaSdk.checkForJdk(new File(jdkPath)); boolean validSdk = !sdkPath.isEmpty() && IdeSdks.isValidAndroidSdkPath(new File(sdkPath)); return !validJdk || !validSdk; }
private static boolean isJdk7(@NotNull File path) { String jdkVersion = JavaSdk.getJdkVersion(path.getAbsolutePath()); if (jdkVersion != null) { JavaSdkVersion version = JavaSdk.getInstance().getVersion(jdkVersion); if (version != null && !version.isAtLeast(JavaSdkVersion.JDK_1_7)) { return false; } } return true; }
private void createUIComponents() { mySdksModel = new ProjectSdksModel(); mySdksModel.reset(null); myJavaSdkCombo = new JdkComboBox(mySdksModel, new Condition<SdkTypeId>() { @Override public boolean value(SdkTypeId id) { return JavaSdk.getInstance().equals(id); } }); }
@Nullable private static String validateJdkPath(@Nullable String path) { if (isEmpty(path) || !JavaSdk.getInstance().isValidSdkHome(path)) { return "Invalid JDK path."; } return null; }
public static boolean isApplicableJdk(@NotNull Sdk jdk, @Nullable LanguageLevel langLevel) { if (!(jdk.getSdkType() instanceof JavaSdk)) { return false; } if (langLevel == null) { langLevel = DEFAULT_LANG_LEVEL; } JavaSdkVersion version = JavaSdk.getInstance().getVersion(jdk); if (version != null) { //noinspection TestOnlyProblems return hasMatchingLangLevel(version, langLevel); } return false; }
@Nullable private static String getBestJdk(@NotNull List<String> jdkRoots, @NotNull LanguageLevel langLevel) { String bestJdk = null; for (String jdkRoot : jdkRoots) { if (JavaSdk.getInstance().isValidSdkHome(jdkRoot)) { if (bestJdk == null && hasMatchingLangLevel(jdkRoot, langLevel)) { bestJdk = jdkRoot; } else if (bestJdk != null) { bestJdk = selectJdk(bestJdk, jdkRoot, langLevel); } } } return bestJdk; }
@NotNull private static JavaSdkVersion getVersion(@NotNull String jdkRoot) { String version = JavaSdk.getInstance().getVersionString(jdkRoot); if (version == null) { return JavaSdkVersion.JDK_1_0; } JavaSdkVersion sdkVersion = JavaSdk.getInstance().getVersion(version); return sdkVersion == null ? JavaSdkVersion.JDK_1_0 : sdkVersion; }
@Nullable public static Sdk createJdk(@NotNull String jdkHomePath) { Sdk jdk = createAndAddSDK(jdkHomePath, JavaSdk.getInstance()); if (jdk == null) { String msg = String.format("Unable to create JDK from path '%1$s'", jdkHomePath); Logger.getInstance(Jdks.class).error(msg); } return jdk; }
public boolean isJdk() { if (myNode instanceof NamedLibraryElementNode) { NamedLibraryElement value = ((NamedLibraryElementNode)myNode).getValue(); assertNotNull(value); LibraryOrSdkOrderEntry orderEntry = value.getOrderEntry(); if (orderEntry instanceof JdkOrderEntry) { Sdk sdk = ((JdkOrderEntry)orderEntry).getJdk(); return sdk.getSdkType() instanceof JavaSdk; } } return false; }