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

(-)src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java (+59 lines)
Lines 11-16 Link Here
11
package org.eclipse.jdt.core.tests.model;
11
package org.eclipse.jdt.core.tests.model;
12
12
13
13
14
import java.io.File;
14
import java.io.IOException;
15
import java.io.IOException;
15
16
16
import junit.framework.Test;
17
import junit.framework.Test;
Lines 19-24 Link Here
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.OperationCanceledException;
22
import org.eclipse.core.runtime.OperationCanceledException;
23
import org.eclipse.core.runtime.Path;
22
import org.eclipse.jdt.core.*;
24
import org.eclipse.jdt.core.*;
23
import org.eclipse.jdt.core.compiler.CompilationParticipant;
25
import org.eclipse.jdt.core.compiler.CompilationParticipant;
24
import org.eclipse.jdt.core.compiler.IProblem;
26
import org.eclipse.jdt.core.compiler.IProblem;
Lines 805-810 Link Here
805
		"	f2[*]: {CATEGORIES}"
807
		"	f2[*]: {CATEGORIES}"
806
	);
808
	);
807
}
809
}
810
/*
811
 * Ensures that changing and external jar and refreshing takes the change into account
812
 * (regression test for bug 
813
 */
814
public void testChangeExternalJar() throws CoreException, IOException {
815
	IJavaProject project = getJavaProject("Reconciler");
816
	String jarPath = getExternalPath() + "lib.jar";
817
	try {
818
		org.eclipse.jdt.core.tests.util.Util.createJar(new String[] {
819
			"p/Y.java",
820
			"package p;\n" +
821
			"public class Y {\n" +
822
			"  public void foo() {\n" +
823
			"  }\n" +
824
			"}"
825
		}, jarPath, "1.4");
826
		addLibraryEntry(project, jarPath, false);
827
		
828
		// force Y.class file to be cached during resolution
829
		setWorkingCopyContents(
830
			"package p1;\n" +
831
			"public class X extends p.Y {\n" +
832
			"  public void bar() {\n" +
833
			"    foo();\n" +
834
			"  }\n" +
835
			"}");
836
		this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null);
837
		
838
		// change jar and refresh
839
		org.eclipse.jdt.core.tests.util.Util.createJar(new String[] {
840
			"p/Y.java",
841
			"package p;\n" +
842
			"public class Y {\n" +
843
			"  public void foo(String s) {\n" +
844
			"  }\n" +
845
			"}"
846
		}, jarPath, "1.4");
847
		getJavaModel().refreshExternalArchives(null,null);
848
		
849
		setWorkingCopyContents(
850
			"package p1;\n" +
851
			"public class X extends p.Y {\n" +
852
			"  public void bar() {\n" +
853
			"    foo(\"a\");\n" +
854
			"  }\n" +
855
			"}");
856
		this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null);
857
		assertProblems(
858
			"Unexpected problems", 
859
			"----------\n" + 
860
			"----------\n"
861
		);
862
	} finally {
863
		removeLibraryEntry(project, new Path(jarPath));
864
		deleteFile(new File(jarPath));
865
	}
866
}
808
/**
867
/**
809
 * Ensures that the reconciler reconciles the new contents with the current
868
 * Ensures that the reconciler reconciles the new contents with the current
810
 * contents,updating the structure of this reconciler's compilation
869
 * contents,updating the structure of this reconciler's compilation
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java (-2 / +4 lines)
Lines 1663-1672 Link Here
1663
	protected void removeLibraryEntry(IJavaProject project, Path path) throws JavaModelException {
1663
	protected void removeLibraryEntry(IJavaProject project, Path path) throws JavaModelException {
1664
		IClasspathEntry[] entries = project.getRawClasspath();
1664
		IClasspathEntry[] entries = project.getRawClasspath();
1665
		int length = entries.length;
1665
		int length = entries.length;
1666
		IClasspathEntry[] newEntries = new IClasspathEntry[length-1];
1666
		IClasspathEntry[] newEntries = null;
1667
		for (int i = 0; i < length; i++) {
1667
		for (int i = 0; i < length; i++) {
1668
			IClasspathEntry entry = entries[i];
1668
			IClasspathEntry entry = entries[i];
1669
			if (entry.getPath().equals(path)) {
1669
			if (entry.getPath().equals(path)) {
1670
				newEntries = new IClasspathEntry[length-1];
1670
				if (i > 0)
1671
				if (i > 0)
1671
					System.arraycopy(entries, 0, newEntries, 0, i);
1672
					System.arraycopy(entries, 0, newEntries, 0, i);
1672
				if (i < length-1)
1673
				if (i < length-1)
Lines 1674-1680 Link Here
1674
				break;
1675
				break;
1675
			}	
1676
			}	
1676
		}
1677
		}
1677
		project.setRawClasspath(newEntries, null);
1678
		if (newEntries != null)
1679
			project.setRawClasspath(newEntries, null);
1678
	}
1680
	}
1679
1681
1680
	/**
1682
	/**
(-)model/org/eclipse/jdt/internal/core/DeltaProcessor.java (+4 lines)
Lines 309-314 Link Here
309
			if (hasDelta){
309
			if (hasDelta){
310
				// force classpath marker refresh of affected projects
310
				// force classpath marker refresh of affected projects
311
				JavaModel.flushExternalFileCache();
311
				JavaModel.flushExternalFileCache();
312
				
313
				// flush jar type cache
314
				JavaModelManager.getJavaModelManager().resetJarTypeCache();
315
				
312
				IJavaElementDelta[] projectDeltas = this.currentDelta.getAffectedChildren();
316
				IJavaElementDelta[] projectDeltas = this.currentDelta.getAffectedChildren();
313
				final int length = projectDeltas.length;
317
				final int length = projectDeltas.length;
314
				final IProject[] projectsToTouch = new IProject[length];
318
				final IProject[] projectsToTouch = new IProject[length];

Return to bug 134110