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- IJavaProject#findPackageFragmentRoots
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 (+43 lines)
Lines 6767-6772 Link Here
6767
		ContainerInitializer.setInitializer(null);
6767
		ContainerInitializer.setInitializer(null);
6768
	}
6768
	}
6769
}
6769
}
6770
/**
6771
 * @bug 324367: IJavaProject.findPackageFragmentRoots(IClasspathEntry cpe) returns empty list
6772
 * 
6773
 * Test that exported classpath entries from the referenced project are included when invoked
6774
 * the API org.eclipse.jdt.core.IJavaProject.findPackageFragmentRoots(IClasspathEntry)
6775
 * 
6776
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=324367"
6777
 * @throws Exception
6778
 */
6779
public void testBug324367() throws Exception {
6780
	try {
6781
		IJavaProject referencingProject = this.createJavaProject("ReferencingProject", new String[] {}, "bin");
6782
		IJavaProject referencedProject = this.createJavaProject("ReferencedProject", new String[] {"src"}, "bin");
6783
		
6784
		addLibrary(referencedProject, "lib.jar", null, new String[0], 
6785
				new String[] {
6786
				"META-INF/MANIFEST.MF",
6787
				"Manifest-Version: 1.0\n",
6788
			},
6789
			JavaCore.VERSION_1_4); 
6790
		IClasspathEntry[] classpath = new IClasspathEntry[2];
6791
		classpath[0] = JavaCore.newSourceEntry(new Path("/ReferencedProject/src"), new Path[0]);
6792
		classpath[1] = JavaCore.newLibraryEntry(new Path("/ReferencedProject/lib.jar"), null, null,true);
6793
		setClasspath(referencedProject, classpath);
6794
		classpath = new IClasspathEntry[1];
6795
		classpath[0] = JavaCore.newProjectEntry(new Path("/ReferencedProject"), false);
6796
		setClasspath(referencingProject, classpath);
6797
		
6798
	    IClasspathEntry referencedProjectCPE = null;
6799
	    IClasspathEntry[] rawClasspath = referencingProject.getRawClasspath();
6800
	    for(int index = 0; index < rawClasspath.length; index++) {
6801
	    	IClasspathEntry cpe = rawClasspath[index];
6802
	    	if (cpe.getPath().equals(referencedProject.getPath())) {
6803
	    		referencedProjectCPE = cpe;
6804
	    		break;
6805
	    	}
6806
	    }
6807
	    assertEquals("Incorrect package fragment roots", 2, referencingProject.findPackageFragmentRoots(referencedProjectCPE).length);
6808
	} finally {
6809
		deleteProject("ReferencingProject");
6810
		deleteProject("ReferencedProject");
6811
	}
6812
}
6770
6813
6771
6814
6772
}
6815
}

Return to bug 324367