From e76b37012601cf67a069b4a78f60f183efad563d Mon Sep 17 00:00:00 2001 From: acolyer Date: Tue, 27 Sep 2005 15:00:24 +0000 Subject: [PATCH] tests and fix for pr88900, unneccessary warning --- tests/bugs150/pr104229.aj | 132 ++++++++++++++++++ tests/bugs150/pr88900.aj | 5 + .../systemtest/ajc150/Ajc150Tests.java | 8 ++ .../org/aspectj/systemtest/ajc150/ajc150.xml | 19 +++ .../aspectj/weaver/ResolvedTypeMunger.java | 6 +- 5 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 tests/bugs150/pr104229.aj create mode 100644 tests/bugs150/pr88900.aj diff --git a/tests/bugs150/pr104229.aj b/tests/bugs150/pr104229.aj new file mode 100644 index 000000000..d3feb328b --- /dev/null +++ b/tests/bugs150/pr104229.aj @@ -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 index 000000000..4f3e65bc8 --- /dev/null +++ b/tests/bugs150/pr88900.aj @@ -0,0 +1,5 @@ +aspect RunnableDefaultImpl { + + public void Runnable.run() {} + +} diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index 6c3cb6dac..15516c6fc 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -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) { diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index fb1ce4b0b..eb518ceba 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -607,6 +607,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java b/weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java index f921ad69a..e602170c4 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java +++ b/weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java @@ -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()); -- 2.39.5