View | Details | Raw Unified | Return to bug 324367 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/JavaProject.java (-1 / +3 lines)
Lines 1210-1219 Link Here
1210
			IClasspathEntry[] classpath = getRawClasspath();
1210
			IClasspathEntry[] classpath = getRawClasspath();
1211
			for (int i = 0, length = classpath.length; i < length; i++) {
1211
			for (int i = 0, length = classpath.length; i < length; i++) {
1212
				if (classpath[i].equals(entry)) { // entry may need to be resolved
1212
				if (classpath[i].equals(entry)) { // entry may need to be resolved
1213
					// https://bugs.eclipse.org/bugs/show_bug.cgi?id=324367
1214
					// consider referred projects as per API doc 
1213
					return
1215
					return
1214
						computePackageFragmentRoots(
1216
						computePackageFragmentRoots(
1215
							resolveClasspath(new IClasspathEntry[] {entry}),
1217
							resolveClasspath(new IClasspathEntry[] {entry}),
1216
							false, // don't retrieve exported roots
1218
							true,
1217
							null); /*no reverse map*/
1219
							null); /*no reverse map*/
1218
				}
1220
				}
1219
			}
1221
			}
(-)src/org/eclipse/jdt/core/tests/model/ClasspathTests.java (+44 lines)
Lines 6747-6751 Link Here
6747
		ContainerInitializer.setInitializer(null);
6747
		ContainerInitializer.setInitializer(null);
6748
	}
6748
	}
6749
}
6749
}
6750
/**
6751
 * @bug 324367: IJavaProject.findPackageFragmentRoots(IClasspathEntry cpe) returns empty list
6752
 * 
6753
 * Test that exported classpath entries from the referenced project are included when invoked
6754
 * the API org.eclipse.jdt.core.IJavaProject.findPackageFragmentRoots(IClasspathEntry)
6755
 * 
6756
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=324367"
6757
 * @throws Exception
6758
 */
6759
public void testBug324367() throws Exception {
6760
	try {
6761
		IJavaProject referencingProject = this.createJavaProject("ReferencingProject", new String[] {}, "bin");
6762
		IJavaProject referencedProject = this.createJavaProject("ReferencedProject", new String[] {}, "bin");
6763
		
6764
		addLibrary(referencedProject, "lib.jar", null, new String[0], 
6765
				new String[] {
6766
				"META-INF/MANIFEST.MF",
6767
				"Manifest-Version: 1.0\n",
6768
			},
6769
			JavaCore.VERSION_1_4); 
6770
		IClasspathEntry[] classpath = new IClasspathEntry[1];
6771
		classpath[0] = JavaCore.newLibraryEntry(new Path("/ReferencedProject/lib.jar"), null, null,true);
6772
		setClasspath(referencedProject, classpath);
6773
6774
		classpath = new IClasspathEntry[1];
6775
		classpath[0] = JavaCore.newProjectEntry(new Path("/ReferencedProject"), false);
6776
		setClasspath(referencingProject, classpath);
6777
		
6778
	    IClasspathEntry referencedProjectCPE = null;
6779
	    IClasspathEntry[] rawClasspath = referencingProject.getRawClasspath();
6780
	    for(int index = 0; index < rawClasspath.length; index++) {
6781
	    	IClasspathEntry cpe = rawClasspath[index];
6782
	    	if (cpe.getPath().equals(referencedProject.getPath())) {
6783
	    		referencedProjectCPE = cpe;
6784
	    		break;
6785
	    	}
6786
	    }
6787
	    assertEquals("No package fragment roots found referenced project", 1, referencingProject.findPackageFragmentRoots(referencedProjectCPE).length);
6788
6789
	} finally {
6790
		deleteProject("ReferencingProject");
6791
		deleteProject("ReferencedProject");
6792
	}
6793
}
6750
6794
6751
}
6795
}

Return to bug 324367