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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (+9 lines)
Lines 212-217 Link Here
212
	public static final String ANNOTATION_PROCESSOR_MANAGER_EXTPOINT_ID = "annotationProcessorManager" ;  //$NON-NLS-1$
212
	public static final String ANNOTATION_PROCESSOR_MANAGER_EXTPOINT_ID = "annotationProcessorManager" ;  //$NON-NLS-1$
213
213
214
	/**
214
	/**
215
	 * Name of the JVM parameter to specify whether or not referenced JAR should be resolved for container libraries.
216
	 */
217
	private static final String RESOLVE_REFERENCED_LIBRARIES_FOR_CONTAINERS = "resolveReferencedLibrariesForContainers"; //$NON-NLS-1$
218
	
219
	/**
215
	 * Special value used for recognizing ongoing initialization and breaking initialization cycles
220
	 * Special value used for recognizing ongoing initialization and breaking initialization cycles
216
	 */
221
	 */
217
	public final static IPath VARIABLE_INITIALIZATION_IN_PROGRESS = new Path("Variable Initialization In Progress"); //$NON-NLS-1$
222
	public final static IPath VARIABLE_INITIALIZATION_IN_PROGRESS = new Path("Variable Initialization In Progress"); //$NON-NLS-1$
Lines 257-262 Link Here
257
262
258
	public static boolean PERF_VARIABLE_INITIALIZER = false;
263
	public static boolean PERF_VARIABLE_INITIALIZER = false;
259
	public static boolean PERF_CONTAINER_INITIALIZER = false;
264
	public static boolean PERF_CONTAINER_INITIALIZER = false;
265
	// Non-static, which will give it a chance to retain the default when and if JavaModelManager is restarted.
266
	boolean resolveReferencedLibrariesForContainers = false;
260
267
261
	public final static ICompilationUnit[] NO_WORKING_COPY = new ICompilationUnit[0];
268
	public final static ICompilationUnit[] NO_WORKING_COPY = new ICompilationUnit[0];
262
269
Lines 1540-1545 Link Here
1540
		if (Platform.isRunning()) {
1547
		if (Platform.isRunning()) {
1541
			this.indexManager = new IndexManager();
1548
			this.indexManager = new IndexManager();
1542
			this.nonChainingJars = loadNonChainingJarsCache();
1549
			this.nonChainingJars = loadNonChainingJarsCache();
1550
			String includeContainerReferencedLib = System.getProperty(RESOLVE_REFERENCED_LIBRARIES_FOR_CONTAINERS);
1551
			this.resolveReferencedLibrariesForContainers = "true".equalsIgnoreCase(includeContainerReferencedLib); //$NON-NLS-1$
1543
		}
1552
		}
1544
	}
1553
	}
1545
1554
(-)model/org/eclipse/jdt/internal/core/JavaProject.java (-2 / +13 lines)
Lines 2671-2678 Link Here
2671
						if (cEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
2671
						if (cEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
2672
							// resolve ".." in library path
2672
							// resolve ".." in library path
2673
							cEntry = cEntry.resolvedDotDot();
2673
							cEntry = cEntry.resolvedDotDot();
2674
							// https://bugs.eclipse.org/bugs/show_bug.cgi?id=305037
2674
							// https://bugs.eclipse.org/bugs/show_bug.cgi?id=313965
2675
							// responsibility of resolving chained (referenced) libraries lies with the container
2675
							// Do not resolve if the system attribute is set to false	
2676
							if (resolveChainedLibraries
2677
									&& JavaModelManager.getJavaModelManager().resolveReferencedLibrariesForContainers
2678
									&& result.rawReverseMap.get(cEntry.getPath()) == null) {
2679
								// resolve Class-Path: in manifest
2680
								ClasspathEntry[] extraEntries = cEntry.resolvedChainedLibraries();
2681
								for (int k = 0, length2 = extraEntries.length; k < length2; k++) {
2682
									if (!rawLibrariesPath.contains(extraEntries[k].getPath())) {
2683
										addToResult(rawEntry, extraEntries[k], result, resolvedEntries, externalFoldersManager, referencedEntriesMap, false);
2684
									}
2685
								}
2686
							}
2676
						}
2687
						}
2677
						addToResult(rawEntry, cEntry, result, resolvedEntries, externalFoldersManager, referencedEntriesMap, false);
2688
						addToResult(rawEntry, cEntry, result, resolvedEntries, externalFoldersManager, referencedEntriesMap, false);
2678
					}
2689
					}
(-)src/org/eclipse/jdt/core/tests/model/ClasspathTests.java (+74 lines)
Lines 6673-6677 Link Here
6673
		JavaCore.removeClasspathVariable("MyVar", null);
6673
		JavaCore.removeClasspathVariable("MyVar", null);
6674
	}
6674
	}
6675
}
6675
}
6676
/**
6677
 * @bug 313965: Breaking change in classpath container API  
6678
 * Test that when the includeContainerReferencedLib system property is set to true, the referenced libraries
6679
 * for JARs from containers are resolved.
6680
 * 
6681
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=313965"
6682
 * @throws Exception
6683
 */
6684
public void testBug313965() throws Exception {
6685
	try {
6686
		simulateExit();
6687
		// Use the literal attribute and not constant. Attribute once documented is not supposed to change.
6688
		System.setProperty("resolveReferencedLibrariesForContainers", "true");
6689
		simulateRestart();
6690
		IJavaProject p = this.createJavaProject("P", new String[] {}, "bin");
6691
		addLibrary(p, "lib.jar", null, new String[0], 
6692
				new String[] {
6693
				"META-INF/MANIFEST.MF",
6694
				"Manifest-Version: 1.0\n" +
6695
				"Class-Path: lib1.jar\n",
6696
			},
6697
			JavaCore.VERSION_1_4); 
6698
		IClasspathEntry[] classpath = new IClasspathEntry[1];
6699
		ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P", "/P/lib.jar"}));
6700
		classpath[0] = JavaCore.newContainerEntry(new Path("org.eclipse.jdt.core.tests.model.TEST_CONTAINER"));
6701
		setClasspath(p, classpath);
6702
		createFile("/P/lib1.jar", "");
6703
6704
		IClasspathEntry[] resolvedClasspath = p.getResolvedClasspath(true);
6705
		assertClasspathEquals(resolvedClasspath, 
6706
				"/P/lib1.jar[CPE_LIBRARY][K_BINARY][isExported:false]\n" + 
6707
				"/P/lib.jar[CPE_LIBRARY][K_BINARY][isExported:false]");
6708
	} finally {
6709
		deleteProject("P");
6710
		ContainerInitializer.setInitializer(null);
6711
		simulateExit();
6712
		System.setProperty("resolveReferencedLibrariesForContainers", "");
6713
		simulateRestart();
6714
	}
6715
}
6716
/**
6717
 * @bug 313965: Breaking change in classpath container API  
6718
 * Test that when the includeContainerReferencedLib system property is set to false (or default), the referenced libraries
6719
 * for JARs from containers are NOT resolved or added to the project's classpath.
6720
 * 
6721
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=313965"
6722
 * @throws Exception
6723
 */
6724
public void testBug313965a() throws Exception {
6725
	try {
6726
		// Do not set the includeContainerReferencedLib system property (the default value is false)
6727
		IJavaProject p = this.createJavaProject("P", new String[] {}, "bin");
6728
		addLibrary(p, "lib.jar", null, new String[0], 
6729
				new String[] {
6730
				"META-INF/MANIFEST.MF",
6731
				"Manifest-Version: 1.0\n" +
6732
				"Class-Path: lib1.jar\n",
6733
			},
6734
			JavaCore.VERSION_1_4); 
6735
		IClasspathEntry[] classpath = new IClasspathEntry[1];
6736
		ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P", "/P/lib.jar"}));
6737
		classpath[0] = JavaCore.newContainerEntry(new Path("org.eclipse.jdt.core.tests.model.TEST_CONTAINER"));
6738
		setClasspath(p, classpath);
6739
6740
		createFile("/P/lib1.jar", "");
6741
6742
		IClasspathEntry[] resolvedClasspath = p.getResolvedClasspath(true);
6743
		assertClasspathEquals(resolvedClasspath, 
6744
				"/P/lib.jar[CPE_LIBRARY][K_BINARY][isExported:false]");
6745
	} finally {
6746
		deleteProject("P");
6747
		ContainerInitializer.setInitializer(null);
6748
	}
6749
}
6676
6750
6677
}
6751
}

Return to bug 313965