Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 208603 Details for
Bug 366544
[index] Test testUseIndexInternalJarAfterRestart failed on Mac and Linux
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
patch.txt (text/plain), 9.85 KB, created by
Satyam Kandula
on 2011-12-20 07:43:50 EST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Satyam Kandula
Created:
2011-12-20 07:43:50 EST
Size:
9.85 KB
patch
obsolete
>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 89d3a5a..0c18e57 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 >@@ -169,9 +169,10 @@ > } > > // Test that the same index file is used even after restarting >- public void _testUseIndexInternalJarAfterRestart() throws IOException, CoreException { >+ public void testUseIndexInternalJarAfterRestart() throws IOException, CoreException { > String indexFilePath = getExternalResourcePath("Test.index"); > String jarFilePath = "/P/Test.jar"; >+ String fullJarPath = getWorkspacePath() + jarFilePath; > try { > IJavaProject p = createJavaProject("P"); > createJar(new String[] { >@@ -179,8 +180,9 @@ > "package pkg;\n" + > "public class Test {\n" + > " protected Test(int i) {}\n" + >- "}"}, jarFilePath); >- JavaIndexer.generateIndexForJar(jarFilePath, indexFilePath); >+ "}"}, fullJarPath); >+ p.getProject().refreshLocal(1, null); >+ JavaIndexer.generateIndexForJar(fullJarPath, indexFilePath); > long modified = new File(indexFilePath).lastModified(); > IPath libPath = new Path(jarFilePath); > IClasspathAttribute attribute = JavaCore.newClasspathAttribute(IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME, "file:///"+indexFilePath); >@@ -189,17 +191,18 @@ > waitUntilIndexesReady(); > > search("Test", TYPE, DECLARATIONS, EXACT_RULE, SearchEngine.createJavaSearchScope(new IJavaElement[]{p})); >- assertSearchResults("\\P\\Test.jar pkg.Test"); >+ assertSearchResults("Test.jar pkg.Test [No source]"); >+ java.io.File indexFile = JavaModelManager.getIndexManager().getIndex(libPath, false, false).getIndexFile(); >+ assertEquals(indexFilePath,indexFile.toString()); > > simulateExitRestart(); >- getJavaModel().refreshExternalArchives(null, null); > waitUntilIndexesReady(); > > this.resultCollector = new JavaSearchResultCollector(); > search("Test", TYPE, DECLARATIONS, EXACT_RULE, SearchEngine.createJavaSearchScope(new IJavaElement[]{p})); >- assertSearchResults("\\P\\Test.jar pkg.Test"); >+ assertSearchResults("Test.jar pkg.Test [No source]"); > >- java.io.File indexFile = JavaModelManager.getIndexManager().getIndex(libPath, false, false).getIndexFile(); >+ indexFile = JavaModelManager.getIndexManager().getIndex(libPath, false, false).getIndexFile(); > assertEquals(indexFilePath,indexFile.toString()); > // Ensure that the file is not modified > assertEquals(modified, new File(indexFilePath).lastModified()); >@@ -593,9 +596,10 @@ > } > > // Test changing the classpath >- public void _testChangeClasspathForInternalJar() throws CoreException, IOException { >+ public void testChangeClasspathForInternalJar() throws CoreException, IOException { > String indexFilePath = getExternalResourcePath("Test.index"); > String jarFilePath = "/P/Test.jar"; >+ String fullJarPath = getWorkspacePath() + jarFilePath; > try { > IJavaProject p = createJavaProject("P"); > createJar(new String[] { >@@ -603,8 +607,8 @@ > "package pkg;\n" + > "public class Test {\n" + > " protected Test(int i) {}\n" + >- "}"}, jarFilePath); >- JavaIndexer.generateIndexForJar(jarFilePath, indexFilePath); >+ "}"}, fullJarPath); >+ JavaIndexer.generateIndexForJar(fullJarPath, indexFilePath); > createJar(new String[] { > "pkg/Test.java", > "package pkg;\n" + >@@ -615,14 +619,15 @@ > "package pkg;\n" + > "public class NewTest {\n" + > " protected NewTest(int i) {}\n" + >- "}"}, jarFilePath); >+ "}"}, fullJarPath); >+ p.getProject().refreshLocal(1, null); > Path libPath = new Path(jarFilePath); > > IClasspathEntry entry = JavaCore.newLibraryEntry(libPath, null, null, null, null, false); > setClasspath(p, new IClasspathEntry[] {entry}); > waitUntilIndexesReady(); > search("NewTest", TYPE, DECLARATIONS, EXACT_RULE, SearchEngine.createJavaSearchScope(new IJavaElement[]{p})); >- assertSearchResults("\\P\\Test.jar pkg.NewTest"); >+ assertSearchResults("Test.jar pkg.NewTest [No source]"); > > IClasspathAttribute attribute = JavaCore.newClasspathAttribute(IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME, "file:///"+indexFilePath); > entry = JavaCore.newLibraryEntry(libPath, null, null, null, new IClasspathAttribute[]{attribute}, false); >@@ -637,9 +642,7 @@ > waitUntilIndexesReady(); > this.resultCollector = new JavaSearchResultCollector(); > search("NewTest", TYPE, DECLARATIONS, EXACT_RULE, SearchEngine.createJavaSearchScope(new IJavaElement[]{p})); >- assertSearchResults("\\P\\Test.jar pkg.NewTest"); >- >- >+ assertSearchResults("Test.jar pkg.NewTest [No source]"); > } finally { > deleteProject("P"); > new File(indexFilePath).delete(); >@@ -766,7 +769,7 @@ > } > > // Test that it works if the index file is in the jar file >- public void _testIndexInJar() throws IOException, CoreException { >+ public void testIndexInJar() throws IOException, CoreException { > String indexFilePath = getExternalResourcePath("Test.index"); > String jarFilePath = getExternalResourcePath("Test.jar"); > String indexZipPath = getExternalResourcePath("TestIndex.zip"); >@@ -783,7 +786,7 @@ > > IJavaProject p = createJavaProject("P"); > Path libPath = new Path(jarFilePath); >- String url = "jar:file:/"+indexZipPath+"!/Test.index"; >+ String url = "jar:file:"+indexZipPath+"!/Test.index"; > IClasspathAttribute attribute = JavaCore.newClasspathAttribute(IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME, url); > IClasspathEntry entry = JavaCore.newLibraryEntry(libPath, null, null, null, new IClasspathAttribute[]{attribute}, false); > setClasspath(p, new IClasspathEntry[] {entry}); >diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java >index 75f441f..f7db2a3 100644 >--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java >+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java >@@ -53,6 +53,7 @@ > /* can only replace a current state if its less than the new one */ > // key = indexLocation path, value = index state integer > private SimpleLookupTable indexStates = null; >+ private File indexNamesMapFile = new File(getSavedIndexesDirectory(), "indexNamesMap.txt"); //$NON-NLS-1$ > private File savedIndexNamesFile = new File(getSavedIndexesDirectory(), "savedIndexNames.txt"); //$NON-NLS-1$ > private File participantIndexNamesFile = new File(getSavedIndexesDirectory(), "participantsIndexNames.txt"); //$NON-NLS-1$ > private boolean javaLikeNamesChanged = true; >@@ -394,6 +395,7 @@ > this.javaLikeNamesChanged = false; > deleteIndexFiles(); > } >+ readIndexMap(); > return this.indexStates; > } > private IPath getParticipantsContainer(IndexLocation indexLocation) { >@@ -517,7 +519,7 @@ > } > > synchronized boolean addIndex(IPath containerPath, IndexLocation indexFile) { >- this.indexStates.put(indexFile, REUSE_STATE); >+ getIndexStates().put(indexFile, REUSE_STATE); > this.indexLocations.put(containerPath, indexFile); > Index index = getIndex(containerPath, indexFile, true, false); > if (index == null) { >@@ -525,6 +527,7 @@ > this.indexLocations.put(containerPath, null); > return false; > } >+ writeIndexMapFile(); > return true; > } > >@@ -906,6 +909,30 @@ > return buffer.toString(); > } > >+private void readIndexMap() { >+ try { >+ char[] indexMaps = org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(this.indexNamesMapFile, null); >+ if (indexMaps.length > 0) { >+ char[][] names = CharOperation.splitOn('\n', indexMaps); >+ if (names.length >= 3) { >+ // First line is DiskIndex signature (see writeIndexMapFile()) >+ String savedSignature = DiskIndex.SIGNATURE; >+ if (savedSignature.equals(new String(names[0]))) { >+ for (int i = 1, l = names.length-1 ; i < l ; i+=2) { >+ IndexLocation indexPath = IndexLocation.createIndexLocation(new URL(new String(names[i]))); >+ this.indexLocations.put(new Path(new String(names[i+1])), indexPath ); >+ this.indexStates.put(indexPath, REUSE_STATE); >+ } >+ } >+ >+ } >+ } >+ } catch (IOException ignored) { >+ if (VERBOSE) >+ Util.verbose("Failed to read saved index file names"); //$NON-NLS-1$ >+ } >+ return; >+} > private char[][] readIndexState(String dirOSString) { > try { > char[] savedIndexNames = org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(this.savedIndexNamesFile, null); >@@ -963,6 +990,7 @@ > if (!changed) return; > > writeSavedIndexNamesFile(); >+ writeIndexMapFile(); > } > private synchronized void updateIndexState(IndexLocation indexLocation, Integer indexState) { > if (indexLocation == null) >@@ -1037,6 +1065,39 @@ > } > } > } >+private void writeIndexMapFile() { >+ BufferedWriter writer = null; >+ try { >+ writer = new BufferedWriter(new FileWriter(this.indexNamesMapFile)); >+ writer.write(DiskIndex.SIGNATURE); >+ writer.write('\n'); >+ Object[] keys = this.indexStates.keyTable; >+ Object[] states = this.indexStates.valueTable; >+ for (int i = 0, l = states.length; i < l; i++) { >+ IndexLocation location = (IndexLocation)keys[i]; >+ if (location != null && states[i] == REUSE_STATE) { >+ IPath container = (IPath)this.indexLocations.keyForValue(location); >+ if (container != null) { >+ writer.write(location.toString()); >+ writer.write('\n'); >+ writer.write(container.toOSString()); >+ writer.write('\n'); >+ } >+ } >+ } >+ } catch (IOException ignored) { >+ if (VERBOSE) >+ Util.verbose("Failed to write saved index file names", System.err); //$NON-NLS-1$ >+ } finally { >+ if (writer != null) { >+ try { >+ writer.close(); >+ } catch (IOException e) { >+ // ignore >+ } >+ } >+ } >+} > private void writeParticipantsIndexNamesFile() { > BufferedWriter writer = null; > try {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 366544
: 208603