• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JdkUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.openapi.projectRoots.JdkUtil的典型用法代码示例。如果您正苦于以下问题:Java JdkUtil类的具体用法?Java JdkUtil怎么用?Java JdkUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JdkUtil类属于com.intellij.openapi.projectRoots包,在下文中一共展示了JdkUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: shouldForceClassicVM

import com.intellij.openapi.projectRoots.JdkUtil; //导入依赖的package包/类
/**
 * for Target JDKs versions 1.2.x - 1.3.0 the Classic VM should be used for debugging
 */
private static boolean shouldForceClassicVM(Sdk jdk) {
  if (SystemInfo.isMac) {
    return false;
  }
  if (jdk == null) return false;

  String version = JdkUtil.getJdkMainAttribute(jdk, Attributes.Name.IMPLEMENTATION_VERSION);
  if (version != null) {
    if (version.compareTo("1.4") >= 0) {
      return false;
    }
    if (version.startsWith("1.2") && SystemInfo.isWindows) {
      return true;
    }
    version += ".0";
    if (version.startsWith("1.3.0") && SystemInfo.isWindows) {
      return true;
    }
    if ((version.startsWith("1.3.1_07") || version.startsWith("1.3.1_08")) && SystemInfo.isWindows) {
      return false; // fixes bug for these JDKs that it cannot start with -classic option
    }
  }

  return DebuggerSettings.getInstance().FORCE_CLASSIC_VM;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:DebuggerManagerImpl.java


示例2: shouldAddXdebugKey

import com.intellij.openapi.projectRoots.JdkUtil; //导入依赖的package包/类
private static boolean shouldAddXdebugKey(Sdk jdk) {
  if (jdk == null) {
    return true; // conservative choice
  }
  if (DebuggerSettings.getInstance().DISABLE_JIT) {
    return true;
  }

  //if (ApplicationManager.getApplication().isUnitTestMode()) {
  // need this in unit tests to avoid false alarms when comparing actual output with expected output
  //return true;
  //}

  final String version = JdkUtil.getJdkMainAttribute(jdk, Attributes.Name.IMPLEMENTATION_VERSION);
  return version == null ||
         //version.startsWith("1.5") ||
         version.startsWith("1.4") ||
         version.startsWith("1.3") ||
         version.startsWith("1.2") ||
         version.startsWith("1.1") ||
         version.startsWith("1.0");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:DebuggerManagerImpl.java


示例3: runJython

import com.intellij.openapi.projectRoots.JdkUtil; //导入依赖的package包/类
public static ProcessOutput runJython(String workDir, String pythonPath, String... args) throws ExecutionException {
  final SimpleJavaSdkType sdkType = new SimpleJavaSdkType();
  final Sdk ideaJdk = sdkType.createJdk("tmp", SystemProperties.getJavaHome());
  SimpleJavaParameters parameters = new SimpleJavaParameters();
  parameters.setJdk(ideaJdk);
  parameters.setMainClass("org.python.util.jython");

  File jythonJar = new File(PythonHelpersLocator.getPythonCommunityPath(), "lib/jython.jar");
  parameters.getClassPath().add(jythonJar.getPath());

  parameters.getProgramParametersList().add("-Dpython.path=" + pythonPath + File.pathSeparator + workDir);
  parameters.getProgramParametersList().addAll(args);
  parameters.setWorkingDirectory(workDir);

  final GeneralCommandLine commandLine = JdkUtil.setupJVMCommandLine(sdkType.getVMExecutablePath(ideaJdk), parameters, false);
  final CapturingProcessHandler processHandler = new CapturingProcessHandler(commandLine.createProcess());
  return processHandler.runProcess();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JythonUnitTestUtil.java


示例4: shouldForceNoJIT

import com.intellij.openapi.projectRoots.JdkUtil; //导入依赖的package包/类
private static boolean shouldForceNoJIT(Sdk jdk)
{
	if(DebuggerSettings.getInstance().DISABLE_JIT)
	{
		return true;
	}
	if(jdk != null)
	{
		final String version = JdkUtil.getJdkMainAttribute(jdk, Attributes.Name.IMPLEMENTATION_VERSION);
		if(version != null && (version.startsWith("1.2") || version.startsWith("1.3")))
		{
			return true;
		}
	}
	return false;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:DebuggerManagerImpl.java


示例5: shouldAddXdebugKey

import com.intellij.openapi.projectRoots.JdkUtil; //导入依赖的package包/类
private static boolean shouldAddXdebugKey(Sdk jdk)
{
	if(jdk == null)
	{
		return true; // conservative choice
	}
	if(DebuggerSettings.getInstance().DISABLE_JIT)
	{
		return true;
	}

	//if (ApplicationManager.getApplication().isUnitTestMode()) {
	// need this in unit tests to avoid false alarms when comparing actual output with expected output
	//return true;
	//}

	final String version = JdkUtil.getJdkMainAttribute(jdk, Attributes.Name.IMPLEMENTATION_VERSION);
	return version == null ||
			//version.startsWith("1.5") ||
			version.startsWith("1.4") || version.startsWith("1.3") || version.startsWith("1.2") || version.startsWith("1.1") || version.startsWith("1.0");
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:22,代码来源:DebuggerManagerImpl.java


示例6: shouldForceNoJIT

import com.intellij.openapi.projectRoots.JdkUtil; //导入依赖的package包/类
private static boolean shouldForceNoJIT(Sdk jdk) {
  if (DebuggerSettings.getInstance().DISABLE_JIT) {
    return true;
  }
  if (jdk != null) {
    final String version = JdkUtil.getJdkMainAttribute(jdk, Attributes.Name.IMPLEMENTATION_VERSION);
    if (version != null && (version.startsWith("1.2") || version.startsWith("1.3"))) {
      return true;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:DebuggerManagerImpl.java


示例7: isJVMTIAvailable

import com.intellij.openapi.projectRoots.JdkUtil; //导入依赖的package包/类
private static boolean isJVMTIAvailable(Sdk jdk) {
  if (jdk == null) {
    return false; // conservative choice
  }

  final String version = JdkUtil.getJdkMainAttribute(jdk, Attributes.Name.IMPLEMENTATION_VERSION);
  if (version == null) {
    return false;
  }
  return !(version.startsWith("1.4") ||
           version.startsWith("1.3") ||
           version.startsWith("1.2") ||
           version.startsWith("1.1") ||
           version.startsWith("1.0"));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:DebuggerManagerImpl.java


示例8: detectJarVersion

import com.intellij.openapi.projectRoots.JdkUtil; //导入依赖的package包/类
@Nullable
public static String detectJarVersion(@NotNull String detectionClass, @NotNull Module module) {
  for (OrderEntry library : ModuleRootManager.getInstance(module).getOrderEntries()) {
    if (library instanceof LibraryOrderEntry) {
      VirtualFile jar = LibrariesHelper.getInstance().findJarByClass(((LibraryOrderEntry)library).getLibrary(), detectionClass);
      if (jar != null && jar.getFileSystem() instanceof JarFileSystem) {
        return JdkUtil.getJarMainAttribute(jar, Attributes.Name.IMPLEMENTATION_VERSION);
      }
    }
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:JarVersionDetectionUtil.java


示例9: createAlternativeJdk

import com.intellij.openapi.projectRoots.JdkUtil; //导入依赖的package包/类
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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:JavaParametersUtil.java


示例10: getVersionByJarManifest

import com.intellij.openapi.projectRoots.JdkUtil; //导入依赖的package包/类
@Nullable
private static String getVersionByJarManifest(@NotNull VirtualFile file) {
  String version = JdkUtil.getJarMainAttribute(file, Attributes.Name.IMPLEMENTATION_VERSION);
  if (version == null) return null;

  Matcher versionMatcher = DIGIT_VERSION_PATTERN.matcher(version);
  if (!versionMatcher.matches()) return null;

  return versionMatcher.group(1);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:LibraryJarUsagesCollector.java


示例11: validateJdkLocation

import com.intellij.openapi.projectRoots.JdkUtil; //导入依赖的package包/类
@Nullable
public static String validateJdkLocation(@Nullable File location) {
  if (location == null) {
    return "Path is empty";
  }
  if (!JdkUtil.checkForJdk(location)) {
    return "Path specified is not a valid JDK location";
  }
  if (!isJdk7(location)) {
    return "JDK 7.0 or newer is required";
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:JdkDetection.java


示例12: doGetGradleJdk

import com.intellij.openapi.projectRoots.JdkUtil; //导入依赖的package包/类
@Nullable
private Sdk doGetGradleJdk(@Nullable Project project, String linkedProjectPath) {
  if (project == null) {
    return null;
  }

  final GradleProjectSettings settings = GradleSettings.getInstance(project).getLinkedProjectSettings(linkedProjectPath);
  if (settings == null) {
    return null;
  }

  final String gradleJvm = settings.getGradleJvm();
  final Sdk sdk;
  try {
    sdk = ExternalSystemJdkUtil.getJdk(project, gradleJvm);
  }
  catch (ExternalSystemJdkException e) {
    throw new ExternalSystemJdkException(
      String.format("Invalid Gradle JDK configuration found. <a href='%s'>Open Gradle Settings</a> \n",
                    OpenExternalSystemSettingsCallback.ID),
      linkedProjectPath, e, OpenExternalSystemSettingsCallback.ID);
  }

  if (sdk == null && gradleJvm != null) {
    throw new ExternalSystemJdkException(
      String.format("Invalid Gradle JDK configuration found. <a href='%s'>Open Gradle Settings</a> \n",
                    OpenExternalSystemSettingsCallback.ID),
      linkedProjectPath, null, OpenExternalSystemSettingsCallback.ID);
  }

  final File sdkHomePath = sdk != null && sdk.getHomePath() != null ? new File(sdk.getHomePath()) : null;
  if (sdkHomePath != null && JdkUtil.checkForJre(sdkHomePath.getPath()) && !JdkUtil.checkForJdk(sdkHomePath)) {
    throw new ExternalSystemJdkException(
      String.format("Please, use JDK instead of JRE for Gradle importer. <a href='%s'>Open Gradle Settings</a> \n",
                    OpenExternalSystemSettingsCallback.ID),
      linkedProjectPath, null, OpenExternalSystemSettingsCallback.ID);
  }
  return sdk;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:GradleInstallationManager.java


示例13: createAlternativeJdk

import com.intellij.openapi.projectRoots.JdkUtil; //导入依赖的package包/类
private 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 String versionString = SdkVersionUtil.detectJdkVersion(jreHome);
    final Sdk jdk = new SimpleJavaSdkType().createJdk(versionString != null ? versionString : "", jreHome);
    if (jdk == null) throw CantRunException.noJdkConfigured();
    return jdk;
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:16,代码来源:XQueryRunProfileState.java


示例14: shouldForceClassicVM

import com.intellij.openapi.projectRoots.JdkUtil; //导入依赖的package包/类
/**
 * for Target JDKs versions 1.2.x - 1.3.0 the Classic VM should be used for debugging
 */
private static boolean shouldForceClassicVM(Sdk jdk)
{
	if(SystemInfo.isMac)
	{
		return false;
	}
	if(jdk == null)
	{
		return false;
	}

	String version = JdkUtil.getJdkMainAttribute(jdk, Attributes.Name.IMPLEMENTATION_VERSION);
	if(version == null || StringUtil.compareVersionNumbers(version, "1.4") >= 0)
	{
		return false;
	}

	if(version.startsWith("1.2") && SystemInfo.isWindows)
	{
		return true;
	}
	version += ".0";
	if(version.startsWith("1.3.0") && SystemInfo.isWindows)
	{
		return true;
	}
	if((version.startsWith("1.3.1_07") || version.startsWith("1.3.1_08")) && SystemInfo.isWindows)
	{
		return false; // fixes bug for these JDKs that it cannot start with -classic option
	}
	return DebuggerSettings.getInstance().FORCE_CLASSIC_VM;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:36,代码来源:DebuggerManagerImpl.java


示例15: isJVMTIAvailable

import com.intellij.openapi.projectRoots.JdkUtil; //导入依赖的package包/类
private static boolean isJVMTIAvailable(Sdk jdk)
{
	if(jdk == null)
	{
		return false; // conservative choice
	}

	final String version = JdkUtil.getJdkMainAttribute(jdk, Attributes.Name.IMPLEMENTATION_VERSION);
	if(version == null)
	{
		return false;
	}
	return !(version.startsWith("1.4") || version.startsWith("1.3") || version.startsWith("1.2") || version.startsWith("1.1") || version.startsWith("1.0"));
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:15,代码来源:DebuggerManagerImpl.java


示例16: patchJavaParameters

import com.intellij.openapi.projectRoots.JdkUtil; //导入依赖的package包/类
@Override
public void patchJavaParameters(Executor executor, RunProfile configuration, JavaParameters javaParameters) {
  if (!executor.getId().equals(DefaultDebugExecutor.EXECUTOR_ID)) {
    return;
  }

  if (!GroovyDebuggerSettings.getInstance().ENABLE_GROOVY_HOTSWAP) {
    return;
  }

  if (hasSpringLoadedReloader(javaParameters)) {
    return;
  }

  if (!(configuration instanceof RunConfiguration)) {
    return;
  }

  final Project project = ((RunConfiguration)configuration).getProject();
  if (project == null) {
    return;
  }

  if (!LanguageLevelProjectExtension.getInstance(project).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5)) {
    return;
  }

  if (configuration instanceof ModuleBasedConfiguration) {
    final Module module = ((ModuleBasedConfiguration)configuration).getConfigurationModule().getModule();
    if (module != null) {
      final LanguageLevel level = LanguageLevelModuleExtensionImpl.getInstance(module).getLanguageLevel();
      if (level != null && !level.isAtLeast(LanguageLevel.JDK_1_5)) {
        return;
      }
    }
  }

  Sdk jdk = javaParameters.getJdk();
  if (jdk != null) {
    String vendor = JdkUtil.getJdkMainAttribute(jdk, Attributes.Name.IMPLEMENTATION_VENDOR);
    if (vendor != null && vendor.contains("IBM")) {
      LOG.info("Due to IBM JDK pecularities (IDEA-59070) we don't add groovy agent when running applications under it");
      return;
    }
  }

  if (!project.isDefault() && containsGroovyClasses(project)) {
    final String agentPath = handleSpacesInPath(getAgentJarPath());
    if (agentPath != null) {
      javaParameters.getVMParametersList().add("-javaagent:" + agentPath);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:54,代码来源:GroovyHotSwapper.java


示例17: createFromJavaParameters

import com.intellij.openapi.projectRoots.JdkUtil; //导入依赖的package包/类
public static GeneralCommandLine createFromJavaParameters(final SimpleJavaParameters javaParameters,
                                                          final Project project,
                                                          final boolean dynamicClasspath) throws CantRunException {
    return createFromJavaParameters(javaParameters, dynamicClasspath && JdkUtil.useDynamicClasspath(project));
}
 
开发者ID:asebak,项目名称:embeddedlinux-jvmdebugger-intellij,代码行数:6,代码来源:RemoteCommandLineBuilder.java


示例18: patchJavaParameters

import com.intellij.openapi.projectRoots.JdkUtil; //导入依赖的package包/类
public void patchJavaParameters(Executor executor, RunProfile configuration, JavaParameters javaParameters) {
  if (!executor.getId().equals(DefaultDebugExecutor.EXECUTOR_ID)) {
    return;
  }

  if (!GroovyDebuggerSettings.getInstance().ENABLE_GROOVY_HOTSWAP) {
    return;
  }

  if (hasSpringLoadedReloader(javaParameters)) {
    return;
  }

  if (!(configuration instanceof RunConfiguration)) {
    return;
  }

  final Project project = ((RunConfiguration)configuration).getProject();
  if (project == null) {
    return;
  }

  if (!LanguageLevelProjectExtension.getInstance(project).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5)) {
    return;
  }

  if (configuration instanceof ModuleBasedConfiguration) {
    final Module module = ((ModuleBasedConfiguration)configuration).getConfigurationModule().getModule();
    if (module != null) {
      final LanguageLevel level = LanguageLevelModuleExtension.getInstance(module).getLanguageLevel();
      if (level != null && !level.isAtLeast(LanguageLevel.JDK_1_5)) {
        return;
      }
    }
  }

  Sdk jdk = javaParameters.getJdk();
  if (jdk != null) {
    String vendor = JdkUtil.getJdkMainAttribute(jdk, Attributes.Name.IMPLEMENTATION_VENDOR);
    if (vendor != null && vendor.contains("IBM")) {
      LOG.info("Due to IBM JDK pecularities (IDEA-59070) we don't add groovy agent when running applications under it");
      return;
    }
  }

  if (!project.isDefault() && containsGroovyClasses(project)) {
    final String agentPath = handleSpacesInPath(getAgentJarPath());
    if (agentPath != null) {
      javaParameters.getVMParametersList().add("-javaagent:" + agentPath);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:53,代码来源:GroovyHotSwapper.java


示例19: checkAlternativeJRE

import com.intellij.openapi.projectRoots.JdkUtil; //导入依赖的package包/类
public static void checkAlternativeJRE(@Nullable String jrePath) throws RuntimeConfigurationWarning {
    if (StringUtil.isEmpty(jrePath) ||
            ProjectJdkTable.getInstance().findJdk(jrePath) == null && !JdkUtil.checkForJre(jrePath)) {
        throw new RuntimeConfigurationWarning(ExecutionBundle.message("jre.path.is.not.valid.jre.home.error.message", jrePath));
    }
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:7,代码来源:AlternativeJreValidator.java


示例20: createFromJavaParameters

import com.intellij.openapi.projectRoots.JdkUtil; //导入依赖的package包/类
private GeneralCommandLine createFromJavaParameters(final SimpleJavaParameters javaParameters,
                                                    final Project project) throws CantRunException {
    return createFromJavaParameters(javaParameters, JdkUtil.useDynamicClasspath(project));
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:5,代码来源:XQueryRunProfileState.java



注:本文中的com.intellij.openapi.projectRoots.JdkUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java V2TBSCertListGenerator类代码示例发布时间:2022-05-23
下一篇:
Java TypeConverterRegistry类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap