diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestCase.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestCase.java index 5c4d47d..5cb670e 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestCase.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestCase.java @@ -825,7 +825,7 @@ protected void setUp() throws Exception { if (JavaCore.getPlugin() != null) Indexer.getInstance().enableAutomaticIndexing(false); - super.setUp(); +// super.setUp(); // Store test class and its name when changing this.first = false; @@ -911,7 +911,7 @@ } protected void tearDown() throws Exception { - super.tearDown(); +// super.tearDown(); if (JavaCore.getPlugin() != null) Indexer.getInstance().enableAutomaticIndexing(true); diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaIndexTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaIndexTests.java index 1893d3f..91a68c5 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaIndexTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaIndexTests.java @@ -33,12 +33,13 @@ import org.eclipse.jdt.core.tests.util.Util; import org.eclipse.jdt.internal.core.JavaModelManager; import org.eclipse.jdt.internal.core.UserLibraryClasspathContainer; +import org.eclipse.jdt.internal.core.index.FileIndexLocation; import org.osgi.service.prefs.BackingStoreException; public class JavaIndexTests extends AbstractJavaSearchTests { static { - // TESTS_NAMES = new String[] {"testPlatformIndexFile"}; + TESTS_NAMES = new String[] {"testNonExistentIndexRestart10"}; } public JavaIndexTests(String name) { super(name); @@ -278,12 +279,21 @@ new File(jarFilePath).delete(); } } - + public void testNonExistentIndexRestart10() throws Exception { + for (int i=0; i<10; i++) { + System.out.println(i); + testNonExistentIndexRestart(); + tearDown(); + setUp(); + } + } + // test a non-existent index public void testNonExistentIndexRestart() throws CoreException, IOException { String indexFilePath = getExternalResourcePath("Test.index"); String jarFilePath = getExternalResourcePath("Test.jar"); try { + FileIndexLocation.cryOnWrite = false; createJar(new String[] { "pkg/Test.java", "package pkg;\n" + @@ -306,6 +316,7 @@ java.io.File indexFile = JavaModelManager.getIndexManager().getIndex(libPath, false, false).getIndexFile(); long modified = indexFile.lastModified(); assertEquals(modified, indexFile.lastModified()); + FileIndexLocation.cryOnWrite = true; simulateExitRestart(); getJavaModel().refreshExternalArchives(null,null); diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java index 0f389f4..41a3123 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java @@ -14,7 +14,6 @@ package org.eclipse.jdt.internal.core; import java.io.File; -import java.net.URL; import java.util.*; import org.eclipse.core.resources.IBuildConfiguration; @@ -1048,10 +1047,10 @@ // then index the jar this.manager.indexManager.indexLibrary(entryPath, project.getProject(), ((ClasspathEntry)entries[j]).getLibraryIndexLocation(), true); } else { - URL indexLocation = ((ClasspathEntry)entries[j]).getLibraryIndexLocation(); - if (indexLocation != null) { // force reindexing, this could be faster rather than maintaining the list - this.manager.indexManager.indexLibrary(entryPath, project.getProject(), indexLocation); - } +// URL indexLocation = ((ClasspathEntry)entries[j]).getLibraryIndexLocation(); +// if (indexLocation != null) { // force reindexing, this could be faster rather than maintaining the list +// this.manager.indexManager.indexLibrary(entryPath, project.getProject(), indexLocation); +// } externalArchivesStatus.put(entryPath, EXTERNAL_JAR_UNCHANGED); } } else { diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/FileIndexLocation.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/FileIndexLocation.java index 463720c..f675ab6 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/FileIndexLocation.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/FileIndexLocation.java @@ -21,6 +21,8 @@ public class FileIndexLocation extends IndexLocation { File indexFile; + + public static boolean cryOnWrite = false; public FileIndexLocation(File file) { super(file); @@ -39,6 +41,9 @@ @Override public boolean createNewFile() throws IOException { + if (cryOnWrite) { + System.err.println("WRITING"); + } File directory = this.indexFile.getParentFile(); if (directory != null && !directory.exists()) { directory.mkdirs(); diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java index 30b0c22..6b3009f 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java @@ -33,6 +33,7 @@ import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable; import org.eclipse.jdt.internal.compiler.util.Util; import org.eclipse.jdt.internal.core.JavaModelManager; +import org.eclipse.jdt.internal.core.index.FileIndexLocation; import org.eclipse.jdt.internal.core.index.Index; import org.eclipse.jdt.internal.core.index.IndexLocation; import org.eclipse.jdt.internal.core.search.JavaSearchDocument; @@ -54,6 +55,8 @@ this.resource = resource; this.indexFileURL = indexFile; this.forceIndexUpdate = updateIndex; + if (FileIndexLocation.cryOnWrite) + System.out.println("AddJarFileToIndex"); } public AddJarFileToIndex(IPath jarPath, IndexLocation indexFile, IndexManager manager) { this(jarPath, indexFile, manager, false); @@ -63,6 +66,8 @@ super(jarPath, manager); this.indexFileURL = indexFile; this.forceIndexUpdate = updateIndex; + if (FileIndexLocation.cryOnWrite) + System.out.println("AddJarFileToIndex"); } @Override public boolean equals(Object o) {