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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/ClasspathEntry.java (+3 lines)
Lines 1827-1832 Link Here
1827
	 * @return a java model status describing the problem related to this classpath entry if any, a status object with code <code>IStatus.OK</code> if the entry is fine
1827
	 * @return a java model status describing the problem related to this classpath entry if any, a status object with code <code>IStatus.OK</code> if the entry is fine
1828
	 */
1828
	 */
1829
	public static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment, boolean referredByContainer){
1829
	public static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment, boolean referredByContainer){
1830
		if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
1831
			JavaModelManager.getJavaModelManager().removeFromInvalidArchiveCache(entry.getPath());
1832
		}
1830
		IJavaModelStatus status = validateClasspathEntry(project, entry, null, checkSourceAttachment, referredByContainer);
1833
		IJavaModelStatus status = validateClasspathEntry(project, entry, null, checkSourceAttachment, referredByContainer);
1831
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=171136 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=300136
1834
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=171136 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=300136
1832
		// Ignore class path errors from optional entries.
1835
		// Ignore class path errors from optional entries.
(-)model/org/eclipse/jdt/internal/core/DeltaProcessor.java (-5 / +5 lines)
Lines 954-960 Link Here
954
				// project does not exist -> ignore
954
				// project does not exist -> ignore
955
				continue;
955
				continue;
956
			}
956
			}
957
			boolean hasChainedJar = false;
957
			boolean deltaContainsModifiedJar = false;
958
			for (int j = 0; j < entries.length; j++){
958
			for (int j = 0; j < entries.length; j++){
959
				if (entries[j].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
959
				if (entries[j].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
960
					IPath entryPath = entries[j].getPath();
960
					IPath entryPath = entries[j].getPath();
Lines 1024-1030 Link Here
1024
								System.out.println("- External JAR ADDED, affecting root: "+root.getElementName()); //$NON-NLS-1$
1024
								System.out.println("- External JAR ADDED, affecting root: "+root.getElementName()); //$NON-NLS-1$
1025
							}
1025
							}
1026
							elementAdded(root, null, null);
1026
							elementAdded(root, null, null);
1027
							hasChainedJar |= !this.manager.isNonChainingJar(entryPath);
1027
							deltaContainsModifiedJar = true;
1028
							this.state.addClasspathValidation(javaProject); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=185733
1028
							this.state.addClasspathValidation(javaProject); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=185733
1029
							hasDelta = true;
1029
							hasDelta = true;
1030
						} else if (status == EXTERNAL_JAR_CHANGED) {
1030
						} else if (status == EXTERNAL_JAR_CHANGED) {
Lines 1033-1039 Link Here
1033
								System.out.println("- External JAR CHANGED, affecting root: "+root.getElementName()); //$NON-NLS-1$
1033
								System.out.println("- External JAR CHANGED, affecting root: "+root.getElementName()); //$NON-NLS-1$
1034
							}
1034
							}
1035
							contentChanged(root);
1035
							contentChanged(root);
1036
							hasChainedJar |= !this.manager.isNonChainingJar(entryPath);
1036
							deltaContainsModifiedJar = true;
1037
							hasDelta = true;
1037
							hasDelta = true;
1038
						} else if (status == EXTERNAL_JAR_REMOVED) {
1038
						} else if (status == EXTERNAL_JAR_REMOVED) {
1039
							PackageFragmentRoot root = (PackageFragmentRoot) javaProject.getPackageFragmentRoot(entryPath.toString());
1039
							PackageFragmentRoot root = (PackageFragmentRoot) javaProject.getPackageFragmentRoot(entryPath.toString());
Lines 1041-1047 Link Here
1041
								System.out.println("- External JAR REMOVED, affecting root: "+root.getElementName()); //$NON-NLS-1$
1041
								System.out.println("- External JAR REMOVED, affecting root: "+root.getElementName()); //$NON-NLS-1$
1042
							}
1042
							}
1043
							elementRemoved(root, null, null);
1043
							elementRemoved(root, null, null);
1044
							hasChainedJar |= !this.manager.isNonChainingJar(entryPath);
1044
							deltaContainsModifiedJar = true;
1045
							this.state.addClasspathValidation(javaProject); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=185733
1045
							this.state.addClasspathValidation(javaProject); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=185733
1046
							hasDelta = true;
1046
							hasDelta = true;
1047
						}
1047
						}
Lines 1049-1055 Link Here
1049
				}
1049
				}
1050
			}
1050
			}
1051
			
1051
			
1052
			if (hasChainedJar) {
1052
			if (deltaContainsModifiedJar) {
1053
				javaProject.resetResolvedClasspath();
1053
				javaProject.resetResolvedClasspath();
1054
			}
1054
			}
1055
		}
1055
		}
(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (+6 lines)
Lines 3086-3091 Link Here
3086
		return this.invalidArchives != null && this.invalidArchives.contains(path);
3086
		return this.invalidArchives != null && this.invalidArchives.contains(path);
3087
	}
3087
	}
3088
3088
3089
	public void removeFromInvalidArchiveCache(IPath path) {
3090
		if (this.invalidArchives != null) {
3091
			this.invalidArchives.remove(path);
3092
		}
3093
	}
3094
3089
	public void setClasspathBeingResolved(IJavaProject project, boolean classpathIsResolved) {
3095
	public void setClasspathBeingResolved(IJavaProject project, boolean classpathIsResolved) {
3090
	    if (classpathIsResolved) {
3096
	    if (classpathIsResolved) {
3091
	        getClasspathBeingResolved().add(project);
3097
	        getClasspathBeingResolved().add(project);
(-)src/org/eclipse/jdt/core/tests/model/ClasspathTests.java (+78 lines)
Lines 242-247 Link Here
242
	suite.addTest(new ClasspathTests("testExtraLibraries15"));
242
	suite.addTest(new ClasspathTests("testExtraLibraries15"));
243
	suite.addTest(new ClasspathTests("testExtraLibraries16"));
243
	suite.addTest(new ClasspathTests("testExtraLibraries16"));
244
	suite.addTest(new ClasspathTests("testExtraLibraries17"));
244
	suite.addTest(new ClasspathTests("testExtraLibraries17"));
245
	suite.addTest(new ClasspathTests("testExtraLibraries18"));
245
	suite.addTest(new ClasspathTests("testFixClasspath1"));
246
	suite.addTest(new ClasspathTests("testFixClasspath1"));
246
	suite.addTest(new ClasspathTests("testFixClasspath2"));
247
	suite.addTest(new ClasspathTests("testFixClasspath2"));
247
	suite.addTest(new ClasspathTests("testHasClasspathCycle"));
248
	suite.addTest(new ClasspathTests("testHasClasspathCycle"));
Lines 249-254 Link Here
249
	suite.addTest(new ClasspathTests("testInvalidClasspath2"));
250
	suite.addTest(new ClasspathTests("testInvalidClasspath2"));
250
	suite.addTest(new ClasspathTests("testInvalidExternalClassFolder"));
251
	suite.addTest(new ClasspathTests("testInvalidExternalClassFolder"));
251
	suite.addTest(new ClasspathTests("testInvalidExternalJar"));
252
	suite.addTest(new ClasspathTests("testInvalidExternalJar"));
253
	suite.addTest(new ClasspathTests("testTransitionFromInvalidToValidJar"));
252
	suite.addTest(new ClasspathTests("testInvalidInternalJar1"));
254
	suite.addTest(new ClasspathTests("testInvalidInternalJar1"));
253
	suite.addTest(new ClasspathTests("testInvalidInternalJar2"));
255
	suite.addTest(new ClasspathTests("testInvalidInternalJar2"));
254
	suite.addTest(new ClasspathTests("testInvalidSourceFolder"));
256
	suite.addTest(new ClasspathTests("testInvalidSourceFolder"));
Lines 4020-4025 Link Here
4020
	}
4022
	}
4021
}
4023
}
4022
/*
4024
/*
4025
 * Ensures that the correct delta is reported when changing the Class-Path: clause 
4026
 * of an external jar from not containing a chained jar to containing a chained jar.
4027
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=357425)
4028
 */
4029
public void testExtraLibraries18() throws Exception {
4030
	try {
4031
		IJavaProject p = createJavaProject("P");
4032
		addExternalLibrary(p, getExternalResourcePath("lib1.jar"), new String[0], 
4033
			new String[] {
4034
				"META-INF/MANIFEST.MF",
4035
				"Manifest-Version: 1.0\n"
4036
			},
4037
			JavaCore.VERSION_1_4);
4038
		refreshExternalArchives(p);		
4039
4040
		startDeltas();
4041
		org.eclipse.jdt.core.tests.util.Util.createJar(new String[0],
4042
			new String[] {
4043
				"META-INF/MANIFEST.MF",
4044
				"Manifest-Version: 1.0\n" +
4045
				"Class-Path: lib2.jar\n",
4046
			},
4047
			getExternalResourcePath("lib1.jar"),
4048
			JavaCore.VERSION_1_4);
4049
		createExternalFile("lib2.jar", "");
4050
4051
		refreshExternalArchives(p);
4052
		assertDeltas(
4053
			"Unexpected delta",
4054
			"P[*]: {CHILDREN | RESOLVED CLASSPATH CHANGED}\n" + 
4055
			"	"+ getExternalPath() + "lib1.jar[*]: {CONTENT | REORDERED | ARCHIVE CONTENT CHANGED}\n" + 
4056
			"	"+ getExternalPath() + "lib2.jar[+]: {}"
4057
				);
4058
	} finally {
4059
		stopDeltas();
4060
		deleteProject("P");
4061
		deleteExternalResource("lib1.jar");
4062
		deleteExternalResource("lib2.jar");
4063
	}
4064
}
4065
/*
4023
 * Ensures that a marker is removed if adding an internal jar that is on the classpath in another project
4066
 * Ensures that a marker is removed if adding an internal jar that is on the classpath in another project
4024
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=213723 )
4067
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=213723 )
4025
 */
4068
 */
Lines 4201-4206 Link Here
4201
	}
4244
	}
4202
}
4245
}
4203
/*
4246
/*
4247
 * Ensures that validateClasspathEntry() sees a transition from an invalid/missing jar to a valid jar.
4248
 */
4249
public void testTransitionFromInvalidToValidJar() throws CoreException, IOException {
4250
	String transitioningJarName = "transitioningJar.jar";
4251
	String transitioningJar = getExternalPath() + transitioningJarName;
4252
	String nonExistingJar = getExternalPath() + "nonExisting.jar";
4253
	IClasspathEntry transitioningEntry = JavaCore.newLibraryEntry(new Path(transitioningJar), null, null);
4254
	IClasspathEntry nonExistingEntry = JavaCore.newLibraryEntry(new Path(nonExistingJar), null, null);
4255
4256
	try {
4257
		IJavaProject proj = createJavaProject("P", new String[] {}, new String[] {transitioningJar, nonExistingJar}, "bin");
4258
		
4259
		IJavaModelStatus status1 = ClasspathEntry.validateClasspathEntry(proj, transitioningEntry, false, false);
4260
		IJavaModelStatus status2 = ClasspathEntry.validateClasspathEntry(proj, nonExistingEntry, false, false);
4261
		assertFalse("Non-existing jar should be invalid", status1.isOK());
4262
		assertFalse("Non-existing jar should be invalid", status2.isOK());
4263
4264
		Util.createJar(	
4265
			new String[0],
4266
			new String[] {
4267
				"META-INF/MANIFEST.MF",
4268
				"Manifest-Version: 1.0\n"
4269
			},
4270
			transitioningJar,
4271
			JavaCore.VERSION_1_4);
4272
		status1 = ClasspathEntry.validateClasspathEntry(proj, transitioningEntry, false, false);
4273
		status2 = ClasspathEntry.validateClasspathEntry(proj, nonExistingEntry, false, false);
4274
		assertTrue("Existing jar should be valid", status1.isOK());
4275
		assertFalse("Non-existing jar should be invalid", status2.isOK());
4276
	} finally {
4277
		deleteExternalResource(transitioningJarName);
4278
		deleteProject("P");
4279
	}
4280
}
4281
/*
4204
 * Ensures that a non existing internal jar cannot be put on the classpath.
4282
 * Ensures that a non existing internal jar cannot be put on the classpath.
4205
 */
4283
 */
4206
public void testInvalidInternalJar1() throws CoreException {
4284
public void testInvalidInternalJar1() throws CoreException {

Return to bug 357425