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 77382 Details for
Bug 201062
Missing library in project classpath even library exists
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Possible fix
201062v5.txt (text/plain), 15.23 KB, created by
Jerome Lanneluc
on 2007-08-30 10:53:40 EDT
(
hide
)
Description:
Possible fix
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2007-08-30 10:53:40 EDT
Size:
15.23 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java,v >retrieving revision 1.28 >diff -u -r1.28 ExternalJarDeltaTests.java >--- src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java 20 Oct 2006 01:45:46 -0000 1.28 >+++ src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java 30 Aug 2007 14:49:55 -0000 >@@ -16,7 +16,6 @@ > import junit.framework.Test; > > import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IncrementalProjectBuilder; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.Path; >@@ -257,43 +256,6 @@ > } > } > /** >- * Ensure that the external jars are refreshed by full build >- * (regression test for bug 93668 Search indexes not rebuild) >- */ >-public void testExternalJarChanged6() throws CoreException, IOException { >- File f = null; >- try { >- String pPath = getExternalPath() + "p.jar"; >- f = new File(pPath); >- f.createNewFile(); >- createJavaProject("P", new String[] {""}, new String[] {"JCL_LIB", pPath}, ""); >- createFile("/P/X.java", "public class X{}"); >- getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null); >- getJavaModel().refreshExternalArchives(null,null); >- waitUntilIndexesReady(); >- >- // exit, change the jar, and restart >- simulateExit(); >- touch(f); >- simulateRestart(); >- >- startDeltas(); >- getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null); >- >- assertDeltas( >- "Unexpected delta", >- "P[*]: {CHILDREN}\n"+ >- " "+f.getCanonicalPath()+"[*]: {CONTENT | ARCHIVE CONTENT CHANGED}" >- ); >- } finally { >- if(f != null) { >- deleteFile(f); >- } >- this.deleteProject("P"); >- this.stopDeltas(); >- } >-} >-/** > * Refresh the JavaModel after an addition of an external jar. > */ > public void testExternalJarAdded1() throws CoreException, IOException { >@@ -493,6 +455,7 @@ > /** > * - add an internal jar to claspath > * - remove internal jar and the same jar as external jar >+ * - touch the extenal jar > * - refresh the JavaModel > */ > public void testExternalJarInternalExternalJar() throws CoreException, IOException { >@@ -512,17 +475,16 @@ > IPath externalFooPath = new Path(fooIFile.getLocation().toFile().getCanonicalPath()); > setClasspath(project, new IClasspathEntry[]{JavaCore.newLibraryEntry(externalFooPath, null, null)}); > >+ project.open(null); // ensure that project is opened, as external jar delta is optimized for this case (if the project is not opened, there is no need for broadcasting an external jar delta) > f = new File(externalFooPath.toOSString()); >- f.createNewFile(); > touch(f); >- > getJavaModel().refreshExternalArchives(null,null); > > String externalFooPathString = f.getCanonicalPath(); > assertDeltas( > "Unexpected delta", > "P[*]: {CHILDREN | CONTENT | CLASSPATH CHANGED}\n"+ >- " "+externalFooPathString+"[+]: {}\n"+ >+ " "+externalFooPathString+"[*]: {ADDED TO CLASSPATH}\n"+ > " foo.jar[*]: {REMOVED FROM CLASSPATH}\n"+ > " ResourceDelta(/P/.classpath)[*]\n"+ > "\n"+ >#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.302 >diff -u -r1.302 DeltaProcessor.java >--- model/org/eclipse/jdt/internal/core/DeltaProcessor.java 28 Jun 2007 13:58:06 -0000 1.302 >+++ model/org/eclipse/jdt/internal/core/DeltaProcessor.java 30 Aug 2007 14:49:57 -0000 >@@ -234,12 +234,6 @@ > /* A set of IJavaProject whose caches need to be reset */ > public HashSet projectCachesToReset = new HashSet(); > >- /* >- * A list of IJavaElement used as a scope for external archives refresh during POST_CHANGE. >- * This is null if no refresh is needed. >- */ >- private HashSet refreshedElements; >- > /* A table from IJavaProject to an array of IPackageFragmentRoot. > * This table contains the pkg fragment roots of the project that are being deleted. > */ >@@ -300,15 +294,6 @@ > } > } > /* >- * Adds the given element to the list of elements used as a scope for external jars refresh. >- */ >- public void addForRefresh(IJavaElement element) { >- if (this.refreshedElements == null) { >- this.refreshedElements = new HashSet(); >- } >- this.refreshedElements.add(element); >- } >- /* > * Adds the given child handle to its parent's cache of children. > */ > private void addToParentInfo(Openable child) { >@@ -330,66 +315,6 @@ > this.addDependentProjects(javaProject, this.state.projectDependencies, this.rootsToRefresh); > } > /* >- * Check all external archive (referenced by given roots, projects or model) status and issue a corresponding root delta. >- * Also triggers index updates >- */ >- public void checkExternalArchiveChanges(IJavaElement[] elementsToRefresh, IProgressMonitor monitor) throws JavaModelException { >- if (monitor != null && monitor.isCanceled()) >- throw new OperationCanceledException(); >- try { >- if (monitor != null) monitor.beginTask("", 1); //$NON-NLS-1$ >- >- for (int i = 0, length = elementsToRefresh.length; i < length; i++) { >- this.addForRefresh(elementsToRefresh[i]); >- } >- boolean hasDelta = this.createExternalArchiveDelta(monitor); >- 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]; >- for (int i = 0; i < length; i++) { >- IJavaElementDelta delta = projectDeltas[i]; >- JavaProject javaProject = (JavaProject)delta.getElement(); >- projectsToTouch[i] = javaProject.getProject(); >- } >- >- // touch the projects to force them to be recompiled while taking the workspace lock >- // so that there is no concurrency with the Java builder >- // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=96575 >- IWorkspaceRunnable runnable = new IWorkspaceRunnable() { >- public void run(IProgressMonitor progressMonitor) throws CoreException { >- for (int i = 0; i < length; i++) { >- IProject project = projectsToTouch[i]; >- >- // touch to force a build of this project >- if (JavaBuilder.DEBUG) >- System.out.println("Touching project " + project.getName() + " due to external jar file change"); //$NON-NLS-1$ //$NON-NLS-2$ >- project.touch(progressMonitor); >- } >- } >- }; >- try { >- ResourcesPlugin.getWorkspace().run(runnable, monitor); >- } catch (CoreException e) { >- throw new JavaModelException(e); >- } >- >- if (this.currentDelta != null) { // if delta has not been fired while creating markers >- this.fire(this.currentDelta, DEFAULT_CHANGE_EVENT); >- } >- } >- } finally { >- this.currentDelta = null; >- if (monitor != null) monitor.done(); >- } >- } >- /* > * Process the given delta and look for projects being added, opened, closed or > * with a java nature being added or removed. > * Note that projects being deleted are checked in deleting(IProject). >@@ -514,9 +439,6 @@ > break; > } > >- // in all cases, refresh the external jars for this project >- addForRefresh(javaProject); >- > break; > case IResource.FILE : > IFile file = (IFile) resource; >@@ -771,20 +693,72 @@ > return this.currentElement; > } > /* >- * Check if external archives have changed and create the corresponding deltas. >- * Returns whether at least on delta was created. >+ * Check all external archive (referenced by given roots, projects or model) status and issue a corresponding root delta. >+ * Also triggers index updates > */ >- private boolean createExternalArchiveDelta(IProgressMonitor monitor) { >+ public void checkExternalArchiveChanges(IJavaElement[] elementsScope, IProgressMonitor monitor) throws JavaModelException { >+ if (monitor != null && monitor.isCanceled()) >+ throw new OperationCanceledException(); >+ try { >+ if (monitor != null) monitor.beginTask("", 1); //$NON-NLS-1$ >+ >+ for (int i = 0, length = elementsScope.length; i < length; i++) { >+ this.state.addForRefresh(elementsScope[i]); >+ } >+ HashSet elementsToRefresh = this.state.removeExternalElementsToRefresh(); >+ boolean hasDelta = createExternalArchiveDelta(elementsToRefresh, monitor); >+ if (hasDelta){ >+ IJavaElementDelta[] projectDeltas = this.currentDelta.getAffectedChildren(); >+ final int length = projectDeltas.length; >+ final IProject[] projectsToTouch = new IProject[length]; >+ for (int i = 0; i < length; i++) { >+ IJavaElementDelta delta = projectDeltas[i]; >+ JavaProject javaProject = (JavaProject)delta.getElement(); >+ projectsToTouch[i] = javaProject.getProject(); >+ } >+ >+ // touch the projects to force them to be recompiled while taking the workspace lock >+ // so that there is no concurrency with the Java builder >+ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=96575 >+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() { >+ public void run(IProgressMonitor progressMonitor) throws CoreException { >+ for (int i = 0; i < length; i++) { >+ IProject project = projectsToTouch[i]; >+ >+ // touch to force a build of this project >+ if (JavaBuilder.DEBUG) >+ System.out.println("Touching project " + project.getName() + " due to external jar file change"); //$NON-NLS-1$ //$NON-NLS-2$ >+ project.touch(progressMonitor); >+ } >+ } >+ }; >+ try { >+ ResourcesPlugin.getWorkspace().run(runnable, monitor); >+ } catch (CoreException e) { >+ throw new JavaModelException(e); >+ } >+ >+ if (this.currentDelta != null) { // if delta has not been fired while creating markers >+ this.fire(this.currentDelta, DEFAULT_CHANGE_EVENT); >+ } >+ } >+ } finally { >+ this.currentDelta = null; >+ if (monitor != null) monitor.done(); >+ } >+ } >+ /* >+ * Check if external archives have changed for the given elements and create the corresponding deltas. >+ * Returns whether at least one delta was created. >+ */ >+ private boolean createExternalArchiveDelta(HashSet refreshedElements, IProgressMonitor monitor) { > >- if (this.refreshedElements == null) return false; >- > HashMap externalArchivesStatus = new HashMap(); > boolean hasDelta = false; > > // find JARs to refresh > HashSet archivePathsToRefresh = new HashSet(); >- Iterator iterator = this.refreshedElements.iterator(); >- this.refreshedElements = null; // null out early to avoid concurrent modification exception (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=63534) >+ Iterator iterator = refreshedElements.iterator(); > while (iterator.hasNext()) { > IJavaElement element = (IJavaElement)iterator.next(); > switch(element.getElementType()){ >@@ -946,6 +920,13 @@ > } > } > } >+ if (hasDelta){ >+ // force classpath marker refresh of affected projects >+ JavaModel.flushExternalFileCache(); >+ >+ // flush jar type cache >+ JavaModelManager.getJavaModelManager().resetJarTypeCache(); >+ } > return hasDelta; > } > private JavaElementDelta currentDelta() { >@@ -1861,7 +1842,9 @@ > return; > > case IResourceChangeEvent.POST_CHANGE : >- if (isAffectedBy(delta)) { // avoid populating for SYNC or MARKER deltas >+ HashSet elementsToRefresh = this.state.removeExternalElementsToRefresh(); >+ if (isAffectedBy(delta) // avoid populating for SYNC or MARKER deltas >+ || elementsToRefresh != null) { > try { > try { > stopDeltas(); >@@ -1890,8 +1873,8 @@ > } > > // generate external archive change deltas >- if (this.refreshedElements != null) { >- createExternalArchiveDelta(null); >+ if (elementsToRefresh != null) { >+ createExternalArchiveDelta(elementsToRefresh, null); > } > > // generate Java deltas from resource changes >@@ -1920,11 +1903,10 @@ > return; > > case IResourceChangeEvent.PRE_BUILD : >- if(!isAffectedBy(delta)) >- return; // avoid populating for SYNC or MARKER deltas >+ boolean isAffected = isAffectedBy(delta); >+ boolean needCycleValidation = isAffected && validateClasspaths(delta); > > // create classpath markers if necessary >- boolean needCycleValidation = validateClasspaths(delta); > ClasspathValidation[] validations = this.state.removeClasspathValidations(); > if (validations != null) { > for (int i = 0, length = validations.length; i < length; i++) { >@@ -1954,8 +1936,10 @@ > } > } > >- JavaModel.flushExternalFileCache(); >- JavaBuilder.buildStarting(); >+ if (isAffected) { >+ JavaModel.flushExternalFileCache(); >+ JavaBuilder.buildStarting(); >+ } > > // does not fire any deltas > return; >Index: model/org/eclipse/jdt/internal/core/DeltaProcessingState.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessingState.java,v >retrieving revision 1.42 >diff -u -r1.42 DeltaProcessingState.java >--- model/org/eclipse/jdt/internal/core/DeltaProcessingState.java 13 Apr 2007 16:02:15 -0000 1.42 >+++ model/org/eclipse/jdt/internal/core/DeltaProcessingState.java 30 Aug 2007 14:49:57 -0000 >@@ -93,6 +93,12 @@ > private HashSet javaProjectNamesCache; > > /* >+ * A list of IJavaElement used as a scope for external archives refresh during POST_CHANGE. >+ * This is null if no refresh is needed. >+ */ >+ private HashSet externalElementsToRefresh; >+ >+ /* > * Need to clone defensively the listener information, in case some listener is reacting to some notification iteration by adding/changing/removing > * any of the other (for example, if it deregisters itself). > */ >@@ -119,6 +125,16 @@ > this.elementChangedListenerCount++; > } > >+ /* >+ * Adds the given element to the list of elements used as a scope for external jars refresh. >+ */ >+ public synchronized void addForRefresh(IJavaElement externalElement) { >+ if (this.externalElementsToRefresh == null) { >+ this.externalElementsToRefresh = new HashSet(); >+ } >+ this.externalElementsToRefresh.add(externalElement); >+ } >+ > public synchronized void addPreResourceChangedListener(IResourceChangeListener listener, int eventMask) { > for (int i = 0; i < this.preResourceChangeListenerCount; i++){ > if (this.preResourceChangeListeners[i] == listener) { >@@ -290,6 +306,12 @@ > return updates; > } > >+ public synchronized HashSet removeExternalElementsToRefresh() { >+ HashSet result = this.externalElementsToRefresh; >+ this.externalElementsToRefresh = null; >+ return result; >+ } >+ > public synchronized void removeElementChangedListener(IElementChangedListener listener) { > > for (int i = 0; i < this.elementChangedListenerCount; i++){
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 201062
: 77382