diff options
author | aclement <aclement> | 2005-12-09 10:52:15 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-12-09 10:52:15 +0000 |
commit | 0c8c0a3d21365eade6f53a0484bba71f24637a65 (patch) | |
tree | efa8c4ba005882f172f1abfc9460adda738031c3 /tests | |
parent | 5f8d2cdff480ac9d04cc73a4a69eb11563a0bb01 (diff) | |
download | aspectj-0c8c0a3d21365eade6f53a0484bba71f24637a65.tar.gz aspectj-0c8c0a3d21365eade6f53a0484bba71f24637a65.zip |
Some updates for 118754. The various places that were checking for 'MISSING' now call 'isMissing' if they can. I think this negates some work Adrian did with introducing MissingWithKnownSignature - but we have to make this change for LTW to work properly. Someone with a bit of time on their hands should go through all the places isMissing() is now called and see if the check should be 'isReallyMissing()' which would allow the MissingWithKnownSignature to get through. I will raise an enhancement to cover this.
Diffstat (limited to 'tests')
9 files changed, 145 insertions, 29 deletions
diff --git a/tests/java5/ataspectj/ajc-ant.xml b/tests/java5/ataspectj/ajc-ant.xml index 5c4495be4..695e8ac07 100644 --- a/tests/java5/ataspectj/ajc-ant.xml +++ b/tests/java5/ataspectj/ajc-ant.xml @@ -60,6 +60,14 @@ </java> </target> + <target name="ltw.DumpProxyTest"> + <java fork="yes" classname="ataspectj.TestProxyGenerator" failonerror="yes"> + <classpath refid="aj.path"/> + <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/> + <jvmarg value="-Daj5.def=ataspectj/aop-dumpproxy.xml"/> + </java> + </target> + <target name="javac.ltw" depends="compile:javac, ltw"/> <target name="ltw.Aspect2MainTest"> diff --git a/tests/java5/ataspectj/ataspectj/Test$$EnhancerByCGLIB$$12345.java b/tests/java5/ataspectj/ataspectj/Test$$EnhancerByCGLIB$$12345.java new file mode 100644 index 000000000..78df5f1b1 --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/Test$$EnhancerByCGLIB$$12345.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2005 IBM Corporation and others. + * 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: + * Matthew Webster - initial implementation + *******************************************************************************/ +package ataspectj; + +public class Test$$EnhancerByCGLIB$$12345 { + + public static void main(String[] args) { + System.out.println("Test$$EnhancerByCGLIB$$12345.main()"); + } + +} diff --git a/tests/java5/ataspectj/ataspectj/TestInterface.java b/tests/java5/ataspectj/ataspectj/TestInterface.java new file mode 100644 index 000000000..beac1461b --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/TestInterface.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright (c) 2005 IBM Corporation and others. + * 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: + * Matthew Webster - initial implementation + *******************************************************************************/ +package ataspectj; + +public interface TestInterface { + + public void testMethod (); +} diff --git a/tests/java5/ataspectj/ataspectj/TestProxyGenerator.java b/tests/java5/ataspectj/ataspectj/TestProxyGenerator.java new file mode 100644 index 000000000..1dc0e9aac --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/TestProxyGenerator.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2005 IBM Corporation and others. + * 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: + * Matthew Webster - initial implementation + *******************************************************************************/ +package ataspectj; + +import java.lang.reflect.Proxy; + +public class TestProxyGenerator implements TestInterface { + + public void testMethod() { + } + + public static void main(String[] args) { + Class clazz = TestProxyGenerator.class; + Class proxyClazz = Proxy.getProxyClass(clazz.getClassLoader(),new Class[] { TestInterface.class}); + System.out.println("TestProxyGenerator.main() proxyClazz=" + proxyClazz + ", proxyClassLoader=" + proxyClazz.getClassLoader()); + } + +} diff --git a/tests/java5/ataspectj/ataspectj/aop-dumpbeforeandafter.xml b/tests/java5/ataspectj/ataspectj/aop-dumpbeforeandafter.xml index c2824e2be..487d5dd62 100644 --- a/tests/java5/ataspectj/ataspectj/aop-dumpbeforeandafter.xml +++ b/tests/java5/ataspectj/ataspectj/aop-dumpbeforeandafter.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <aspectj> - <weaver options="-XmessageHandlerClass:ataspectj.TestHelper"> - <dump within="ataspectj.DumpTestThe*" beforeandafter="true"/> + <weaver options="-verbose"> + <dump within="ataspectj..*" beforeandafter="true"/> </weaver> </aspectj> diff --git a/tests/java5/ataspectj/ataspectj/aop-dumpclosure.xml b/tests/java5/ataspectj/ataspectj/aop-dumpclosure.xml index d73c1c23b..fdee559eb 100644 --- a/tests/java5/ataspectj/ataspectj/aop-dumpclosure.xml +++ b/tests/java5/ataspectj/ataspectj/aop-dumpclosure.xml @@ -4,6 +4,9 @@ <aspect name="ataspectj.TestAroundAspect"/> </aspects> <weaver options="-Xnoinline"> - <dump within="ataspectj.DumpTestThe*" beforeandafter="true"/> + <dump within="ataspectj..*Closure*"/> +<!-- + <dump within="*"/> +--> </weaver> </aspectj> diff --git a/tests/java5/ataspectj/ataspectj/aop-dumpproxy.xml b/tests/java5/ataspectj/ataspectj/aop-dumpproxy.xml new file mode 100644 index 000000000..1a76c0152 --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/aop-dumpproxy.xml @@ -0,0 +1,9 @@ +<?xml version="1.0"?> +<aspectj> + <weaver> +<!-- + <dump within="*..*Proxy*" beforeandafter="true"/> +--> + <dump within="*Proxy*" beforeandafter="true"/> + </weaver> +</aspectj> diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java index 5db988b07..2d27cb8e1 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java @@ -11,12 +11,13 @@ *******************************************************************************/ package org.aspectj.systemtest.ajc150.ataspectj; -import org.aspectj.testing.XMLBasedAjcTestCase; -import org.aspectj.util.FileUtil; +import java.io.File; +import java.io.FilenameFilter; import junit.framework.Test; -import java.io.File; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.util.FileUtil; /** * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a> @@ -97,11 +98,9 @@ public class AtAjLTWTests extends XMLBasedAjcTestCase { public void testLTWDumpBeforeAndAfter() { runTest("LTW DumpTest before and after"); - File f = new File("_ajdump/ataspectj/DumpTest.class"); - assertFalse(f.exists()); - f = new File("_ajdump/_before/ataspectj/DumpTestTheDump.class"); + File f = new File("_ajdump/_before/ataspectj/Test$$EnhancerByCGLIB$$12345.class"); assertTrue(f.exists()); - f = new File("_ajdump/ataspectj/DumpTestTheDump.class"); + f = new File("_ajdump/ataspectj/Test$$EnhancerByCGLIB$$12345.class"); assertTrue(f.exists()); // tidy up... @@ -110,23 +109,39 @@ public class AtAjLTWTests extends XMLBasedAjcTestCase { f.delete(); } - /* FIXME maw currently can't dump closures because the logic in - * ClassLoaderWeavingAdaptor.shouldDump() relies on the World being - * able to resolve the name which it can't for closures. - */ -// public void testLTWDumpClosure() { -// runTest("LTW DumpTest closure"); -// -// File f = new File("_ajdump/_before/ataspectj/DumpTestTheDump$AjcClosure1.class"); -// assertTrue(f.exists()); -// f = new File("_ajdump/ataspectj/DumpTestTheDump$AjcClosure1.class"); -// assertTrue(f.exists()); -// -// // tidy up... -// f = new File("_ajdump"); -// FileUtil.deleteContents(f); -// f.delete(); -// } + public void testLTWDumpClosure() { + runTest("LTW DumpTest closure"); + + File f = new File("_ajdump/ataspectj/DumpTestTheDump$AjcClosure1.class"); + assertTrue("Missing dump file " + f.getAbsolutePath(),f.exists()); + + // tidy up... + f = new File("_ajdump"); + FileUtil.deleteContents(f); + f.delete(); + } + + public void testLTWDumpProxy() { + runTest("LTW DumpTest proxy"); + + // The working directory is different because this test must be forked + File dir = new File("../tests/java5/ataspectj"); + File f = new File(dir,"_ajdump/_before"); + System.out.println("AtAjLTWTests.testLTWDumpProxy() f=" + f.getAbsolutePath()); + CountingFilenameFilter cff = new CountingFilenameFilter(); + f.listFiles(cff); + assertEquals("Expected dump file in " + f.getAbsolutePath(),1,cff.getCount()); + f = new File(dir,"_ajdump"); + System.out.println("AtAjLTWTests.testLTWDumpProxy() f=" + f.getAbsolutePath()); + cff = new CountingFilenameFilter(); + f.listFiles(cff); + assertEquals(1,cff.getCount()); + + // tidy up... + f = new File(dir,"_ajdump"); + FileUtil.deleteContents(f); + f.delete(); + } public void testAjcAspect1LTWAspect2_Xreweavable() { runTest("Ajc Aspect1 LTW Aspect2 -Xreweavable"); @@ -185,4 +200,17 @@ public class AtAjLTWTests extends XMLBasedAjcTestCase { runTest("AppContainer"); } + private static class CountingFilenameFilter implements FilenameFilter { + + private int count; + + public boolean accept(File dir, String name) { + if (name.endsWith(".class")) count++; + return false; + } + + public int getCount() { + return count; + } + } } diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml index 1510598fb..f4ac1a7bb 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml @@ -95,9 +95,9 @@ <ajc-test dir="java5/ataspectj" title="LTW DumpTest before and after"> <compile - files="ataspectj/DumpTest.java,ataspectj/DumpTestTheDump.java,ataspectj/TestHelper.java" + files="ataspectj/Test$$EnhancerByCGLIB$$12345.java" options="-1.5"/> - <run class="ataspectj.DumpTest" ltw="ataspectj/aop-dumpbeforeandafter.xml"/> + <run class="ataspectj.Test$$EnhancerByCGLIB$$12345" ltw="ataspectj/aop-dumpbeforeandafter.xml"/> </ajc-test> <ajc-test dir="java5/ataspectj" title="LTW DumpTest closure"> @@ -107,6 +107,13 @@ <run class="ataspectj.DumpTest" ltw="ataspectj/aop-dumpclosure.xml"/> </ajc-test> + <ajc-test dir="java5/ataspectj" title="LTW DumpTest proxy"> + <compile + files="ataspectj/TestProxyGenerator.java,ataspectj/TestInterface.java" + options="-1.5"/> + <ant file="ajc-ant.xml" target="ltw.DumpProxyTest" verbose="true"/> + </ajc-test> + <ajc-test dir="java5/ataspectj" title="Ajc Aspect1 LTW Aspect2 -Xreweavable"> <compile files="ataspectj/ltwreweavable/Main.java,ataspectj/ltwreweavable/Aspect1.java,ataspectj/ltwreweavable/Advisable.java" |