Incremental compilation does not delete weaver-generated class filestags/Root_ajdt_support
<compile files="WeaveLocal.java" aspectpath="notAJar.jar" outjar="notAJar.jar" > | <compile files="WeaveLocal.java" aspectpath="notAJar.jar" outjar="notAJar.jar" > | ||||
</compile> | </compile> | ||||
</ajc-test> | </ajc-test> | ||||
<ajc-test dir="incremental/initialTests/classWAroundClosureRemoved" | |||||
title="make sure additional classes generated during weave are deleted with src class file" | |||||
keywords="incremental-test"> | |||||
<compile staging="true" | |||||
options="-incremental" | |||||
sourceroots="."/> | |||||
<inc-compile tag="20" > | |||||
<dir-changes removed="AdviceOnIntroduced$AjcClosure1"/> | |||||
</inc-compile> | |||||
</ajc-test> | |||||
</suite> | </suite> |
import org.aspectj.testing.Tester; | |||||
public aspect AdviceOnIntroduced { | |||||
public static void main(String[] args) { test(); } | |||||
public static void test() { | |||||
Tester.checkEqual(new Foo(10).foo(5), 6, "foo"); | |||||
} | |||||
int Foo.foo(int n) { return n; } | |||||
Foo.new(int w) {} | |||||
int around(int n): | |||||
within(AdviceOnIntroduced) && | |||||
(args(n) && execution(int foo(int))) { | |||||
int result = proceed(n); | |||||
return result+1; | |||||
} | |||||
before(): within(Foo) && execution(new(..)) { | |||||
//System.out.println("before new"); | |||||
} | |||||
} | |||||
class Foo { | |||||
} |
import org.aspectj.testing.Tester; | |||||
public aspect AdviceOnIntroduced { | |||||
public static void main(String[] args) { test(); } | |||||
public static void test() { | |||||
Tester.checkEqual(new Foo(10).foo(5), 6, "foo"); | |||||
} | |||||
int Foo.foo(int n) { return n; } | |||||
Foo.new(int w) {} | |||||
int around(int n): | |||||
within(AdviceOnIntroduced) && | |||||
(args(n) && execution(int foo(int))) { | |||||
int result = proceed(n); | |||||
return result+1; | |||||
} | |||||
before(): within(Foo) && execution(new(..)) { | |||||
//System.out.println("before new"); | |||||
} | |||||
} | |||||
class Foo { | |||||
} |
import org.aspectj.testing.Tester; | |||||
public class Main { | |||||
public static void main(String[] args) { | |||||
Tester.checkFailed("Incremental compilation did not appear to (re)weave Main"); | |||||
} | |||||
} |
import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
import java.io.File; | import java.io.File; | ||||
import java.io.FilenameFilter; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Collections; | import java.util.Collections; | ||||
public String toString() { | public String toString() { | ||||
return "UnwovenClassFile(" + filename + ", " + getClassName() + ")"; | 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 { | 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 | // record | ||||
public static class ChildClass { | public static class ChildClass { | ||||
public final String name; | public final String name; |