From: aclement Date: Fri, 18 Nov 2005 09:01:17 +0000 (+0000) Subject: test and fix for 116626 from Matthew. X-Git-Tag: V1_5_0RC1~168 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c7608950f0deb6f9951435f58209ad60aaf28e06;p=aspectj.git test and fix for 116626 from Matthew. --- diff --git a/tests/bugs150/pr116626/TestAspect.aj b/tests/bugs150/pr116626/TestAspect.aj new file mode 100644 index 000000000..105a53eb9 --- /dev/null +++ b/tests/bugs150/pr116626/TestAspect.aj @@ -0,0 +1,19 @@ +package com.foo.bar; + +public privileged aspect TestAspect { + + pointcut TestToArray(Test mt) : + target(mt) && + !within(TestAspect); + + + Object[] around(Test mt, Object[] objs) : + TestToArray(mt) && + args(objs) && + execution(Object[] Test.getObjs(Object[])) { + + objs = proceed(mt, objs); + System.out.println("GO Aspects!"); + return objs; + } +} diff --git a/tests/bugs150/pr116626/aop.xml b/tests/bugs150/pr116626/aop.xml new file mode 100644 index 000000000..93ca6dd43 --- /dev/null +++ b/tests/bugs150/pr116626/aop.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/bugs150/pr116626/com/foo/bar/Test.java b/tests/bugs150/pr116626/com/foo/bar/Test.java new file mode 100644 index 000000000..5b255baee --- /dev/null +++ b/tests/bugs150/pr116626/com/foo/bar/Test.java @@ -0,0 +1,28 @@ +package com.foo.bar; + +import java.util.*; + +public class Test { + + Set intsSet; + + public Test() { + this.intsSet = new HashSet(); + } + + public T[] getObjs(T[] a) { + return intsSet.toArray(a); + } + + public static void main(String[] args) { + System.out.println("AAA :-)"); + new TTT().foo(); + } +} + +class TTT { + public void foo() { + Test mt = new Test(); + Object[] arr = mt.getObjs(new Object[]{}); + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index eab3ffac6..08209ca26 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -712,6 +712,11 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testNoStackOverflowWithCircularPCDInGenericAspect2() { runTest("no StackOverflowError with circular pcd in generic aspect - 2"); } + + /* + * Load-time weaving bugs + */ + public void testNPEinWeavingAdaptor_pr116626() { runTest("NPE in WeavingAdaptor");} // helper methods..... diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index a2075580f..de7cf19d2 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -5559,5 +5559,12 @@ + + + + + + \ No newline at end of file diff --git a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java index ea7590273..6d11ff307 100644 --- a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java +++ b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java @@ -387,14 +387,15 @@ public class WeavingAdaptor { private class WeavingClassFileProvider implements IClassFileProvider { + private UnwovenClassFile unwovenClass; private List unwovenClasses = new ArrayList(); /* List */ private UnwovenClassFile wovenClass; private boolean isApplyAtAspectJMungersOnly = false; public WeavingClassFileProvider (String name, byte[] bytes) { - UnwovenClassFile unwoven = new UnwovenClassFile(name,bytes); - unwovenClasses.add(unwoven); - bcelWorld.addSourceObjectType(unwoven.getJavaClass()); + this.unwovenClass = new UnwovenClassFile(name,bytes); + this.unwovenClasses.add(unwovenClass); + bcelWorld.addSourceObjectType(unwovenClass.getJavaClass()); } public void setApplyAtAspectJMungersOnly() { @@ -406,7 +407,8 @@ public class WeavingAdaptor { } public byte[] getBytes () { - return wovenClass.getBytes(); + if (wovenClass != null) return wovenClass.getBytes(); + else return unwovenClass.getBytes(); } public Iterator getClassFileIterator() {