--- /dev/null
+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;
+ }
+}
--- /dev/null
+<aspectj>
+ <aspects>
+ <aspect name="com.foo.bar.TestAspect"/>
+ </aspects>
+
+ <weaver options="-verbose -XlazyTjp -showWeaveInfo">
+ <include within="com.foo.*"/>
+ </weaver>
+</aspectj>
--- /dev/null
+package com.foo.bar;
+
+import java.util.*;
+
+public class Test<T> {
+
+ Set<T> intsSet;
+
+ public Test() {
+ this.intsSet = new HashSet<T>();
+ }
+
+ public <T> 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<Object> mt = new Test<Object>();
+ Object[] arr = mt.getObjs(new Object[]{});
+ }
+}
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.....
<ajc-test dir="java5/generics/itds/design" title="generic itds - design G">
<compile files="DesignG.java" options="-1.5"/>
</ajc-test>
+
+ <ajc-test dir="bugs150/pr116626" title="NPE in WeavingAdaptor">
+ <compile files="com/foo/bar/Test.java, TestAspect.aj" options="-1.5"/>
+ <run class="com.foo.bar.Test" ltw="aop.xml"
+ >
+ </run>
+ </ajc-test>
</suite>
\ No newline at end of file
private class WeavingClassFileProvider implements IClassFileProvider {
+ private UnwovenClassFile unwovenClass;
private List unwovenClasses = new ArrayList(); /* List<UnovenClassFile> */
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() {
}
public byte[] getBytes () {
- return wovenClass.getBytes();
+ if (wovenClass != null) return wovenClass.getBytes();
+ else return unwovenClass.getBytes();
}
public Iterator getClassFileIterator() {