From 9a67e6290d6e330418f9b0ccaa94ec32d9f0aa49 Mon Sep 17 00:00:00 2001 From: mkersten Date: Wed, 26 Feb 2003 10:11:28 +0000 Subject: [PATCH] The mappings for advice are now correct, and associations have corresponding kinds (e.g. "affects exception handlers"). --- .../examples/coverage/ModelCoverage.java | 15 ++++--- .../testdata/examples/coverage/coverage.ajsym | Bin 10265 -> 12313 bytes .../org/aspectj/asm/AdviceAssociation.java | 16 +++---- weaver/src/org/aspectj/weaver/AsmAdaptor.java | 40 +++++++++++++++--- 4 files changed, 49 insertions(+), 22 deletions(-) diff --git a/ajde/testdata/examples/coverage/ModelCoverage.java b/ajde/testdata/examples/coverage/ModelCoverage.java index cf14bf080..c882d1674 100644 --- a/ajde/testdata/examples/coverage/ModelCoverage.java +++ b/ajde/testdata/examples/coverage/ModelCoverage.java @@ -1,5 +1,5 @@ -import java.io.*;; +import java.io.*; class Point { @@ -23,24 +23,25 @@ class Point { System.err.println("!"); } setX(10); + new Point(); } } -aspect PcdCoverage { +aspect AdvisesRelationCoverage { before(): get(int *.*) { } before(): set(int *.*) { } before(): initialization(Point.new(..)) { } before(): staticinitialization(Point) { } before(): handler(IOException) { } - before(): call(String Point.setX(int)) { } -// before(): call(String Point.new()) { } -// execution(): call(String Point.setX(int)) { } + before(): call(* Point.setX(int)) { } + before(): call(Point.new()) { } + before(): within(*) && execution(* Point.setX(..)) { } + before(): within(*) && execution(Point.new()) { } } aspect InterTypeDecCoverage { - pointcut illegalNewFigElt(): call(FigureElement+.new(..)) && - !withincode(* Main.main(..)); + pointcut illegalNewFigElt(): call(Point.new(..)) && !withincode(* *.doIt(..)); declare error: illegalNewFigElt(): "Illegal figure element constructor call."; diff --git a/ajde/testdata/examples/coverage/coverage.ajsym b/ajde/testdata/examples/coverage/coverage.ajsym index 27561a1b35f8eb861161f542f025acd358ccb56a..f796d993d55a2b0591f53d54be5c896cb0d93eac 100644 GIT binary patch delta 2366 zcma)8O>7%Q6rORMO>CUliIX^v(|DcOj#HH=j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=b4k7Yjabv82&|eGmY>nN=TgBahAGGw_-v?7ySs` zs4oOU(Jz7*U4%DLga}=PMdY1#6NLp{7zPF1^?qkFwq| z)qHp6$I9xS@pY3~?wcPqt0FjU5V}Pilu^!0= z({d*xged6pqWm$Hj>aH6c6)uO!??Lk{_l30URL-oVrNNh^1?+=B0V%No~U_`8M9`?g}xnN2p2|#VNq+BwX|{zY-tnBg9Z;8CgGEAj`JVF2r33~uc{PDLg*y9Mb<%Kp4A#A#N=o! zECfeJ#848J%ulM)+`5@0x-6FvvMvc&wFq#xvfY&74#osOEs`ETcz2+q>ZUdwm*V5n zV+(@@Y(EbQ*w14J+?M;rQI}+t!YhqMMrClyYUjhyOVzx$`XQ~>6jno3T*Xm%cPhp2 z&2rnhd{VIIsfOxW3lmUL;EFYejV}zljxl&?tI+*V$BsI7u5;KLwD^MX-4Q)jmrcWX zNM=@EYTZ$Z;qvgrZrF!tCvTIEc1fB`@g$LlV*#+Mjm&^b22={eU_)o|3edCgwBb>s zFE5$R{Wj%s#jSIouH(p(Pc~!8KAe@xEvbFP)JpTd4L%%w!4}n^ZVlIk4c8fFLu5Ou z56yn;Lli3A+VlSmD6fLTs-zZ0#N@@|t<>U`TIuV!07LG+4mrBe)7goVa~ zi3DG6TF1G<3i#~glE4l;Q&ix8Ma>l47iJq!8t n^`Q+uH}%qcQ0evIIoDXdzx<4%7ez1rOViT_Ih#tsRq4zhC31{B diff --git a/asm/src/org/aspectj/asm/AdviceAssociation.java b/asm/src/org/aspectj/asm/AdviceAssociation.java index c1914630d..842690ea2 100644 --- a/asm/src/org/aspectj/asm/AdviceAssociation.java +++ b/asm/src/org/aspectj/asm/AdviceAssociation.java @@ -23,14 +23,14 @@ import org.aspectj.asm.*; public class AdviceAssociation implements Association { public static final String NAME = "Advice"; - public static final Relation METHOD_RELATION = new Relation("affects methods", "method affected by", NAME, true, false); - public static final Relation METHOD_CALL_SITE_RELATION = new Relation("affects method call sites", "method call site affected by", NAME, true, false); - public static final Relation CONSTRUCTOR_RELATION = new Relation("affects constructors", "constructor affected by", NAME, true, false); - public static final Relation CONSTRUCTOR_CALL_SITE_RELATION = new Relation("affects constructions", "construction affected by", NAME, true, false); - public static final Relation HANDLER_RELATION = new Relation("affects handlers", "handler affected by", NAME, true, false); - public static final Relation INITIALIZER_RELATION = new Relation("affects initializers", "initializer affected by", NAME, true, false); - public static final Relation FIELD_ACCESS_RELATION = new Relation("affects field access", "field access affected by", NAME, true, false); - public static final Relation INTRODUCTION_RELATION = new Relation("affects introduction", "introduction affected by", NAME, true, false); + public static final Relation METHOD_RELATION = new Relation("advises methods", "method advised by", NAME, true, false); + public static final Relation METHOD_CALL_SITE_RELATION = new Relation("advises method call sites", "method call site advised by", NAME, true, false); + public static final Relation CONSTRUCTOR_RELATION = new Relation("advises constructors", "constructors advised by", NAME, true, false); + public static final Relation CONSTRUCTOR_CALL_SITE_RELATION = new Relation("advises constructions", "construction advised by", NAME, true, false); + public static final Relation HANDLER_RELATION = new Relation("advises exception handlers", "exception handler advised by", NAME, true, false); + public static final Relation INITIALIZER_RELATION = new Relation("advises initializers", "initializers advised by", NAME, true, false); + public static final Relation FIELD_ACCESS_RELATION = new Relation("advises field access", "field access advised by", NAME, true, false); + public static final Relation INTRODUCTION_RELATION = new Relation("advises introduction", "introduction advised by", NAME, true, false); private List relations = new ArrayList(); diff --git a/weaver/src/org/aspectj/weaver/AsmAdaptor.java b/weaver/src/org/aspectj/weaver/AsmAdaptor.java index c9c0e52c0..0c3c7201d 100644 --- a/weaver/src/org/aspectj/weaver/AsmAdaptor.java +++ b/weaver/src/org/aspectj/weaver/AsmAdaptor.java @@ -33,19 +33,45 @@ public class AsmAdaptor { // System.out.println("--------------------------"); ProgramElementNode targetNode = getNode(model, shadow); ProgramElementNode adviceNode = getNode(model, a); + + Relation relation; + if (shadow.getKind().equals(Shadow.FieldGet) || shadow.getKind().equals(Shadow.FieldSet)) { + relation = AdviceAssociation.FIELD_ACCESS_RELATION; + } else if (shadow.getKind().equals(Shadow.Initialization) || shadow.getKind().equals(Shadow.StaticInitialization)) { + relation = AdviceAssociation.INITIALIZER_RELATION; + } else if (shadow.getKind().equals(Shadow.ExceptionHandler)) { + relation = AdviceAssociation.HANDLER_RELATION; + } else if (shadow.getKind().equals(Shadow.MethodCall)) { + relation = AdviceAssociation.METHOD_CALL_SITE_RELATION; + } else if (shadow.getKind().equals(Shadow.ConstructorCall)) { + relation = AdviceAssociation.CONSTRUCTOR_CALL_SITE_RELATION; + } else if (shadow.getKind().equals(Shadow.MethodExecution) || shadow.getKind().equals(Shadow.AdviceExecution)) { + relation = AdviceAssociation.METHOD_RELATION; + } else if (shadow.getKind().equals(Shadow.ConstructorExecution)) { + relation = AdviceAssociation.CONSTRUCTOR_RELATION; + } else { + System.err.println("> unmatched relation: " + shadow.getKind()); + relation = AdviceAssociation.METHOD_RELATION; + } + // System.out.println("> target: " + targetNode + ", advice: " + adviceNode); - createAppropriateLinks(targetNode, adviceNode); + createAppropriateLinks(targetNode, adviceNode, relation); } } private static void createAppropriateLinks( ProgramElementNode target, - ProgramElementNode advice) + ProgramElementNode advice, + Relation relation) { if (target == null || advice == null) return; - addLink(target, new LinkNode(advice), org.aspectj.asm.AdviceAssociation.METHOD_RELATION, true); - addLink(advice, new LinkNode(target), org.aspectj.asm.AdviceAssociation.METHOD_RELATION, false); -// System.out.println(">> added target: " + target + ", advice: " + advice); + + + addLink(target, new LinkNode(advice), relation, true); + addLink(advice, new LinkNode(target), relation, false); + +// System.out.println(">> added target: " + target.getProgramElementKind() + ", advice: " + advice); +// System.out.println(">> target: " + target + ", advice: " + target.getSourceLocation()); } private static void addLink( @@ -120,7 +146,8 @@ public class AsmAdaptor { ProgramElementNode peNode = new ProgramElementNode( shadow.toString(), ProgramElementNode.Kind.CODE, - new SourceLocation(enclosingNode.getSourceLocation().getSourceFile(), sl.getLine()), +// new SourceLocation(enclosingNode.getSourceLocation().getSourceFile(), sl.getLine()), + enclosingNode.getSourceLocation(), 0, "", new ArrayList()); @@ -158,7 +185,6 @@ public class AsmAdaptor { } } // if we can't find the member, we'll just put it in the class - //??? is this what the IDEs want return classNode; } -- 2.39.5