diff options
author | acolyer <acolyer> | 2004-03-18 14:36:58 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2004-03-18 14:36:58 +0000 |
commit | 7d6b500be325633c3057abaf973b8c56464d6706 (patch) | |
tree | 66543c61dfaf9c3c83f5eb797f846389be23761b /weaver | |
parent | 183fc23883289ae42854ce9afcf2d3b0d29b7599 (diff) | |
download | aspectj-7d6b500be325633c3057abaf973b8c56464d6706.tar.gz aspectj-7d6b500be325633c3057abaf973b8c56464d6706.zip |
fix for Bugzilla Bug 55134
Incremental compilation does not delete weaver-generated class files
Diffstat (limited to 'weaver')
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java b/weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java index ab4463407..e67f17529 100644 --- a/weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java +++ b/weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java @@ -15,6 +15,7 @@ package org.aspectj.weaver.bcel; import java.io.BufferedOutputStream; import java.io.File; +import java.io.FilenameFilter; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -150,14 +151,29 @@ public class UnwovenClassFile { public String toString() { return "UnwovenClassFile(" + filename + ", " + getClassName() + ")"; } - + + /** + * delete not just this file, but any files in the same directory that + * were generated as a result of weaving it (e.g. for an around closure). + */ public void deleteRealFile() throws IOException { - new File(filename).delete(); + File victim = new File(filename); + String namePrefix = victim.getName(); + namePrefix = namePrefix.substring(0,namePrefix.lastIndexOf('.')); + final String targetPrefix = namePrefix + "$Ajc"; + File dir = victim.getParentFile(); + if (dir != null) { + File[] weaverGenerated = dir.listFiles(new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.startsWith(targetPrefix); + }}); + for (int i = 0; i < weaverGenerated.length; i++) { + weaverGenerated[i].delete(); + } + } + victim.delete(); } - - - // record public static class ChildClass { public final String name; |