[r352] Bug 297039 - Debugger opens ".java" files instead of ".class" files if target platform is inside the workspace
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/JavaSourceLookupUtil.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/JavaSourceLookupUtil.java
index 8921339..76468c0 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/JavaSourceLookupUtil.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/JavaSourceLookupUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -150,76 +150,51 @@
*/
private static IPackageFragmentRoot getPackageFragmentRoot(IRuntimeClasspathEntry entry) {
IResource resource = entry.getResource();
- if (resource == null) {
- // Check all package fragment roots for case of external archive.
- // External jars are shared, so it does not matter which project it
- // originates from
- IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
- Path entryPath = new Path(entry.getLocation());
+ if (resource != null) {
+ // find package fragment associated with the resource
+ IProject project = resource.getProject();
+ IJavaProject jp = JavaCore.create(project);
try {
- IJavaProject[] jps = model.getJavaProjects();
- for (int i = 0; i < jps.length; i++) {
- IJavaProject jp = jps[i];
- IProject p = jp.getProject();
- if (p.isOpen()) {
- IPackageFragmentRoot[] allRoots = jp.getPackageFragmentRoots();
- for (int j = 0; j < allRoots.length; j++) {
- IPackageFragmentRoot root = allRoots[j];
- if (root.isExternal() && root.getPath().equals(entryPath)) {
- if (isSourceAttachmentEqual(root, entry)) {
- // use package fragment root
- return root;
- }
- }
+ if (project.isOpen() && jp.exists()) {
+ IPackageFragmentRoot root = jp.findPackageFragmentRoot(resource.getFullPath());
+ if (root != null) {
+ // ensure source attachment paths match
+ if (isSourceAttachmentEqual(root, entry)) {
+ // use package fragment root
+ return root;
}
}
}
} catch (JavaModelException e) {
LaunchingPlugin.log(e);
}
- } else {
- // check if the archive is a package fragment root
- IProject project = resource.getProject();
- IJavaProject jp = JavaCore.create(project);
- try {
- if (project.isOpen() && jp.exists()) {
- IPackageFragmentRoot root = jp.getPackageFragmentRoot(resource);
+ }
+ // Check all package fragment roots for case of external archive.
+ // External jars are shared, so it does not matter which project it
+ // originates from
+ IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
+ Path entryPath = new Path(entry.getLocation());
+ try {
+ IJavaProject[] jps = model.getJavaProjects();
+ for (int i = 0; i < jps.length; i++) {
+ IJavaProject jp = jps[i];
+ IProject p = jp.getProject();
+ if (p.isOpen()) {
IPackageFragmentRoot[] allRoots = jp.getPackageFragmentRoots();
for (int j = 0; j < allRoots.length; j++) {
- if (allRoots[j].equals(root)) {
- // ensure source attachment paths match
+ IPackageFragmentRoot root = allRoots[j];
+ if (root.isExternal() && root.getPath().equals(entryPath)) {
if (isSourceAttachmentEqual(root, entry)) {
// use package fragment root
return root;
- }
- }
- }
-
- }
- // check all other java projects to see if another project references
- // the archive
- IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
- IJavaProject[] jps = model.getJavaProjects();
- for (int i = 0; i < jps.length; i++) {
- IJavaProject jp1 = jps[i];
- IProject p = jp1.getProject();
- if (p.isOpen()) {
- IPackageFragmentRoot[] allRoots = jp1.getPackageFragmentRoots();
- for (int j = 0; j < allRoots.length; j++) {
- IPackageFragmentRoot root = allRoots[j];
- if (!root.isExternal() && root.getPath().equals(entry.getPath())) {
- if (isSourceAttachmentEqual(root, entry)) {
- // use package fragment root
- return root;
- }
- }
+ }
}
}
}
- } catch (JavaModelException e) {
- LaunchingPlugin.log(e);
- }
- }
+ }
+ } catch (JavaModelException e) {
+ LaunchingPlugin.log(e);
+ }
return null;
}
}
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/RuntimeClasspathEntry.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/RuntimeClasspathEntry.java
index ae83131..260cc33 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/RuntimeClasspathEntry.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/RuntimeClasspathEntry.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -324,10 +324,6 @@
protected IResource getResource(IPath path) {
if (path != null) {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- if (path.getDevice() == null) {
- // search relative to the workspace if no device present
- return root.findMember(path);
- }
// look for files or folders with the given path
IFile[] files = root.findFilesForLocation(path);
if (files.length > 0) {
@@ -337,6 +333,10 @@
if (containers.length > 0) {
return containers[0];
}
+ if (path.getDevice() == null) {
+ // search relative to the workspace if no device present
+ return root.findMember(path);
+ }
}
return null;
}