本文整理汇总了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);
}
}
}
示例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[] {};
}
示例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;
}
示例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);
}
示例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));
}
}
}
}
}
}
示例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()]);
}
示例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]);
}
}
示例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];
}