]> source.dussan.org Git - aspectj.git/commitdiff
test and fixes for 117681
authoraclement <aclement>
Wed, 23 Nov 2005 12:54:02 +0000 (12:54 +0000)
committeraclement <aclement>
Wed, 23 Nov 2005 12:54:02 +0000 (12:54 +0000)
tests/bugs150/pr117681/Audit.java [new file with mode: 0644]
tests/bugs150/pr117681/AuditImpl.java [new file with mode: 0644]
tests/bugs150/pr117681/MoodIndicator.java [new file with mode: 0644]
tests/bugs150/pr117681/Test.java [new file with mode: 0644]
tests/bugs150/pr117681/TestAspect.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java

diff --git a/tests/bugs150/pr117681/Audit.java b/tests/bugs150/pr117681/Audit.java
new file mode 100644 (file)
index 0000000..b575cef
--- /dev/null
@@ -0,0 +1,4 @@
+public interface Audit {
+   public String getLastUpdatedBy();
+   public void   setLastUpdatedBy(String un);
+}
diff --git a/tests/bugs150/pr117681/AuditImpl.java b/tests/bugs150/pr117681/AuditImpl.java
new file mode 100644 (file)
index 0000000..3143218
--- /dev/null
@@ -0,0 +1,10 @@
+public class AuditImpl implements Audit {
+   private String lastUpdatedBy;
+   public String getLastUpdatedBy() {
+       return lastUpdatedBy;
+   }
+   public void setLastUpdatedBy(String un) {
+       lastUpdatedBy = un;
+   }
+}
+
diff --git a/tests/bugs150/pr117681/MoodIndicator.java b/tests/bugs150/pr117681/MoodIndicator.java
new file mode 100644 (file)
index 0000000..ec420ad
--- /dev/null
@@ -0,0 +1,42 @@
+import org.aspectj.lang.annotation.*;
+
+class Mood {
+  public final static Mood HAPPY=new Mood();
+}
+   // this interface can be outside of the aspect
+    interface Moody {
+     Mood getMood(int i);
+   };
+
+   // this implementation can be outside of the aspect
+    class MoodyImpl implements Moody {
+      private Mood mood = Mood.HAPPY;
+
+      public Mood getMood(int i) {
+        return mood;
+      }
+   }
+@Aspect
+public class MoodIndicator {
+
+
+   // here is the actual ITD syntax when using @AspectJ
+   // public static is mandatory
+   // the field type must be the introduced interface. It can't be a class.
+   @DeclareParents("C")
+   public static Moody introduced = new MoodyImpl();
+
+//   @Before("execution(* *.*(..)) && this(m)")
+//   public void feelingMoody(Moody m) {
+//      System.out.println("I'm feeling " + m.getMood());
+//   }
+
+  public static void main(String []argv) {
+    ((Moody)new C()).getMood(7);
+  }
+}
+
+
+class C {
+  
+}
diff --git a/tests/bugs150/pr117681/Test.java b/tests/bugs150/pr117681/Test.java
new file mode 100644 (file)
index 0000000..6c7f326
--- /dev/null
@@ -0,0 +1,7 @@
+public class Test {
+    public static void main(String[] args) {
+        Audit a = (Audit)new Test();
+        a.setLastUpdatedBy("username");
+        System.out.println("Username ="+a.getLastUpdatedBy());
+    }
+}
diff --git a/tests/bugs150/pr117681/TestAspect.java b/tests/bugs150/pr117681/TestAspect.java
new file mode 100644 (file)
index 0000000..3316774
--- /dev/null
@@ -0,0 +1,7 @@
+import org.aspectj.lang.annotation.*;
+
+@Aspect
+public class TestAspect {
+  @DeclareParents("Test")
+  public static Audit introduced = new AuditImpl();
+}
index abec35200f5fffdcaaed3170eae10b1622d8ff5c..be703cb0345362a136d7897958384a5db0a81745 100644 (file)
@@ -49,6 +49,7 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
   public void testGenericITDsAndAbstractMethodError_pr102357() { runTest("generic itds and abstract method error");}
   */
   
+  public void testAtDeclareParents_pr117681() { runTest("at declare parents");}
   public void testPrivilegeProblem_pr87525() { runTest("privilege problem with switch");}
   public void testGenericAspects_pr115237() { runTest("aspectOf and generic aspects");}
   public void testClassFormatError_pr114436() { runTest("ClassFormatError binary weaving perthis");}
index 373a56a0a3c04d6afec2e57e86433a8e4b87451b..5b072abf7a25c4621e75fdba5d8623901fb38dc1 100644 (file)
      <compile files="Pr112756.aj" options="-warn:assertIdentifier -Xdev:Pinpoint"/>
     </ajc-test>
     
+    <ajc-test dir="bugs150/pr117681" pr="117681" title="at declare parents">
+     <compile files="Test.java,TestAspect.java,Audit.java,AuditImpl.java" options="-1.5"/>
+     <run class="Test"/>
+    </ajc-test>
+    
     <ajc-test dir="bugs150/pr117296" pr="117296" title="self bounding generic types">
      <compile files="PropertySupport.java" options="-1.5"/>
      <run class="PropertySupport"/>
index 3c7dc1639dd71cc862ec4e5014f016d2c37e7ba1..9bbd0d49e07d5fad5f811a054b28b1da17d41d1d 100644 (file)
@@ -1107,6 +1107,10 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
             body.append(Utility.createGet(fact, munger.getDelegate()));
 
             int pos = 0;
+               if (!introduced.isStatic()) { // skip 'this'
+                 //body.append(InstructionFactory.createThis());
+                 pos++;
+               }
             Type[] paramTypes = BcelWorld.makeBcelTypes(introduced.getParameterTypes());
             for (int i = 0, len = paramTypes.length; i < len; i++) {
                 Type paramType = paramTypes[i];