]> source.dussan.org Git - aspectj.git/commitdiff
tests and fix for pr88900, unneccessary warning
authoracolyer <acolyer>
Tue, 27 Sep 2005 15:00:24 +0000 (15:00 +0000)
committeracolyer <acolyer>
Tue, 27 Sep 2005 15:00:24 +0000 (15:00 +0000)
tests/bugs150/pr104229.aj [new file with mode: 0644]
tests/bugs150/pr88900.aj [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/ResolvedTypeMunger.java

diff --git a/tests/bugs150/pr104229.aj b/tests/bugs150/pr104229.aj
new file mode 100644 (file)
index 0000000..d3feb32
--- /dev/null
@@ -0,0 +1,132 @@
+import java.lang.annotation.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import java.awt.*;
+
+interface GoalSelectedNotice {
+         public void goalSelected(Object goal);
+}
+
+@Retention(RetentionPolicy.RUNTIME) 
+@interface DefaultImplementation {}
+
+aspect X {
+       /**
+        * Watch for goalSelected(..) method being called when
+        * not within this aspect.
+        */
+       pointcut goalSelectedPointcut(GoalSelectedNotice _this, Object goal): 
+               call(void GoalSelectedNotice.goalSelected(Object))
+           && target(_this) && args(goal) && !cflow(adviceexecution());        
+       
+       declare warning : call(void GoalSelectedNotice.goalSelected(Object)) : "bingo";
+       
+       after(Object caller, Object o) returning : call(void GoalSelectedNotice.goalSelected(Object)) && args(o) && target(caller){
+               System.out.println("call match " + caller.getClass());
+       }
+       
+       after(GoalSelectedNotice _this, Object goal) returning:
+       goalSelectedPointcut(_this, goal){
+         System.out.println("OK it worked!");
+       }
+       /**
+        * Empty body, can be overriden by classes implementing
+        * {@link GoalSelectedNotice}.
+        */
+    @DefaultImplementation 
+       public void GoalSelectedNotice.goalSelected(Object goal){
+       }
+}
+
+public class pr104229 implements GoalSelectedNotice {
+       
+       interface CallMe { void doIt(); }
+       
+       public static void main(String[] args) {
+               pr104229 pr = new pr104229();
+               pr.callInner();
+       }
+       
+       public void callInner() {
+               
+               CallMe callMe = new CallMe() {
+                       public void doIt() {
+                               pr104229.this.goalSelected("MyGoal");
+                       }
+               };
+               
+               callMe.doIt();
+               
+       }
+       
+       
+}
+
+class ListPanel extends JPanel implements GoalSelectedNotice{
+
+       private JComboBox jComboBox = null;
+       private JList jList = null;
+       /**
+        * This is the default constructor
+        */
+       public ListPanel() {
+               super();
+               initialize();
+       }
+       /**
+        * This method initializes this
+        * 
+        * @return void
+        */
+       private  void initialize() {
+               this.setLayout(new BorderLayout());
+               this.setSize(300,200);
+               this.add(getJComboBox(), java.awt.BorderLayout.NORTH);
+               this.add(getJList(), java.awt.BorderLayout.CENTER);
+       }
+       /**
+        * This method initializes jComboBox    
+        *      
+        * @return javax.swing.JComboBox        
+        */    
+       private JComboBox getJComboBox() {
+               if (jComboBox == null) {
+                       jComboBox = new JComboBox((ComboBoxModel)null);
+               }
+               return jComboBox;
+       }
+       /**
+        * This method initializes jList        
+        *      
+        * @return javax.swing.JList    
+        */    
+       private JList getJList() {
+               if (jList == null) { 
+                       jList = new JList((ListModel)null);
+                       jList.addListSelectionListener(
+                                       new  ListSelectionListener(){
+                                               public void valueChanged(ListSelectionEvent e){
+                                                       if(!e.getValueIsAdjusting()){
+                                                               JList list = (JList)e.getSource();
+                                                               Object goal = list.getSelectedValue();
+                                                               System.out.println(goal);
+
+// If I replace the line below with...
+                                                               ListPanel.this.goalSelected(goal); //the join point is not seen!;
+// This was working before a switched to source level 5!                               
+                               ListPanel.this.sendGoalSelectedNotice(goal); // this is workaround!
+
+                                                       }
+                                               }
+                                       }
+                                       );
+               }
+               return jList;
+       }
+
+       // this is part of workaround
+       protected void sendGoalSelectedNotice(Object goal){
+                // join point is found by pointcut here!  This is ok!
+               goalSelected(goal);
+       }
+}
\ No newline at end of file
diff --git a/tests/bugs150/pr88900.aj b/tests/bugs150/pr88900.aj
new file mode 100644 (file)
index 0000000..4f3e65b
--- /dev/null
@@ -0,0 +1,5 @@
+aspect RunnableDefaultImpl {
+       
+       public void Runnable.run() {}
+       
+}
index 6c3cb6dac47c7a6d56916a7d882af0a81032bee2..15516c6fcaa24bc80dfe693463baf5c4e04c4a3e 100644 (file)
@@ -454,6 +454,14 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
          runTest("parameterized generic methods");
   }
   
+  public void testCallJoinPointsInAnonymousInnerClasses() {
+         runTest("call join points in anonymous inner classes");
+  }
+  
+  public void testNoRequirementForUnwovenTypesToBeExposedToWeaver() {
+         runTest("default impl of Runnable");
+  }
+  
   // helper methods.....
   
   public SyntheticRepository createRepos(File cpentry) {
index fb1ce4b0b545591c44c745343d624876c89e88f0..eb518ceba8dd70734cbab35573270989384747a4 100644 (file)
         </compile>
     </ajc-test> 
     
+    <ajc-test dir="bugs150" title="call join points in anonymous inner classes">
+        <compile files="pr104229.aj" options="-1.5">
+            <message kind="warning" line="54" text="bingo"/>
+            <message kind="warning" line="115" text="bingo"/>
+            <message kind="warning" line="130" text="bingo"/>
+        </compile>
+        <run class="pr104229">
+            <stdout>
+                <line text="call match class pr104229"/>
+                <line text="OK it worked!"/>
+            </stdout>
+        </run>
+    </ajc-test>
+
+    <ajc-test dir="bugs150" title="default impl of Runnable">
+        <compile files="pr88900.aj" options="-Xdev:Pinpoint">
+        </compile>
+    </ajc-test> 
+    
     <!-- ============================================================================ -->
     <!-- ============================================================================ -->
     
index f921ad69ae02661414a58b33e6bb3de7d08b072f..e602170c48a4d4933aca1cf7582e7a0860650b4c 100644 (file)
@@ -87,7 +87,11 @@ public abstract class ResolvedTypeMunger {
        //System.err.println("matching: " + this + " to " + matchType + " onType = " + onType);
                if (matchType.equals(onType)) { 
                        if (!onType.isExposedToWeaver()) {
-                               if (onType.getWeaverState() == null) {
+                               // if the onType is an interface, and it already has the member we are about
+                               // to munge, then this is ok...
+                               boolean ok = (onType.isInterface() && (onType.lookupMemberWithSupersAndITDs(getSignature()) != null));
+                               
+                               if (!ok && onType.getWeaverState() == null) {
                                        if (matchType.getWorld().getLint().typeNotExposedToWeaver.isEnabled()) {
                                                matchType.getWorld().getLint().typeNotExposedToWeaver.signal(
                                                        matchType.getName(), signature.getSourceLocation());