From 0c8da60c4d6e6f22e6d422157ecc0630bad942e3 Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 5 Sep 2008 21:31:00 +0000 Subject: [PATCH] allow for jars changing on classpath --- .../ajdt/internal/core/builder/AjState.java | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java index a5ad9ed6d..8911c4be2 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java @@ -69,7 +69,7 @@ public class AjState implements CompilerConfigurationChangeFlags { public static boolean FORCE_INCREMENTAL_DURING_TESTING = false; - private AjBuildManager buildManager; + private final AjBuildManager buildManager; private boolean couldBeSubsequentIncrementalBuild = false; private INameEnvironment nameEnvironment; @@ -80,10 +80,10 @@ public class AjState implements CompilerConfigurationChangeFlags { * When looking at changes on the classpath, this set accumulates files in our state instance that affected by those changes. * Then if we can do an incremental build - these must be compiled. */ - private Set affectedFiles = new HashSet(); + private final Set affectedFiles = new HashSet(); private long lastSuccessfulFullBuildTime = -1; - private Hashtable /* File, long */structuralChangesSinceLastFullBuild = new Hashtable(); + private final Hashtable /* File, long */structuralChangesSinceLastFullBuild = new Hashtable(); private long lastSuccessfulBuildTime = -1; private long currentBuildTime = -1; @@ -100,7 +100,7 @@ public class AjState implements CompilerConfigurationChangeFlags { * * Added by AMC during state refactoring, 1Q06. */ - private Map/* */fullyQualifiedTypeNamesResultingFromCompilationUnit = new HashMap(); + private final Map/* */fullyQualifiedTypeNamesResultingFromCompilationUnit = new HashMap(); /** * Source files defining aspects @@ -109,14 +109,14 @@ public class AjState implements CompilerConfigurationChangeFlags { * * Added by AMC during state refactoring, 1Q06. */ - private Set/* */sourceFilesDefiningAspects = new HashSet(); + private final Set/* */sourceFilesDefiningAspects = new HashSet(); /** * Populated in noteResult to record the set of types that should be recompiled if the given file is modified or deleted. * * Refered to during addAffectedSourceFiles when calculating incremental compilation set. */ - private Map/* */references = new HashMap(); + private final Map/* */references = new HashMap(); /** * Holds UnwovenClassFiles (byte[]s) originating from the given file source. This could be a jar file, a directory, or an @@ -143,13 +143,13 @@ public class AjState implements CompilerConfigurationChangeFlags { * (type name, File) not UnwovenClassFiles (which also have all the byte code in them). After a batch build, binarySourceFiles * is cleared, leaving just this much lighter weight map to use in processing subsequent incremental builds. */ - private Map/* */inputClassFilesBySource = new HashMap(); + private final Map/* */inputClassFilesBySource = new HashMap(); /** * Holds structure information on types as they were at the end of the last build. It would be nice to get rid of this too, but * can't see an easy way to do that right now. */ - private Map/* FQN,CompactStructureRepresentation */resolvedTypeStructuresFromLastBuild = new HashMap(); + private final Map/* FQN,CompactStructureRepresentation */resolvedTypeStructuresFromLastBuild = new HashMap(); /** * Populated in noteResult to record the set of UnwovenClassFiles (intermediate results) that originated from compilation of the @@ -159,7 +159,7 @@ public class AjState implements CompilerConfigurationChangeFlags { * * Passed into StatefulNameEnvironment during incremental compilation to support findType lookups. */ - private Map/* */classesFromName = new HashMap(); + private final Map/* */classesFromName = new HashMap(); /** * Populated by AjBuildManager to record the aspects with the file name in which they're contained. This is later used when @@ -170,7 +170,7 @@ public class AjState implements CompilerConfigurationChangeFlags { private Map /* */aspectsFromFileNames; private Set/* File */compiledSourceFiles = new HashSet(); - private List/* String */resources = new ArrayList(); + private final List/* String */resources = new ArrayList(); // these are references created on a particular compile run - when looping round in // addAffectedSourceFiles(), if some have been created then we look at which source files @@ -496,9 +496,9 @@ public class AjState implements CompilerConfigurationChangeFlags { public static class SoftHashMap extends AbstractMap { - private Map map; + private final Map map; - private ReferenceQueue rq = new ReferenceQueue(); + private final ReferenceQueue rq = new ReferenceQueue(); public SoftHashMap(Map map) { this.map = map; @@ -733,10 +733,16 @@ public class AjState implements CompilerConfigurationChangeFlags { // it as a standalone element on our classpath rather than going through them all List/* String */modifiedCpElements = newConfig.getClasspathElementsWithModifiedContents(); for (Iterator iterator = modifiedCpElements.iterator(); iterator.hasNext();) { - File cpDir = new File((String) iterator.next()); - int classFileChanges = classFileChangedInDirSinceLastBuildRequiringFullBuild(cpDir); - if (classFileChanges == CLASS_FILE_CHANGED_THAT_NEEDS_FULL_BUILD) { - return true; + File cpElement = new File((String) iterator.next()); + if (cpElement.exists() && !cpElement.isDirectory()) { + if (cpElement.lastModified() > lastSuccessfulBuildTime) { + return true; + } + } else { + int classFileChanges = classFileChangedInDirSinceLastBuildRequiringFullBuild(cpElement); + if (classFileChanges == CLASS_FILE_CHANGED_THAT_NEEDS_FULL_BUILD) { + return true; + } } } } -- 2.39.5