### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/JavaModelManager.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java,v retrieving revision 1.462 diff -u -r1.462 JavaModelManager.java --- model/org/eclipse/jdt/internal/core/JavaModelManager.java 2 Dec 2010 07:51:52 -0000 1.462 +++ model/org/eclipse/jdt/internal/core/JavaModelManager.java 10 Dec 2010 09:50:21 -0000 @@ -3965,38 +3965,23 @@ } void save(ISaveContext context) throws IOException, JavaModelException { - IProject project = context.getProject(); - if (project == null) { // save all projects if none specified (snapshot or full save) - saveProjects(getJavaModel().getJavaProjects()); - } - else { - saveProjects(new IJavaProject[] {JavaCore.create(project)}); - } - - switch (context.getKind()) { - case ISaveContext.FULL_SAVE : - // TODO (eric) - investigate after 3.3 if variables should be saved for a SNAPSHOT - case ISaveContext.SNAPSHOT : - // remove variables that should not be saved - HashMap varsToSave = null; - Iterator iterator = JavaModelManager.this.variables.entrySet().iterator(); - IEclipsePreferences defaultPreferences = getDefaultPreferences(); - while (iterator.hasNext()) { - Map.Entry entry = (Map.Entry) iterator.next(); - String varName = (String) entry.getKey(); - if (defaultPreferences.get(CP_VARIABLE_PREFERENCES_PREFIX + varName, null) != null // don't save classpath variables from the default preferences as there is no delta if they are removed - || CP_ENTRY_IGNORE_PATH.equals(entry.getValue())) { - - if (varsToSave == null) - varsToSave = new HashMap(JavaModelManager.this.variables); - varsToSave.remove(varName); - } - } - saveVariables(varsToSave != null ? varsToSave : JavaModelManager.this.variables); - break; - default : - // do nothing + saveProjects(getJavaModel().getJavaProjects()); + // remove variables that should not be saved + HashMap varsToSave = null; + Iterator iterator = JavaModelManager.this.variables.entrySet().iterator(); + IEclipsePreferences defaultPreferences = getDefaultPreferences(); + while (iterator.hasNext()) { + Map.Entry entry = (Map.Entry) iterator.next(); + String varName = (String) entry.getKey(); + if (defaultPreferences.get(CP_VARIABLE_PREFERENCES_PREFIX + varName, null) != null // don't save classpath variables from the default preferences as there is no delta if they are removed + || CP_ENTRY_IGNORE_PATH.equals(entry.getValue())) { + + if (varsToSave == null) + varsToSave = new HashMap(JavaModelManager.this.variables); + varsToSave.remove(varName); + } } + saveVariables(varsToSave != null ? varsToSave : JavaModelManager.this.variables); } private void saveAccessRule(ClasspathAccessRule rule) throws IOException { #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java,v retrieving revision 1.70 diff -u -r1.70 ClasspathInitializerTests.java --- src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java 25 Oct 2010 10:30:07 -0000 1.70 +++ src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java 10 Dec 2010 09:50:23 -0000 @@ -77,7 +77,7 @@ // All specified tests which do not belong to the class are skipped... static { // Names of tests to run: can be "testBugXXXX" or "BugXXXX") -// TESTS_NAMES = new String[] { "testContainerInitializer12" }; + TESTS_NAMES = new String[] { "testContainerInitializer26" }; // Numbers of tests to run: "test" will be run for each number of this array // TESTS_NUMBERS = new int[] { 2, 12 }; // Range numbers of tests to run: all tests between "test" and "test" will be run for { first, last } @@ -1034,6 +1034,37 @@ } } + +/* + * Ensures that the project references are updated on startup if the initializer gives a different value. + */ +public void testContainerInitializer26() throws CoreException { + try { + createProject("P1"); + createFile("/P1/lib.jar", ""); + ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P2", "/P1/lib.jar"})); + IJavaProject p2 = createJavaProject( + "P2", + new String[] {}, + new String[] {"org.eclipse.jdt.core.tests.model.TEST_CONTAINER"}, + ""); + ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P2", "/P1"})); + + waitForAutoBuild(); + getWorkspace().save(true/*full save*/, null/*no progress*/); + p2.getProject().close(null); // close the project after the save and before the shutdown + JavaModelManager.getJavaModelManager().shutdown(); + + startLogListening(); + simulateRestart(); + assertLogEquals(""); // there should be no log + + } finally { + stopLogListening(); + deleteProject("P1"); + deleteProject("P2"); + } +} public void testVariableInitializer01() throws CoreException { try { createProject("P1");