### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java,v retrieving revision 1.97 diff -u -r1.97 ReconcilerTests.java --- src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java 11 Apr 2006 13:31:48 -0000 1.97 +++ src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java 14 Apr 2006 15:28:05 -0000 @@ -11,6 +11,7 @@ package org.eclipse.jdt.core.tests.model; +import java.io.File; import java.io.IOException; import junit.framework.Test; @@ -19,6 +20,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Path; import org.eclipse.jdt.core.*; import org.eclipse.jdt.core.compiler.CompilationParticipant; import org.eclipse.jdt.core.compiler.IProblem; @@ -805,6 +807,63 @@ " f2[*]: {CATEGORIES}" ); } +/* + * Ensures that changing and external jar and refreshing takes the change into account + * (regression test for bug + */ +public void testChangeExternalJar() throws CoreException, IOException { + IJavaProject project = getJavaProject("Reconciler"); + String jarPath = getExternalPath() + "lib.jar"; + try { + org.eclipse.jdt.core.tests.util.Util.createJar(new String[] { + "p/Y.java", + "package p;\n" + + "public class Y {\n" + + " public void foo() {\n" + + " }\n" + + "}" + }, jarPath, "1.4"); + addLibraryEntry(project, jarPath, false); + + // force Y.class file to be cached during resolution + setWorkingCopyContents( + "package p1;\n" + + "public class X extends p.Y {\n" + + " public void bar() {\n" + + " foo();\n" + + " }\n" + + "}"); + this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); + + // change jar and refresh + org.eclipse.jdt.core.tests.util.Util.createJar(new String[] { + "p/Y.java", + "package p;\n" + + "public class Y {\n" + + " public void foo(String s) {\n" + + " }\n" + + "}" + }, jarPath, "1.4"); + getJavaModel().refreshExternalArchives(null,null); + + setWorkingCopyContents( + "package p1;\n" + + "public class X extends p.Y {\n" + + " public void bar() {\n" + + " foo(\"a\");\n" + + " }\n" + + "}"); + this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); + assertProblems( + "Unexpected problems", + "----------\n" + + "----------\n" + ); + } finally { + removeLibraryEntry(project, new Path(jarPath)); + deleteFile(new File(jarPath)); + } +} /** * Ensures that the reconciler reconciles the new contents with the current * contents,updating the structure of this reconciler's compilation Index: src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java,v retrieving revision 1.164 diff -u -r1.164 AbstractJavaModelTests.java --- src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 6 Apr 2006 15:25:02 -0000 1.164 +++ src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 14 Apr 2006 15:28:04 -0000 @@ -1663,10 +1663,11 @@ protected void removeLibraryEntry(IJavaProject project, Path path) throws JavaModelException { IClasspathEntry[] entries = project.getRawClasspath(); int length = entries.length; - IClasspathEntry[] newEntries = new IClasspathEntry[length-1]; + IClasspathEntry[] newEntries = null; for (int i = 0; i < length; i++) { IClasspathEntry entry = entries[i]; if (entry.getPath().equals(path)) { + newEntries = new IClasspathEntry[length-1]; if (i > 0) System.arraycopy(entries, 0, newEntries, 0, i); if (i < length-1) @@ -1674,7 +1675,8 @@ break; } } - project.setRawClasspath(newEntries, null); + if (newEntries != null) + project.setRawClasspath(newEntries, null); } /** #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/DeltaProcessor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java,v retrieving revision 1.282 diff -u -r1.282 DeltaProcessor.java --- model/org/eclipse/jdt/internal/core/DeltaProcessor.java 29 Mar 2006 03:08:48 -0000 1.282 +++ model/org/eclipse/jdt/internal/core/DeltaProcessor.java 14 Apr 2006 15:28:08 -0000 @@ -309,6 +309,10 @@ if (hasDelta){ // force classpath marker refresh of affected projects JavaModel.flushExternalFileCache(); + + // flush jar type cache + JavaModelManager.getJavaModelManager().resetJarTypeCache(); + IJavaElementDelta[] projectDeltas = this.currentDelta.getAffectedChildren(); final int length = projectDeltas.length; final IProject[] projectsToTouch = new IProject[length];