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

(-)model/org/eclipse/jdt/internal/core/DeltaProcessor.java (-3 / +8 lines)
Lines 953-958 Link Here
953
				// project does not exist -> ignore
953
				// project does not exist -> ignore
954
				continue;
954
				continue;
955
			}
955
			}
956
			boolean hasChainedJar = false;
956
			for (int j = 0; j < entries.length; j++){
957
			for (int j = 0; j < entries.length; j++){
957
				if (entries[j].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
958
				if (entries[j].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
958
					IPath entryPath = entries[j].getPath();
959
					IPath entryPath = entries[j].getPath();
Lines 1022-1028 Link Here
1022
								System.out.println("- External JAR ADDED, affecting root: "+root.getElementName()); //$NON-NLS-1$
1023
								System.out.println("- External JAR ADDED, affecting root: "+root.getElementName()); //$NON-NLS-1$
1023
							}
1024
							}
1024
							elementAdded(root, null, null);
1025
							elementAdded(root, null, null);
1025
							javaProject.resetResolvedClasspath(); // in case it contains a chained jar
1026
							hasChainedJar |= !this.manager.isNonChainingJar(entryPath);
1026
							this.state.addClasspathValidation(javaProject); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=185733
1027
							this.state.addClasspathValidation(javaProject); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=185733
1027
							hasDelta = true;
1028
							hasDelta = true;
1028
						} else if (status == EXTERNAL_JAR_CHANGED) {
1029
						} else if (status == EXTERNAL_JAR_CHANGED) {
Lines 1031-1037 Link Here
1031
								System.out.println("- External JAR CHANGED, affecting root: "+root.getElementName()); //$NON-NLS-1$
1032
								System.out.println("- External JAR CHANGED, affecting root: "+root.getElementName()); //$NON-NLS-1$
1032
							}
1033
							}
1033
							contentChanged(root);
1034
							contentChanged(root);
1034
							javaProject.resetResolvedClasspath(); // in case it contains a chained jar
1035
							hasChainedJar |= !this.manager.isNonChainingJar(entryPath);
1035
							hasDelta = true;
1036
							hasDelta = true;
1036
						} else if (status == EXTERNAL_JAR_REMOVED) {
1037
						} else if (status == EXTERNAL_JAR_REMOVED) {
1037
							PackageFragmentRoot root = (PackageFragmentRoot) javaProject.getPackageFragmentRoot(entryPath.toString());
1038
							PackageFragmentRoot root = (PackageFragmentRoot) javaProject.getPackageFragmentRoot(entryPath.toString());
Lines 1039-1051 Link Here
1039
								System.out.println("- External JAR REMOVED, affecting root: "+root.getElementName()); //$NON-NLS-1$
1040
								System.out.println("- External JAR REMOVED, affecting root: "+root.getElementName()); //$NON-NLS-1$
1040
							}
1041
							}
1041
							elementRemoved(root, null, null);
1042
							elementRemoved(root, null, null);
1042
							javaProject.resetResolvedClasspath(); // in case it contains a chained jar
1043
							hasChainedJar |= !this.manager.isNonChainingJar(entryPath);
1043
							this.state.addClasspathValidation(javaProject); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=185733
1044
							this.state.addClasspathValidation(javaProject); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=185733
1044
							hasDelta = true;
1045
							hasDelta = true;
1045
						}
1046
						}
1046
					}
1047
					}
1047
				}
1048
				}
1048
			}
1049
			}
1050
			
1051
			if (hasChainedJar) {
1052
				javaProject.resetResolvedClasspath();
1053
			}
1049
		}
1054
		}
1050
		// ensure the external file cache is reset so that if a .jar file is deleted but no longer on the classpath, it won't appear as changed next time it is added
1055
		// ensure the external file cache is reset so that if a .jar file is deleted but no longer on the classpath, it won't appear as changed next time it is added
1051
		JavaModel.flushExternalFileCache();
1056
		JavaModel.flushExternalFileCache();
(-)src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java (-2 / +57 lines)
Lines 97-103 Link Here
97
//		"testPerfSearchAllTypeNamesAndReconcile",
97
//		"testPerfSearchAllTypeNamesAndReconcile",
98
//	};
98
//	};
99
99
100
//	TESTS_PREFIX = "testPerfReconcile";
100
	TESTS_PREFIX = "testRefreshExternalArchives";
101
}
101
}
102
public static Test suite() {
102
public static Test suite() {
103
	Test suite = buildSuite(testClass());
103
	Test suite = buildSuite(testClass());
Lines 347-353 Link Here
347
	}
347
	}
348
	assertEquals(message, expected, actual);
348
	assertEquals(message, expected, actual);
349
}
349
}
350
350
private void touchFiles(File[] files) {
351
	for(int index=0; index < files.length; index++) {
352
		files[index].setLastModified(System.currentTimeMillis());
353
	}
354
}
351
/*
355
/*
352
 * Creates a simple Java project with no source folder and only rt.jar on its classpath.
356
 * Creates a simple Java project with no source folder and only rt.jar on its classpath.
353
 */
357
 */
Lines 1371-1376 Link Here
1371
		System.out.println((System.currentTimeMillis()-startTime)+"ms");
1375
		System.out.println((System.currentTimeMillis()-startTime)+"ms");
1372
	}
1376
	}
1373
}
1377
}
1378
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=354332
1379
public void testRefreshExternalArchives() throws Exception {
1380
	int jarCount = 500;
1381
	File[] files = new File[jarCount];
1382
	IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
1383
	try {
1384
		IClasspathEntry[] classpath = new IClasspathEntry[jarCount];
1385
		for (int index = 0; index < jarCount; index++) {
1386
			String filePath = getExternalResourcePath("lib"+ index +".jar");
1387
			org.eclipse.jdt.core.tests.util.Util.createJar(new String[0],
1388
				new String[] {
1389
					"META-INF/MANIFEST.MF",
1390
					"Manifest-Version: 1.0\n",
1391
				},
1392
				filePath,
1393
				JavaCore.VERSION_1_4);
1394
			classpath[index] = JavaCore.newLibraryEntry(new Path(filePath), null, null);
1395
			files[index]  = new File(filePath);
1396
		}
1397
		BIG_PROJECT.setRawClasspath(classpath, null);
1398
		
1399
		// warm up
1400
		int max = 20;
1401
		int warmup = WARMUP_COUNT / 10;
1402
		for (int i = 0; i < warmup; i++) {
1403
			for (int j = 0; j < max; j++) {
1404
				touchFiles(files);
1405
				model.refreshExternalArchives(new IJavaElement[] {BIG_PROJECT}, null);
1406
			}
1407
		}
1408
1409
		// measure performance
1410
		for (int i = 0; i < MEASURES_COUNT; i++) {
1411
			runGc();
1412
			startMeasuring();
1413
			for (int j = 0; j < max; j++) {
1414
				touchFiles(files);
1415
				model.refreshExternalArchives(new IJavaElement[] {BIG_PROJECT}, null);
1416
			}
1417
			stopMeasuring();
1418
		}
1419
1420
		commitMeasurements();
1421
		assertPerformance();		
1422
		
1423
	} finally {
1424
		for(int index=0; index < files.length; index++) {
1425
			files[index].delete();
1426
		}
1427
	}
1428
}
1374
1429
1375
protected void resetCounters() {
1430
protected void resetCounters() {
1376
	// do nothing
1431
	// do nothing
(-)src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java (+16 lines)
Lines 1246-1249 Link Here
1246
		// Return created options map
1246
		// Return created options map
1247
		return optionsMap;
1247
		return optionsMap;
1248
	}
1248
	}
1249
1250
	protected String getExternalPath() {
1251
		String path = "";
1252
		try {
1253
			path = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getParentFile().getCanonicalPath();
1254
			if (path.charAt(path.length()-1) != File.separatorChar)
1255
				path += File.separatorChar;
1256
		} catch (IOException e) {
1257
			e.printStackTrace();
1258
		}
1259
		return path;
1260
	}
1261
1262
	protected String getExternalResourcePath(String relativePath) {
1263
		return getExternalPath() + relativePath;
1264
	}
1249
}
1265
}

Return to bug 354332