### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/util/messages.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/messages.properties,v retrieving revision 1.74.2.1 diff -u -r1.74.2.1 messages.properties --- model/org/eclipse/jdt/internal/core/util/messages.properties 11 Nov 2009 14:55:06 -0000 1.74.2.1 +++ model/org/eclipse/jdt/internal/core/util/messages.properties 4 Oct 2011 07:19:13 -0000 @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2009 IBM Corporation and others. +# Copyright (c) 2000, 2011 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at @@ -184,7 +184,8 @@ path_mustBeAbsolute = Path must be absolute cache_invalidLoadFactor = Incorrect load factor savedState_jobName = Processing Java changes since last activation -refreshing_external_folders = "Refreshing external folders" +refreshing_external_folders = Refreshing external folders +updating_external_archives_jobName = Refreshing external archives ## java model initialization javamodel_initialization = Initializing Java tooling Index: model/org/eclipse/jdt/internal/core/util/Messages.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Messages.java,v retrieving revision 1.25.2.1 diff -u -r1.25.2.1 Messages.java --- model/org/eclipse/jdt/internal/core/util/Messages.java 11 Nov 2009 14:55:06 -0000 1.25.2.1 +++ model/org/eclipse/jdt/internal/core/util/Messages.java 4 Oct 2011 07:19:11 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -186,6 +186,7 @@ public static String cache_invalidLoadFactor; public static String savedState_jobName; public static String refreshing_external_folders; + public static String updating_external_archives_jobName; public static String convention_unit_nullName; public static String convention_unit_notJavaName; public static String convention_classFile_nullName; 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.335 diff -u -r1.335 DeltaProcessor.java --- model/org/eclipse/jdt/internal/core/DeltaProcessor.java 23 Apr 2009 15:32:17 -0000 1.335 +++ model/org/eclipse/jdt/internal/core/DeltaProcessor.java 4 Oct 2011 07:19:11 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,7 +11,12 @@ package org.eclipse.jdt.internal.core; import java.io.File; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; @@ -25,8 +30,28 @@ import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.*; -import org.eclipse.jdt.core.*; +import org.eclipse.core.resources.WorkspaceJob; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.ISafeRunnable; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.PerformanceStats; +import org.eclipse.core.runtime.SafeRunner; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.jdt.core.ElementChangedEvent; +import org.eclipse.jdt.core.IClasspathEntry; +import org.eclipse.jdt.core.IElementChangedListener; +import org.eclipse.jdt.core.IJavaElement; +import org.eclipse.jdt.core.IJavaElementDelta; +import org.eclipse.jdt.core.IJavaModel; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.IPackageFragment; +import org.eclipse.jdt.core.IPackageFragmentRoot; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.internal.compiler.SourceElementParser; import org.eclipse.jdt.internal.core.JavaModelManager.PerProjectInfo; @@ -35,6 +60,7 @@ import org.eclipse.jdt.internal.core.search.AbstractSearchScope; import org.eclipse.jdt.internal.core.search.JavaWorkspaceScope; import org.eclipse.jdt.internal.core.search.indexing.IndexManager; +import org.eclipse.jdt.internal.core.util.Messages; import org.eclipse.jdt.internal.core.util.Util; /** @@ -686,11 +712,15 @@ this.currentElement = (Openable)element; return this.currentElement; } + + public void checkExternalArchiveChanges(IJavaElement[] elementsScope, IProgressMonitor monitor) throws JavaModelException { + checkExternalArchiveChanges(elementsScope, false, monitor); + } /* * 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[] elementsScope, IProgressMonitor monitor) throws JavaModelException { + private void checkExternalArchiveChanges(IJavaElement[] elementsScope, boolean asynchronous, IProgressMonitor monitor) throws JavaModelException { if (monitor != null && monitor.isCanceled()) throw new OperationCanceledException(); try { @@ -724,26 +754,51 @@ 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); + if (projectsToTouch.length > 0) { + if (asynchronous){ + WorkspaceJob touchJob = new WorkspaceJob(Messages.updating_external_archives_jobName) { + + public IStatus runInWorkspace(IProgressMonitor progressMonitor) throws CoreException { + try { + if (progressMonitor != null) + progressMonitor.beginTask("", projectsToTouch.length); //$NON-NLS-1$ + touchProjects(projectsToTouch, progressMonitor); + } + finally { + if (progressMonitor != null) + progressMonitor.done(); + } + return Status.OK_STATUS; + } + + public boolean belongsTo(Object family) { + return ResourcesPlugin.FAMILY_MANUAL_REFRESH == family; + } + }; + touchJob.schedule(); + } + else { + // 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 < projectsToTouch.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); } } - }; - 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 @@ -758,6 +813,19 @@ if (monitor != null) monitor.done(); } } + + protected void touchProjects(final IProject[] projectsToTouch, IProgressMonitor progressMonitor) + throws CoreException { + for (int i = 0; i < projectsToTouch.length; i++) { + IProgressMonitor monitor = progressMonitor == null ? null: new SubProgressMonitor(progressMonitor, 1); + 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(monitor); + } + } + /* * Check if external archives have changed for the given elements and create the corresponding deltas. * Returns whether at least one delta was created. @@ -1889,6 +1957,16 @@ for (int i = 0; projects != null && i < projects.length; i++) { JavaModelManager.getExternalManager().refreshReferences(projects[i], null); } + IJavaProject[] javaElements = new IJavaProject[projects.length]; + for (int index = 0; index < projects.length; index++) { + javaElements[index] = JavaCore.create(projects[index]); + } + try { + checkExternalArchiveChanges(javaElements, true, null); + } catch (JavaModelException e) { + if (!e.isDoesNotExist()) + Util.log(e, "Exception while updating external archives"); //$NON-NLS-1$ + } return; case IResourceChangeEvent.POST_CHANGE : @@ -2336,7 +2414,7 @@ } /* - * Update the current delta (ie. add/remove/change the given element) and update the correponding index. + * Update the current delta (i.e. add/remove/change the given element) and update the correponding index. * Returns whether the children of the given delta must be processed. * @throws a JavaModelException if the delta doesn't correspond to a java element of the given type. */ #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/JavaElementDeltaTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaElementDeltaTests.java,v retrieving revision 1.93.2.2 diff -u -r1.93.2.2 JavaElementDeltaTests.java --- src/org/eclipse/jdt/core/tests/model/JavaElementDeltaTests.java 25 Nov 2009 10:18:20 -0000 1.93.2.2 +++ src/org/eclipse/jdt/core/tests/model/JavaElementDeltaTests.java 4 Oct 2011 07:19:26 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -3029,5 +3029,26 @@ deleteProject("P"); } } +public void testChangeExternalJar() throws CoreException { + String jarName = "externalLib.jar"; + try { + createExternalFile(jarName, ""); + IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath(jarName)}, ""); + refreshExternalArchives(p); + + startDeltas(); + touch(getExternalFile(jarName)); + refresh(p); + assertDeltas( + "Unexpected delta", + "P[*]: {CHILDREN}\n" + + " "+ getExternalPath() + "externalLib.jar[*]: {CONTENT | ARCHIVE CONTENT CHANGED}" + ); + } finally { + stopDeltas(); + deleteExternalResource(jarName); + deleteProject("P"); + } +} }