]> source.dussan.org Git - aspectj.git/commitdiff
fix NPE in mixing style (can be in concrete aspect from code style as well)
authoravasseur <avasseur>
Mon, 19 Dec 2005 15:06:51 +0000 (15:06 +0000)
committeravasseur <avasseur>
Mon, 19 Dec 2005 15:06:51 +0000 (15:06 +0000)
tests/java5/ataspectj/ataspectj/DeclareParentsImplementsReweavableTest.java
tests/java5/ataspectj/ataspectj/DeclareParentsImplementsTest.java
tests/java5/ataspectj/ataspectj/bugs/AbstractInherited.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java
tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml
weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java

index fad0d8488df387aac65d0b37ded56b1ae2f1aacc..1636328ab2ee89511e3d76a09c8290689ac5d39e 100644 (file)
@@ -26,7 +26,7 @@ public class DeclareParentsImplementsReweavableTest extends TestCase {
 
     static interface I1 { int do1(); }
 
-    static class Imp1 implements I1 {
+    public static class Imp1 implements I1 {
         public int do1() {return 1;}
     }
 
index b4cc9ed4e4783ee9d03d4d4ec452fd7c1e0ed79b..8ce1e191599105484c499c9f40358f1bd6c0208b 100644 (file)
@@ -41,6 +41,9 @@ public class DeclareParentsImplementsTest extends TestCase {
     }
 
     static class Implementation implements Introduced {
+        public Implementation(int i) {}
+        public Implementation() {}
+
         public void intro() {
             log("intro-"+field1);
             // we cannot copy the raw bytecode as there might be super.* calls, and other OO stuff
diff --git a/tests/java5/ataspectj/ataspectj/bugs/AbstractInherited.java b/tests/java5/ataspectj/ataspectj/bugs/AbstractInherited.java
new file mode 100644 (file)
index 0000000..397c1ad
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ * 
+ * Contributors:
+ *   Alexandre Vasseur         initial implementation
+ *******************************************************************************/
+package ataspectj.bugs;
+
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Around;
+
+/**
+ * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+//@Aspect
+public abstract aspect AbstractInherited {
+
+    //@Around("execution(* foo(..))")
+    //public Object around() {
+    //    return null;
+    //}
+
+  void around(): execution(* foo(..)) {
+  }        
+
+}
+
+@Aspect
+class Sub extends AbstractInherited {
+}
+
+class C {
+    void foo() {
+    }
+}
+
+
index c462cdea8f3746a040e4758f0fa5c381bb1bafd3..4a86350817b12652878f9aa5b8ceacd15fdba251 100644 (file)
@@ -133,4 +133,8 @@ public class AtAjSyntaxTests extends XMLBasedAjcTestCase {
         runTest("AbstractAspectNPE");
     }
 
+    public void testAbstractInherited() {
+        runTest("AbstractInherited");
+    }
+
 }
index 015d8c1dc9ba02773f277ff20b11a2b3133e5eae..09b3c6d78929028b9f0211bbf3aa401909f903a0 100644 (file)
         </compile>
     </ajc-test>
 
+
+    <ajc-test dir="java5/ataspectj" title="AbstractInherited">
+        <compile files="ataspectj/bugs/AbstractInherited.java"
+            options="-1.5 -showWeaveInfo">
+            <message kind="weave" text="Join point "/>
+        </compile>
+    </ajc-test>
+
 </suite>
\ No newline at end of file
index e6f0d88c8a87d95d9b34672f4d0556362e8f3a87..5d6a5fcb6382836f143e9241a11c3c13d8742a80 100644 (file)
@@ -454,11 +454,14 @@ public class BcelAdvice extends Advice {
                            }
                        } else if (hasExtraParameter()) {
                         previousIsClosure = false;
-                           extraVar.appendLoadAndConvert(
-                               il,
-                               fact,
-                               getExtraParameterType().resolve(world));
-                       } else {
+                        //extra var can be null here (@Aj aspect extends abstract code style, advice in code style)
+                        if (extraVar != null) {
+                            extraVar.appendLoadAndConvert(
+                                il,
+                                fact,
+                                getExtraParameterType().resolve(world));
+                        }
+                    } else {
                         previousIsClosure = false;
                         getConcreteAspect().getWorld().getMessageHandler().handleMessage(
                                 new Message(