aboutsummaryrefslogtreecommitdiffstats
path: root/org.aspectj.ajdt.core
diff options
context:
space:
mode:
authoraclement <aclement>2005-04-05 14:50:06 +0000
committeraclement <aclement>2005-04-05 14:50:06 +0000
commite460b1e3dae5d05b3457ff96746292516b963c32 (patch)
tree5ee9bc2fd69b26d38bff394aed1ea14483b39618 /org.aspectj.ajdt.core
parent8c4479ee1f75c3c336f3519eaa1c2c03719a1cbb (diff)
downloadaspectj-e460b1e3dae5d05b3457ff96746292516b963c32.tar.gz
aspectj-e460b1e3dae5d05b3457ff96746292516b963c32.zip
Fix for problem introduced when checking contents of dirs on the classpath for changes. (see PR85297)
Diffstat (limited to 'org.aspectj.ajdt.core')
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java30
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/IStateListener.java36
2 files changed, 56 insertions, 10 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 e5668bc32..a747db5cd 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
@@ -29,13 +29,13 @@ import org.aspectj.ajdt.internal.compiler.InterimCompilationResult;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.Message;
import org.aspectj.bridge.SourceLocation;
-import org.aspectj.util.FileUtil;
-import org.aspectj.weaver.bcel.UnwovenClassFile;
import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
import org.aspectj.org.eclipse.jdt.internal.core.builder.ReferenceCollection;
import org.aspectj.org.eclipse.jdt.internal.core.builder.StringSet;
+import org.aspectj.util.FileUtil;
+import org.aspectj.weaver.bcel.UnwovenClassFile;
/**
@@ -44,6 +44,9 @@ import org.aspectj.org.eclipse.jdt.internal.core.builder.StringSet;
public class AjState {
AjBuildManager buildManager;
+ // static so beware of multi-threading bugs...
+ public static IStateListener stateListener = null;
+
long lastSuccessfulBuildTime = -1;
long currentBuildTime = -1;
AjBuildConfig buildConfig;
@@ -100,6 +103,7 @@ public class AjState {
// coming - otherwise a file that has been deleted from an inpath jar
// since the last build will not be deleted from the output directory.
removeAllResultsOfLastBuild();
+ if (stateListener!=null) stateListener.pathChangeDetected();
return false;
}
@@ -180,7 +184,9 @@ public class AjState {
});
for (int i = 0; i < classFiles.length; i++) {
long modTime = classFiles[i].lastModified();
- if (modTime + 1000 >= lastSuccessfulBuildTime) return true;
+ if (modTime + 1000 >= lastSuccessfulBuildTime) {
+ return true;
+ }
}
return false;
}
@@ -189,20 +195,21 @@ public class AjState {
boolean changed = false;
List oldClasspath = oldConfig.getClasspath();
List newClasspath = newConfig.getClasspath();
- if (changed(oldClasspath,newClasspath,true)) return true;
+ if (stateListener!=null) stateListener.aboutToCompareClasspaths(oldClasspath,newClasspath);
+ if (changed(oldClasspath,newClasspath,true,oldConfig.getOutputDir())) return true;
List oldAspectpath = oldConfig.getAspectpath();
List newAspectpath = newConfig.getAspectpath();
- if (changed(oldAspectpath,newAspectpath,true)) return true;
+ if (changed(oldAspectpath,newAspectpath,true,oldConfig.getOutputDir())) return true;
List oldInJars = oldConfig.getInJars();
List newInJars = newConfig.getInJars();
- if (changed(oldInJars,newInJars,false)) return true;
+ if (changed(oldInJars,newInJars,false,oldConfig.getOutputDir())) return true;
List oldInPath = oldConfig.getInpath();
List newInPath = newConfig.getInpath();
- if (changed(oldInPath, newInPath,false)) return true;
+ if (changed(oldInPath, newInPath,false,oldConfig.getOutputDir())) return true;
return changed;
}
- private boolean changed(List oldPath, List newPath, boolean checkClassFiles) {
+ private boolean changed(List oldPath, List newPath, boolean checkClassFiles, File oldOutputLocation) {
if (oldPath == null) oldPath = new ArrayList();
if (newPath == null) newPath = new ArrayList();
if (oldPath.size() != newPath.size()) {
@@ -222,8 +229,10 @@ public class AjState {
if (f.exists() && !f.isDirectory() && (f.lastModified() >= lastSuccessfulBuildTime)) {
return true;
}
- if (f.exists() && f.isDirectory() && checkClassFiles) {
- return classFileChangedInDirSinceLastBuild(f);
+ if (f.exists() && f.isDirectory() && checkClassFiles && !(f.equals(oldOutputLocation))) {
+ boolean b= classFileChangedInDirSinceLastBuild(f);
+ if (b && stateListener!=null) stateListener.detectedClassChangeInThisDir(f);
+ if (b) return true;
}
}
return false;
@@ -639,4 +648,5 @@ public class AjState {
addDependentsOf(intRes.unwovenClassFiles()[i].getClassName());
}
}
+
}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/IStateListener.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/IStateListener.java
new file mode 100644
index 000000000..b1f64dd68
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/IStateListener.java
@@ -0,0 +1,36 @@
+/**
+ * Copyright (c) 2005 IBM and other contributors
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Common Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Andy Clement initial implementation
+ * ******************************************************************/
+
+package org.aspectj.ajdt.internal.core.builder;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * Implementations of this interface get told interesting information about
+ * decisions made in AjState objects. Should help us improve incremental
+ * compilation, and ease the testing of incremental compilation!
+ *
+ * Not yet complete, will expand as we determine what extra useful information
+ * should be recorded.
+ *
+ * @author AndyClement
+ */
+public interface IStateListener {
+
+ public void detectedClassChangeInThisDir(File f);
+
+ public void aboutToCompareClasspaths(List oldClasspath, List newClasspath);
+
+ public void pathChangeDetected();
+
+}