### Eclipse Workspace Patch 1.0 #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.48 diff -u -r1.48 ClasspathInitializerTests.java --- src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java 14 Mar 2007 08:18:39 -0000 1.48 +++ src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java 16 Apr 2007 16:26:36 -0000 @@ -830,13 +830,12 @@ try { createProject("P1"); createFile("/P1/lib.jar", ""); - ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P2", "/P1/lib.jar"})); + ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P2", "/P1/lib.jar", "P3", "/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[] {"P3", "/P1/lib.jar"})); createJavaProject( "P3", new String[] {}, @@ -849,7 +848,7 @@ getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.POST_CHANGE); // initialize to the same value - ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P2", "/P1/lib.jar"}) { + ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P2", "/P1/lib.jar", "P3", "/P1/lib.jar"}) { public void initialize(IPath containerPath, IJavaProject project) throws CoreException { // simulate concurrency (another thread is initializing all containers in parallel and thus this flag is set to true) JavaModelManager.getJavaModelManager().batchContainerInitializations = true; @@ -870,6 +869,32 @@ deleteProject("P3"); } } +/* + * Ensures that an unbound container marker is created if container is reset to null + * (regression test for 182204 Deleting a JRE referenced by container does not result in unbound container problem) + */ +public void testContainerInitializer18() throws CoreException { + try { + ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P1", "/P1/lib.jar"})); + IJavaProject p1 = createJavaProject( + "P1", + new String[] {}, + new String[] {"org.eclipse.jdt.core.tests.model.TEST_CONTAINER"}, + ""); + createFile("/P1/lib.jar", ""); + p1.getResolvedClasspath(true); + waitForAutoBuild(); + + ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[0])); + JavaCore.setClasspathContainer(new Path("org.eclipse.jdt.core.tests.model.TEST_CONTAINER"), new IJavaProject[] {p1}, new IClasspathContainer[] {null}, null); + assertMarkers( + "Unexpected markers", + "Unbound classpath container: \'org.eclipse.jdt.core.tests.model.TEST_CONTAINER\' in project \'P1\'", + p1); + } finally { + deleteProject("P1"); + } +} public void testVariableInitializer01() throws CoreException { try { #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.368 diff -u -r1.368 JavaModelManager.java --- model/org/eclipse/jdt/internal/core/JavaModelManager.java 13 Apr 2007 16:02:15 -0000 1.368 +++ model/org/eclipse/jdt/internal/core/JavaModelManager.java 16 Apr 2007 16:26:38 -0000 @@ -530,13 +530,18 @@ if (projectLength != 1) return false; final IClasspathContainer container = respectiveContainers[0]; - if (container == null) - return false; IJavaProject project = projects[0]; // optimize only if initializing, otherwise we are in a regular setContainer(...) call if (!containerIsInitializationInProgress(project, containerPath)) return false; IClasspathContainer previousContainer = containerGetDefaultToPreviousSession(project, containerPath); + if (container == null) { + if (previousContainer == null) { + containerPut(project, containerPath, null); + return true; + } + return false; + } final IClasspathEntry[] newEntries = container.getClasspathEntries(); if (previousContainer == null) if (newEntries.length == 0) { @@ -1528,21 +1533,6 @@ } else { container = initializeContainer(project, containerPath); } - if (container == null) { // initializer failed to do its job: redirect to the failure container - ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(containerPath.segment(0)); - if (initializer == null) { - // create a dummy initializer and get the default failure container - container = (new ClasspathContainerInitializer() { - public void initialize(IPath path, IJavaProject javaProject) throws CoreException { - // not used - } - }).getFailureContainer(containerPath, project); - } else { - container = initializer.getFailureContainer(containerPath, project); - } - if (container != null) - containerPut(project, containerPath, container); - } } return container; } @@ -2206,7 +2196,13 @@ // retrieve value (if initialization was successful) container = containerGet(project, containerPath); - if (container == CONTAINER_INITIALIZATION_IN_PROGRESS) return null; // break cycle + if (container == CONTAINER_INITIALIZATION_IN_PROGRESS) { + // initializer failed to do its job: redirect to the failure container + container = initializer.getFailureContainer(containerPath, project); + if (container == null) + return null; // break cycle + containerPut(project, containerPath, container); + } ok = true; } catch (CoreException e) { if (e instanceof JavaModelException) { @@ -2237,6 +2233,12 @@ if (CP_RESOLVE_VERBOSE_ADVANCED) verbose_container_value_after_initialization(project, containerPath, container); } else { + // create a dummy initializer and get the default failure container + container = (new ClasspathContainerInitializer() { + public void initialize(IPath path, IJavaProject javaProject) throws CoreException { + // not used + } + }).getFailureContainer(containerPath, project); if (CP_RESOLVE_VERBOSE_ADVANCED) verbose_no_container_initializer_found(project, containerPath); }