View | Details | Raw Unified | Return to bug 305122
Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (-9 / +14 lines)
Lines 1552-1560 Link Here
1552
	}
1552
	}
1553
	
1553
	
1554
	public void addNonChainingJar(IPath path) {
1554
	public void addNonChainingJar(IPath path) {
1555
		if (this.nonChainingJars == null)
1555
		if (this.nonChainingJars != null)
1556
			return;
1556
			this.nonChainingJars.add(path);
1557
		this.nonChainingJars.add(path);
1558
	}
1557
	}
1559
1558
1560
	/**
1559
	/**
Lines 2922-2928 Link Here
2922
	}
2921
	}
2923
	
2922
	
2924
	private Set loadNonChainingJarsCache() {
2923
	private Set loadNonChainingJarsCache() {
2925
		Set nonChainingJarsCache = Collections.synchronizedSet(new HashSet());
2924
		Set nonChainingJarsCache = new HashSet();
2926
		File nonChainingJarsFile = getNonChainingJarsFile();
2925
		File nonChainingJarsFile = getNonChainingJarsFile();
2927
		DataInputStream in = null;
2926
		DataInputStream in = null;
2928
		try {
2927
		try {
Lines 2944-2950 Link Here
2944
				}
2943
				}
2945
			}
2944
			}
2946
		}
2945
		}
2947
		return nonChainingJarsCache;
2946
		return Collections.synchronizedSet(nonChainingJarsCache);
2948
	}
2947
	}
2949
2948
2950
	private File getNonChainingJarsFile() {
2949
	private File getNonChainingJarsFile() {
Lines 2952-2960 Link Here
2952
	}
2951
	}
2953
	
2952
	
2954
	private Set getNonChainingJarsCache() throws CoreException {
2953
	private Set getNonChainingJarsCache() throws CoreException {
2955
		if (this.nonChainingJars != null)
2954
		// Even if there is one entry in the cache, just return it. It may not be 
2955
		// the complete cache, but avoid going through all the projects to populate the cache.
2956
		if (this.nonChainingJars != null && this.nonChainingJars.size() > 0) {
2956
			return this.nonChainingJars;
2957
			return this.nonChainingJars;
2957
		Set result = Collections.synchronizedSet(new HashSet());
2958
		}
2959
		Set result = new HashSet();
2958
		IJavaProject[] projects = getJavaModel().getJavaProjects();
2960
		IJavaProject[] projects = getJavaModel().getJavaProjects();
2959
		for (int i = 0, length = projects.length; i < length; i++) {
2961
		for (int i = 0, length = projects.length; i < length; i++) {
2960
			IJavaProject javaProject = projects[i];
2962
			IJavaProject javaProject = projects[i];
Lines 2969-2975 Link Here
2969
				}
2971
				}
2970
			}
2972
			}
2971
		}
2973
		}
2972
		return result;
2974
		this.nonChainingJars = Collections.synchronizedSet(result);
2975
		return this.nonChainingJars;
2973
	}
2976
	}
2974
2977
2975
	public void loadVariablesAndContainers() throws CoreException {
2978
	public void loadVariablesAndContainers() throws CoreException {
Lines 3648-3653 Link Here
3648
				info.forgetExternalTimestampsAndIndexes();
3651
				info.forgetExternalTimestampsAndIndexes();
3649
			}
3652
			}
3650
		}
3653
		}
3654
		resetNonChainingJarsCache();
3651
	}
3655
	}
3652
3656
3653
	/*
3657
	/*
Lines 3690-3696 Link Here
3690
	}
3694
	}
3691
	
3695
	
3692
	public void resetNonChainingJarsCache() {
3696
	public void resetNonChainingJarsCache() {
3693
		this.nonChainingJars = null;
3697
		if (this.nonChainingJars != null) 
3698
			this.nonChainingJars.clear();
3694
	}
3699
	}
3695
3700
3696
	/*
3701
	/*
(-)src/org/eclipse/jdt/core/tests/model/ClasspathTests.java (+62 lines)
Lines 6579-6583 Link Here
6579
		this.deleteProject("P");
6579
		this.deleteProject("P");
6580
	}
6580
	}
6581
}
6581
}
6582
/**
6583
 * @bug 302949: FUP of 302949
6584
 * Test that 
6585
 * 1) non-chaining jars are cached during classpath resolution and can be retrieved later on
6586
 * 2) A full save (after resetting the non chaining jars cache) caches the non-chaining jars information
6587
 * 3) when a project is deleted, the non-chaining jar cache is reset.
6588
 * 
6589
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=305122"
6590
 * @throws Exception
6591
 */
6592
public void testBug305122() throws Exception {
6593
	try {
6594
6595
		IJavaProject proj = this.createJavaProject("P", new String[] {}, "bin");
6596
		IClasspathEntry[] classpath = new IClasspathEntry[2];
6597
6598
		addLibrary(proj, "nonchaining.jar", null, new String[0], 
6599
				new String[] {
6600
					"META-INF/MANIFEST.MF",
6601
					"Manifest-Version: 1.0\n",
6602
				},
6603
				JavaCore.VERSION_1_4);
6604
		addLibrary(proj, "chaining.jar", null, new String[0], 
6605
				new String[] {
6606
					"META-INF/MANIFEST.MF",
6607
					"Manifest-Version: 1.0\n" +
6608
					"Class-Path: chained.jar\n",
6609
				},
6610
				JavaCore.VERSION_1_4);
6611
6612
		classpath[0] = JavaCore.newLibraryEntry(new Path("/P/nonchaining.jar"), null, null);
6613
		classpath[1] = JavaCore.newLibraryEntry(new Path("/P/chaining.jar"), null, null);
6614
		createFile("/P/chained.jar", "");
6615
		
6616
		proj.setRawClasspath(classpath, null);
6617
		waitForAutoBuild();
6618
		JavaModelManager manager = JavaModelManager.getJavaModelManager();
6619
		assertTrue("Non chaining Jar", manager.isNonChainingJar(classpath[0].getPath()));
6620
		assertFalse("Chaining Jar", manager.isNonChainingJar(classpath[1].getPath()));
6621
		
6622
		((JavaProject)proj).resetResolvedClasspath();
6623
		proj.getResolvedClasspath(true);
6624
		manager = JavaModelManager.getJavaModelManager();
6625
		assertTrue("Non chaining Jar", manager.isNonChainingJar(classpath[0].getPath()));
6626
		assertFalse("Chaining Jar", manager.isNonChainingJar(classpath[1].getPath()));
6627
6628
		((JavaProject)proj).resetResolvedClasspath();
6629
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
6630
		workspace.save(true, null);
6631
		assertTrue("Non chaining Jar", manager.isNonChainingJar(classpath[0].getPath()));
6632
		assertFalse("Chaining Jar", manager.isNonChainingJar(classpath[1].getPath()));
6633
		
6634
		this.deleteProject("P");
6635
		assertFalse("Chaining Jar", manager.isNonChainingJar(classpath[0].getPath()));
6636
		assertFalse("Chaining Jar", manager.isNonChainingJar(classpath[1].getPath()));
6637
		
6638
	} finally {
6639
		IProject proj = this.getProject("P");
6640
		if ( proj != null && proj.exists())
6641
			this.deleteProject("P");
6642
	}
6643
}
6582
6644
6583
}
6645
}

Return to bug 305122