当前位置: 首页>>代码示例>>Java>>正文


Java JavaRuntime.resolveRuntimeClasspathEntry方法代码示例

本文整理汇总了Java中org.eclipse.jdt.launching.JavaRuntime.resolveRuntimeClasspathEntry方法的典型用法代码示例。如果您正苦于以下问题:Java JavaRuntime.resolveRuntimeClasspathEntry方法的具体用法?Java JavaRuntime.resolveRuntimeClasspathEntry怎么用?Java JavaRuntime.resolveRuntimeClasspathEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.launching.JavaRuntime的用法示例。


在下文中一共展示了JavaRuntime.resolveRuntimeClasspathEntry方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getProjectClassPath

import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
public static void getProjectClassPath(IJavaProject project, List<File> dst) throws Exception {
	IRuntimeClasspathEntry [] rentries = JavaRuntime.computeUnresolvedRuntimeClasspath(project);
	for (IRuntimeClasspathEntry entry : rentries) {
		switch (entry.getType()) {
		case IClasspathEntry.CPE_SOURCE: 
			break;
		case IClasspathEntry.CPE_PROJECT:
			break;
		case IClasspathEntry.CPE_LIBRARY:
			break;
		case IClasspathEntry.CPE_VARIABLE:
			// JRE like entries
			IRuntimeClasspathEntry [] variableEntries  = JavaRuntime.resolveRuntimeClasspathEntry(entry, project);
			break;
		case IClasspathEntry.CPE_CONTAINER:
			IRuntimeClasspathEntry [] containerEntries  = JavaRuntime.resolveRuntimeClasspathEntry(entry, project);
			for (IRuntimeClasspathEntry containerentry : containerEntries) {
				dst.add(new File (containerentry.getLocation()));
			}
			break;
		default:
			throw new Exception("unsupported classpath entry "+entry);
		}
	}
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:26,代码来源:TestResourceGeneration.java

示例2: fromJavaRuntimeResolver

import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
private ISourceContainer[] fromJavaRuntimeResolver() throws CoreException {
  for (final IClasspathEntry cpe : jp.getRawClasspath()) {
    if (IClasspathEntry.CPE_CONTAINER == cpe.getEntryKind() && //
        IClasspathManager.CONTAINER_ID.equals(cpe.getPath().toString())) {
      final IRuntimeClasspathEntry newRuntimeContainerClasspathEntry = JavaRuntime.newRuntimeContainerClasspathEntry(cpe.getPath(),
          IRuntimeClasspathEntry.USER_CLASSES, jp);

      final IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry = JavaRuntime.resolveRuntimeClasspathEntry(
          newRuntimeContainerClasspathEntry, jp);

      // there is only one maven2 classpath container in a project return
      return JavaRuntime.getSourceContainers(resolveRuntimeClasspathEntry);
    }
  }

  return new ISourceContainer[] {};
}
 
开发者ID:bjmi,项目名称:m2e.sourcelookup,代码行数:18,代码来源:MyMvnSourceContainer.java

示例3: createClassLoader

import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
@Override
public URLClassLoader createClassLoader() throws SdkException, MalformedURLException {
  IJavaProject userProject = findUserProject();
  if (userProject != null) {
    IRuntimeClasspathEntry outputEntry = JavaRuntime.newDefaultProjectClasspathEntry(userProject);
    try {
      IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry =
          JavaRuntime.resolveRuntimeClasspathEntry(outputEntry, userProject);
      List<URL> urls = new ArrayList<URL>();
      for (IRuntimeClasspathEntry entry : resolveRuntimeClasspathEntry) {
        urls.add(new File(entry.getLocation()).toURI().toURL());
      }

      return new URLClassLoader(urls.toArray(NO_URLS), null);

    } catch (CoreException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }

  // TODO Auto-generated method stub
  return null;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:25,代码来源:GWTProjectsRuntime.java

示例4: computeClasspath

import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
private static String computeClasspath(GwtSdk gwtRuntime, String[] extraClassPath)
    throws CoreException {
  List<String> cpPaths = new ArrayList<String>();
  for (IClasspathEntry c : gwtRuntime.getClasspathEntries()) {
    if (c.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
      IJavaProject javaProject = JavaProjectUtilities.findJavaProject(c.getPath().toOSString());
      IRuntimeClasspathEntry projectRuntimeEntry = JavaRuntime.newDefaultProjectClasspathEntry(javaProject);
      IRuntimeClasspathEntry[] resolvedEntries = JavaRuntime.resolveRuntimeClasspathEntry(
          projectRuntimeEntry, javaProject);
      for (IRuntimeClasspathEntry resolvedEntry : resolvedEntries) {
        cpPaths.add(resolvedEntry.getLocation());
      }
    } else {
      cpPaths.add(c.getPath().toFile().getAbsolutePath());
    }
  }
  if (extraClassPath != null) {
    cpPaths.addAll(Arrays.asList(extraClassPath));
  }
  return ProcessUtilities.buildClasspathString(cpPaths);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:22,代码来源:WebAppProjectCreatorRunner.java

示例5: collectReferencedElements

import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
private void collectReferencedElements(IJavaProject project, HashSet<JavadocLinkRef> result) throws CoreException {
	IRuntimeClasspathEntry[] unresolved = JavaRuntime.computeUnresolvedRuntimeClasspath(project);
	for (int i= 0; i < unresolved.length; i++) {
		IRuntimeClasspathEntry curr= unresolved[i];
		if (curr.getType() == IRuntimeClasspathEntry.PROJECT) {
			result.add(new JavadocLinkRef(JavaCore.create((IProject) curr.getResource())));
		} else {
			IRuntimeClasspathEntry[] entries= JavaRuntime.resolveRuntimeClasspathEntry(curr, project);
			for (int k = 0; k < entries.length; k++) {
				IRuntimeClasspathEntry entry= entries[k];
				if (entry.getType() == IRuntimeClasspathEntry.PROJECT) {
					result.add(new JavadocLinkRef(JavaCore.create((IProject) entry.getResource())));
				} else if (entry.getType() == IRuntimeClasspathEntry.ARCHIVE) {
					IClasspathEntry classpathEntry= entry.getClasspathEntry();
					if (classpathEntry != null) {
						IPath containerPath= null;
						if (curr.getType() == IRuntimeClasspathEntry.CONTAINER) {
							containerPath= curr.getPath();
						}
						result.add(new JavadocLinkRef(containerPath, classpathEntry, project));
					}
				}
			}
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:JavadocStandardWizardPage.java

示例6: resolveRuntimeClasspathEntry

import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
public IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry(IRuntimeClasspathEntry entry,
        IJavaProject project) throws CoreException {
    if (!(entry instanceof IRuntimeClasspathEntry2)) {
        if (entry.getType() == IRuntimeClasspathEntry.CONTAINER) {
            return computeDefaultContainerEntries(entry, project);
        }
        return new IRuntimeClasspathEntry[] {entry};
    }

    IRuntimeClasspathEntry[] entries = ((IRuntimeClasspathEntry2) entry).getRuntimeClasspathEntries(null);
    List<IRuntimeClasspathEntry> resolved = new ArrayList<>();
    for (IRuntimeClasspathEntry ent : entries) {
        IRuntimeClasspathEntry[] temp = JavaRuntime.resolveRuntimeClasspathEntry(ent, project);
        Collections.addAll(resolved, temp);
    }
    return resolved.toArray(new IRuntimeClasspathEntry[resolved.size()]);
}
 
开发者ID:apache,项目名称:ant-ivyde,代码行数:18,代码来源:IvyDERuntimeClasspathEntryResolver.java

示例7: addStandardClasspathEntries

import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
private void addStandardClasspathEntries(Set<IRuntimeClasspathEntry> all, IRuntimeClasspathEntry entry,
    ILaunchConfiguration configuration) throws CoreException {
  IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveRuntimeClasspathEntry(entry, configuration);
  for(int j = 0; j < resolved.length; j++ ) {
    all.add(resolved[j]);
  }
}
 
开发者ID:fbricon,项目名称:wildfly-hive,代码行数:8,代码来源:MavenRuntimeClasspathProvider.java

示例8: getSourceContainers

import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
private static ISourceContainer[] getSourceContainers(IJavaProject project, Set<IRuntimeClasspathEntry> calculated) {
    if (project == null || !project.exists()) {
        return new ISourceContainer[0];
    }

    try {
        IRuntimeClasspathEntry[] unresolved = JavaRuntime.computeUnresolvedRuntimeClasspath(project);
        List<IRuntimeClasspathEntry> resolved = new ArrayList<>();
        for (IRuntimeClasspathEntry entry : unresolved) {
            for (IRuntimeClasspathEntry resolvedEntry : JavaRuntime.resolveRuntimeClasspathEntry(entry, project)) {
                if (!calculated.contains(resolvedEntry)) {
                    calculated.add(resolvedEntry);
                    resolved.add(resolvedEntry);
                }
            }
        }
        Set<ISourceContainer> containers = new LinkedHashSet<>();
        containers.addAll(Arrays.asList(
                JavaRuntime.getSourceContainers(resolved.toArray(new IRuntimeClasspathEntry[0]))));

        // Due to a known jdt java 9 support bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=525840,
        // it would miss some JRE libraries source containers when the debugger is running on JDK9.
        // As a workaround, recompute the possible source containers for JDK9 jrt-fs.jar libraries.
        IRuntimeClasspathEntry jrtFs = resolved.stream().filter(entry -> {
            return entry.getType() == IRuntimeClasspathEntry.ARCHIVE && entry.getPath().lastSegment().equals("jrt-fs.jar");
        }).findFirst().orElse(null);
        if (jrtFs != null && project.isOpen()) {
            IPackageFragmentRoot[] allRoots = project.getPackageFragmentRoots();
            for (IPackageFragmentRoot root : allRoots) {
                if (root.getPath().equals(jrtFs.getPath()) && isSourceAttachmentEqual(root, jrtFs)) {
                    containers.add(new PackageFragmentRootSourceContainer(root));
                }
            }
        }

        return containers.toArray(new ISourceContainer[0]);
    } catch (CoreException ex) {
     // do nothing.
    }

    return new ISourceContainer[0];
}
 
开发者ID:Microsoft,项目名称:java-debug,代码行数:43,代码来源:JdtUtils.java


注:本文中的org.eclipse.jdt.launching.JavaRuntime.resolveRuntimeClasspathEntry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。