]> source.dussan.org Git - aspectj.git/commitdiff
fix source location for @AJ + fix the AsmManager behavior for @AJ (still no luck...
authoravasseur <avasseur>
Mon, 4 Jul 2005 12:58:41 +0000 (12:58 +0000)
committeravasseur <avasseur>
Mon, 4 Jul 2005 12:58:41 +0000 (12:58 +0000)
15 files changed:
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EclipseSourceContext.java
tests/java5/ataspectj/ajc-ant.xml
tests/java5/ataspectj/ataspectj/SingletonAspectBindingsTest.java
tests/java5/ataspectj/ataspectj/SingletonAspectBindingsTest2.aj [new file with mode: 0644]
tests/src/org/aspectj/systemtest/AllTests.java
tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java
tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml
weaver/build.xml
weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java
weaver/src/org/aspectj/weaver/bcel/BcelMethod.java
weaver/src/org/aspectj/weaver/bcel/BcelSourceContext.java
weaver/src/org/aspectj/weaver/patterns/PerFromSuper.java
weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java

index 50a2a11c5ed001afff3c447515f22c5d3a3cdc7b..e298c2498045e04608f4596215d22f49ae2b7739 100644 (file)
@@ -1,13 +1,14 @@
 /* *******************************************************************
  * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved. 
- * This program and the accompanying materials are made available 
- * under the terms of the Common Public License v1.0 
- * which accompanies this distribution and is available at 
- * http://www.eclipse.org/legal/cpl-v10.html 
- *  
- * Contributors: 
- *     PARC     initial implementation 
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Common Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ *     PARC                     initial implementation
+ *     Alexandre Vasseur        support for @AJ style
  * ******************************************************************/
 
 package org.aspectj.ajdt.internal.core.builder;
@@ -39,6 +40,7 @@ import org.aspectj.weaver.patterns.TypePattern;
 import org.aspectj.weaver.patterns.TypePatternList;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation;
 
 /**
  * @author Mik Kersten
@@ -218,9 +220,31 @@ public class AsmElementFormatter {
                                node.setKind(IProgramElement.Kind.CONSTRUCTOR);
                        } else {
                                node.setKind(IProgramElement.Kind.METHOD);
-                       } 
-                       String label = new String(methodDeclaration.selector);
-                       node.setName(label); 
+
+                //TODO AV - could speed up if we could dig only for @Aspect declaring types (or aspect if mixed style allowed)
+                //??? how to : node.getParent().getKind().equals(IProgramElement.Kind.ASPECT)) {
+                if (true && methodDeclaration.annotations != null) {
+                    for (int i = 0; i < methodDeclaration.annotations.length; i++) {
+                        //Note: AV: implicit single advice type support here (should be enforced somewhere as well (APT etc))
+                        Annotation annotation = methodDeclaration.annotations[i];
+                        String annotationSig = new String(annotation.type.getTypeBindingPublic(methodDeclaration.scope).signature());
+                        if ("Lorg/aspectj/lang/annotation/Pointcut;".equals(annotationSig)) {
+                            node.setKind(IProgramElement.Kind.POINTCUT);
+                            break;
+                        } else if ("Lorg/aspectj/lang/annotation/Before;".equals(annotationSig)
+                                   || "Lorg/aspectj/lang/annotation/After;".equals(annotationSig)
+                                   || "Lorg/aspectj/lang/annotation/AfterReturning;".equals(annotationSig)
+                                   || "Lorg/aspectj/lang/annotation/AfterThrowing;".equals(annotationSig)
+                                   || "Lorg/aspectj/lang/annotation/Around;".equals(annotationSig)) {
+                            node.setKind(IProgramElement.Kind.ADVICE);
+                            //TODO AV - all are considered anonymous - is that ok?
+                            node.setDetails(POINTCUT_ANONYMOUS);
+                            break;
+                        }
+                    }
+                }
+                       }
+                       node.setName(new String(methodDeclaration.selector));
                        setParameters(methodDeclaration, node);
                }
        }
index 04d2bde9f1b2069c9c16caac668af97f40e33fe4..8f5cc266df78cc41d83474165488f4654e6449cf 100644 (file)
@@ -1,14 +1,15 @@
 /* *******************************************************************
  * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved. 
- * This program and the accompanying materials are made available 
- * under the terms of the Common Public License v1.0 
- * which accompanies this distribution and is available at 
- * http://www.eclipse.org/legal/cpl-v10.html 
- *  
- * Contributors: 
- *     PARC     initial implementation 
- *     Mik Kersten     revisions, added additional relationships 
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Common Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ *     PARC     initial implementation
+ *     Mik Kersten     revisions, added additional relationships
+ *     Alexandre Vasseur        support for @AJ style
  * ******************************************************************/
 
  
@@ -211,6 +212,17 @@ public class AsmHierarchyBuilder extends ASTVisitor {
                else if (typeDeclaration.kind() == IGenericType.ENUM_DECL) kind = IProgramElement.Kind.ENUM;
                else if (typeDeclaration.kind() == IGenericType.ANNOTATION_TYPE_DECL) kind = IProgramElement.Kind.ANNOTATION;
 
+        //@AJ support
+        if (typeDeclaration.annotations != null) {
+            for (int i = 0; i < typeDeclaration.annotations.length; i++) {
+                Annotation annotation = typeDeclaration.annotations[i];
+                if (Arrays.equals(annotation.type.getTypeBindingPublic(scope).signature(),
+                                  "Lorg/aspectj/lang/annotation/Aspect;".toCharArray())) {
+                    kind = IProgramElement.Kind.ASPECT;
+                }
+            }
+        }
+
                IProgramElement peNode = new ProgramElement(
                        name,
                        kind,
@@ -239,6 +251,17 @@ public class AsmHierarchyBuilder extends ASTVisitor {
                else if (memberTypeDeclaration.kind() == IGenericType.ENUM_DECL) kind = IProgramElement.Kind.ENUM;
                else if (memberTypeDeclaration.kind() == IGenericType.ANNOTATION_TYPE_DECL) kind = IProgramElement.Kind.ANNOTATION;
 
+        //@AJ support
+        if (memberTypeDeclaration.annotations != null) {
+            for (int i = 0; i < memberTypeDeclaration.annotations.length; i++) {
+                Annotation annotation = memberTypeDeclaration.annotations[i];
+                if (Arrays.equals(annotation.type.getTypeBindingPublic(scope).signature(),
+                                  "Lorg/aspectj/lang/annotation/Aspect;".toCharArray())) {
+                    kind = IProgramElement.Kind.ASPECT;
+                }
+            }
+        }
+
                IProgramElement peNode = new ProgramElement(
                        name,
                        kind,
@@ -277,6 +300,18 @@ public class AsmHierarchyBuilder extends ASTVisitor {
                else if (memberTypeDeclaration.kind() == IGenericType.ENUM_DECL) kind = IProgramElement.Kind.ENUM;
                else if (memberTypeDeclaration.kind() == IGenericType.ANNOTATION_TYPE_DECL) kind = IProgramElement.Kind.ANNOTATION;
 
+        //@AJ support
+        if (memberTypeDeclaration.annotations != null) {
+            for (int i = 0; i < memberTypeDeclaration.annotations.length; i++) {
+                Annotation annotation = memberTypeDeclaration.annotations[i];
+                if (Arrays.equals(annotation.type.getTypeBindingPublic(scope).signature(),
+                                  "Lorg/aspectj/lang/annotation/Aspect;".toCharArray())) {
+                    kind = IProgramElement.Kind.ASPECT;
+                    break;
+                }
+            }
+        }
+
                IProgramElement peNode = new ProgramElement(
                        fullName,
                        kind,
index 0561203734511b9a429d84fdfa79de0ce0e4cf53..b3fc473b4a837879842bb885a67543ce17c7f827 100644 (file)
@@ -50,8 +50,19 @@ public class EclipseSourceContext implements ISourceContext {
                return new EclipseSourceLocation(result, position.getStart(), position.getEnd());
        }
 
-       public ISourceLocation makeSourceLocation(int line) {
-               return new SourceLocation(getSourceFile(), line);
+    public ISourceLocation makeSourceLocation(int line) {
+               SourceLocation sl = new SourceLocation(getSourceFile(), line);
+
+        // compute the offset
+        //TODO AV - should we do it lazily?
+        int[] offsets = result.lineSeparatorPositions;
+        int likelyOffset = 0;
+        if (line > 0 && line < offsets.length) {
+            //1st char of given line is next char after previous end of line
+            likelyOffset = offsets[line-1];
+        }
+        sl.setOffset(likelyOffset);
+        return sl;
        }
 
 }
index e4d4008eb90c289ebd64236571cc8f6bca82a582..bd5f98a2b98d7a2ff6fd80dc6a33d7459d46c52e 100644 (file)
@@ -21,7 +21,7 @@
             <!-- use META-INF/aop.xml style -->
             <classpath path="ataspectj/pathentry"/>
             <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
-            <!--<jvmarg line="${jdwp}"/>-->
+<!--            <jvmarg line="${jdwp}"/>-->
         </java>
     </target>
 
index 27ce636b4254b5cf43992e11eb55de453373cd90..e59821cb8b226416f3c1f687c2d90d1e1006b35d 100644 (file)
@@ -19,6 +19,9 @@ import org.aspectj.lang.JoinPoint;
 import org.aspectj.lang.ProceedingJoinPoint;
 import junit.framework.TestCase;
 
+import java.io.File;
+import java.io.FileReader;
+
 /**
  * Test various advice and JoinPoint + binding, without pc ref
  *
@@ -129,4 +132,20 @@ public class SingletonAspectBindingsTest extends TestCase {
         }
 
     }
+
+//    public void testHe() throws Throwable {
+//        //Allow to look inn file based on advises/advised-by offset numbers   
+//        File f = new File("../tests/java5/ataspectj/ataspectj/SingletonAspectBindingsTest2.aj");
+//        FileReader r = new FileReader(f);
+//        int i = 0;
+//        for (i = 0; i < 2800; i++) {
+//            r.read();
+//        }
+//        for (;i < 2900; i++) {
+//            if (i == 2817) System.out.print("X");
+//            System.out.print((char)r.read());
+//        }
+//        System.out.print("|DONE");
+//        r.close();
+//    }
 }
diff --git a/tests/java5/ataspectj/ataspectj/SingletonAspectBindingsTest2.aj b/tests/java5/ataspectj/ataspectj/SingletonAspectBindingsTest2.aj
new file mode 100644 (file)
index 0000000..5083375
--- /dev/null
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * 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:
+ * initial implementation              Alexandre Vasseur
+ *******************************************************************************/
+package ataspectj;
+
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.After;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.ProceedingJoinPoint;
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.io.FileReader;
+
+/**
+ * Test various advice and JoinPoint + binding, without pc ref
+ *
+ * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+public class SingletonAspectBindingsTest2 extends TestCase {
+
+    static StringBuffer s_log = new StringBuffer();
+    static void log(String s) {
+        s_log.append(s).append(" ");
+    }
+
+    public static void main(String[] args) {
+        TestHelper.runAndThrowOnFailure(suite());
+    }
+
+    public static junit.framework.Test suite() {
+        return new junit.framework.TestSuite(SingletonAspectBindingsTest2.class);
+    }
+
+    public void hello() {
+        log("hello");
+    }
+
+    public void hello(String s) {
+        log("hello-");
+        log(s);
+    }
+
+    public void testExecutionWithThisBinding() {
+        s_log = new StringBuffer();
+        SingletonAspectBindingsTest2 me = new SingletonAspectBindingsTest2();
+        me.hello();
+        // see here advice precedence as in source code order
+        //TODO check around relative order
+        // see fix in BcelWeaver sorting shadowMungerList
+        //assertEquals("around2_ around_  before hello after _around _around2 ", s_log.toString());
+        assertEquals("around_ around2_ before hello _around2 _around after ", s_log.toString());
+    }
+
+    public void testExecutionWithArgBinding() {
+        s_log = new StringBuffer();
+        SingletonAspectBindingsTest2 me = new SingletonAspectBindingsTest2();
+        me.hello("x");
+        assertEquals("before- x hello- x ", s_log.toString());
+    }
+
+
+    //@Aspect
+    static aspect TestAspect {
+
+        static int s = 0;
+
+        static {
+            s++;
+        }
+
+        public TestAspect() {
+            // assert clinit has run when singleton aspectOf reaches that
+            assertTrue(s>0);
+        }
+
+        //public static TestAspect aspectOf() {return null;}
+
+        void around() : execution(* ataspectj.SingletonAspectBindingsTest2.hello()) {
+        //public void aaround(ProceedingJoinPoint jp) {
+            log("around_");
+            try {
+                proceed();
+            } catch (Throwable throwable) {
+                throwable.printStackTrace();
+            }
+            log("_around");
+        }
+
+        void around(Object t) : execution(* ataspectj.SingletonAspectBindingsTest2.hello()) && this(t) {
+        //public void around2(ProceedingJoinPoint jp, Object t) {
+            log("around2_");
+            assertEquals(SingletonAspectBindingsTest2.class.getName(), t.getClass().getName());
+            try {
+                proceed(t);
+            } catch (Throwable throwable) {
+                throwable.printStackTrace();
+            }
+            log("_around2");
+        }
+
+        before() : execution(* ataspectj.SingletonAspectBindingsTest2.hello()) {
+        //public void before(JoinPoint.StaticPart sjp) {
+            log("before");
+            assertEquals("hello", thisJoinPointStaticPart.getSignature().getName());
+        }
+
+        after() : execution(* ataspectj.SingletonAspectBindingsTest2.hello()) {
+        //public void after(JoinPoint.StaticPart sjp) {
+            log("after");
+            assertEquals("execution(public void ataspectj.SingletonAspectBindingsTest2.hello())", thisJoinPointStaticPart.toLongString());
+        }
+
+        //TODO see String alias, see before advice name clash - all that works
+        // 1/ String is in java.lang.* - see SimpleScope.javalangPrefix array
+        // 2/ the advice is register thru its Bcel Method mirror
+        before(String s) : execution(* ataspectj.SingletonAspectBindingsTest2.hello(String)) && args(s) {
+        //public void before(String s, JoinPoint.StaticPart sjp) {
+            log("before-");
+            log(s);
+            assertEquals("hello", thisJoinPointStaticPart.getSignature().getName());
+        }
+
+    }
+
+//    public void testHe() throws Throwable {
+//        File f = new File("../tests/java5/ataspectj/ataspectj/SingletonAspectBindingsTest2.aj");
+//        FileReader r = new FileReader(f);
+//        int i = 0;
+//        for (i = 0; i < 3950; i++) {
+//            r.read();
+//        }
+//        for (;i < 4000; i++) {
+//            if (i == 3983) System.out.print("X");
+//            System.out.print((char)r.read());
+//        }
+//        System.out.print("|DONE");
+//        r.close();
+//    }
+}
index 0ea78b169d5698c8fb6fcfde3f118a28c5db71ce..bc1c4ad9c44dfd4c2c360e073ce792f6a2ef4264 100644 (file)
@@ -27,9 +27,6 @@ import org.aspectj.systemtest.xlint.XLintTests;
 
 /**
  * @author colyer
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
  */
 public class AllTests {
 
@@ -54,6 +51,7 @@ public class AllTests {
                suite.addTest(SUIDTests.suite());
                suite.addTest(XLintTests.suite());
                //$JUnit-END$
+
                return suite;
        }
 }
index b4df3a8c3026fa3c11b5c01b241b94798129b32d..eda07cb53819b70618ad665b35146229b21a14dc 100644 (file)
@@ -40,7 +40,13 @@ public class AtAjSyntaxTests extends XMLBasedAjcTestCase {
     }
 
     public void testSingletonAspectBindings() {
+        //Note AV: uncomment setReporting to get it in modules/tests folder
+        //org.aspectj.asm.AsmManager.setReporting("debug.txt",true,true,true,true);
         runTest("singletonAspectBindings");
+        // same stuff with AJ
+        //org.aspectj.asm.AsmManager.setReporting("debug-aj.txt",true,true,true,true);
+        runTest("singletonAspectBindings2");
+
     }
 
     public void testCflowTest() {
index fa16bc3fe9aba89d59df8599a3fe84cddfa28402..f4e209b07be6f022b164ed50b963b91837078789 100644 (file)
@@ -3,11 +3,11 @@
 
     <ajc-test dir="java5/ataspectj" title="SimpleBefore">
         <compile files="SimpleBefore.java" options="-1.5 -showWeaveInfo -XnoInline">
-            <message kind="weave" text="(SimpleBefore.java:23) advised by before advice from 'SimpleBefore$X' (SimpleBefore.java:1)"/>
+            <message kind="weave" text="(SimpleBefore.java:23) advised by before advice from 'SimpleBefore$X' (SimpleBefore.java:33)"/>
         </compile>
         <run class="SimpleBefore"/>
         <compile files="SimpleBefore.java" options="-1.5 -showWeaveInfo -XnoInline -Xdev:NoAtAspectJProcessing">
-            <message kind="weave" text="(SimpleBefore.java:23) advised by before advice from 'SimpleBefore$X' (SimpleBefore.java:1)"/>
+            <message kind="weave" text="(SimpleBefore.java:23) advised by before advice from 'SimpleBefore$X' (SimpleBefore.java:33)"/>
         </compile>
         <run class="SimpleBefore"/>
     </ajc-test>
     </ajc-test>
 
     <ajc-test dir="java5/ataspectj" title="singletonAspectBindings">
-        <compile files="ataspectj/SingletonAspectBindingsTest.java,ataspectj/TestHelper.java" options="-1.5 -XnoInline"/>
+        <compile files="ataspectj/SingletonAspectBindingsTest.java,ataspectj/TestHelper.java" options="-1.5 -emacssym -XnoInline"/>
         <run class="ataspectj.SingletonAspectBindingsTest"/>
-        <compile files="ataspectj/SingletonAspectBindingsTest.java,ataspectj/TestHelper.java" options="-1.5 -XnoInline -Xdev:NoAtAspectJProcessing"/>
+        <compile files="ataspectj/SingletonAspectBindingsTest.java,ataspectj/TestHelper.java" options="-1.5 -emacssym -XnoInline -Xdev:NoAtAspectJProcessing"/>
         <run class="ataspectj.SingletonAspectBindingsTest"/>
     </ajc-test>
 
+    <ajc-test dir="java5/ataspectj" title="singletonAspectBindings2">
+        <compile files="ataspectj/SingletonAspectBindingsTest2.aj,ataspectj/TestHelper.java" options="-1.5 -emacssym -XnoInline"/>
+        <run class="ataspectj.SingletonAspectBindingsTest2"/>
+    </ajc-test>
+
     <ajc-test dir="java5/ataspectj" title="CflowTest">
         <compile files="ataspectj/CflowTest.java,ataspectj/TestHelper.java" options="-1.5"/>
         <run class="ataspectj.CflowTest"/>
index 46f8ca401705830bec418847c85580adf0c763a0..90934da230b0b65f154d38057c64f867398d6633 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!-- see ../build/*.html for explanation -->
 <project name="weaver" default="test" basedir=".">
-    <import file="${basedir}/../build/build.xml"/>  
+    <import file="${basedir}/../build/build.xml"/>
 </project>
 
index 98ad849bbaafb0a50e26f0a3e1d4b22d6ac6425b..e45259a38edae80c9e0a4bd68126ab6002cb25b0 100644 (file)
@@ -32,6 +32,7 @@ import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.IMessageHandler;
 import org.aspectj.bridge.ISourceLocation;
 import org.aspectj.bridge.Message;
+import org.aspectj.bridge.SourceLocation;
 import org.aspectj.weaver.Advice;
 import org.aspectj.weaver.AdviceKind;
 import org.aspectj.weaver.AjAttribute;
@@ -121,10 +122,12 @@ public class AtAjAttributes {
         private String[] m_argumentNamesLazy = null;
 
         final Method method;
+        final BcelMethod bMethod;
 
-        public AjAttributeMethodStruct(Method method, ResolvedTypeX type, ISourceContext sourceContext, IMessageHandler messageHandler) {
+        public AjAttributeMethodStruct(Method method, BcelMethod bMethod, ResolvedTypeX type, ISourceContext sourceContext, IMessageHandler messageHandler) {
             super(type, sourceContext, messageHandler);
             this.method = method;
+            this.bMethod = bMethod;
         }
 
         public String[] getArgumentNames() {
@@ -230,7 +233,7 @@ public class AtAjAttributes {
             Method method = javaClass.getMethods()[i];
             if (method.getName().startsWith(NameMangler.PREFIX)) continue;  // already dealt with by ajc...
             //FIXME alex optimize, this method struct will gets recreated for advice extraction
-            AjAttributeMethodStruct mstruct = new AjAttributeMethodStruct(method, type, context, msgHandler);
+            AjAttributeMethodStruct mstruct = new AjAttributeMethodStruct(method, null, type, context, msgHandler);//FIXME AVASM
             Attribute[] mattributes = method.getAttributes();
 
             for (int j = 0; j < mattributes.length; j++) {
@@ -290,10 +293,10 @@ public class AtAjAttributes {
      * @param msgHandler
      * @return list of AjAttributes
      */
-    public static List readAj5MethodAttributes(Method method, ResolvedTypeX type, ResolvedPointcutDefinition preResolvedPointcut, ISourceContext context, IMessageHandler msgHandler) {
+    public static List readAj5MethodAttributes(Method method, BcelMethod bMethod, ResolvedTypeX type, ResolvedPointcutDefinition preResolvedPointcut, ISourceContext context, IMessageHandler msgHandler) {
         if (method.getName().startsWith(NameMangler.PREFIX)) return Collections.EMPTY_LIST;  // already dealt with by ajc...
 
-        AjAttributeMethodStruct struct = new AjAttributeMethodStruct(method, type, context, msgHandler);
+        AjAttributeMethodStruct struct = new AjAttributeMethodStruct(method, bMethod, type, context, msgHandler);
         Attribute[] attributes = method.getAttributes();
 
         // we remember if we found one @AJ annotation for minimal semantic error reporting
@@ -427,7 +430,7 @@ public class AtAjAttributes {
                 // could not parse it, ignore the aspect
                 return false;
             } else {
-                perClause.setLocation(struct.context, -1, -1);
+                perClause.setLocation(struct.context, struct.context.getOffset(), struct.context.getOffset()+1);//FIXME AVASM
                 struct.ajAttributes.add(new AjAttribute.Aspect(perClause));
                 return true;
             }
@@ -549,13 +552,14 @@ public class AtAjAttributes {
                 }
                 setIgnoreUnboundBindingNames(pc, bindings);
 
+                ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber());
                 struct.ajAttributes.add(
                         new AjAttribute.AdviceAttribute(
                                 AdviceKind.Before,
                                 pc,
                                 extraArgument,
-                                -1,
-                                -1,
+                                sl.getOffset(),
+                                sl.getOffset()+1,//FIXME AVASM
                                 struct.context
                         )
                 );
@@ -603,13 +607,14 @@ public class AtAjAttributes {
                 }
                 setIgnoreUnboundBindingNames(pc, bindings);
 
+                ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber());
                 struct.ajAttributes.add(
                         new AjAttribute.AdviceAttribute(
                                 AdviceKind.After,
                                 pc,
                                 extraArgument,
-                                -1,
-                                -1,
+                                sl.getOffset(),
+                                sl.getOffset()+1,//FIXME AVASM
                                 struct.context
                         )
                 );
@@ -687,13 +692,14 @@ public class AtAjAttributes {
             }
             setIgnoreUnboundBindingNames(pc, bindings);
 
+            ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber());
             struct.ajAttributes.add(
                     new AjAttribute.AdviceAttribute(
                             AdviceKind.AfterReturning,
                             pc,
                             extraArgument,
-                            -1,
-                            -1,
+                            sl.getOffset(),
+                            sl.getOffset()+1,//FIXME AVASM
                             struct.context
                     )
             );
@@ -770,13 +776,14 @@ public class AtAjAttributes {
             }
             setIgnoreUnboundBindingNames(pc, bindings);
 
+            ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber());
             struct.ajAttributes.add(
                     new AjAttribute.AdviceAttribute(
                             AdviceKind.AfterThrowing,
                             pc,
                             extraArgument,
-                            -1,
-                            -1,
+                            sl.getOffset(),
+                            sl.getOffset()+1,//FIXME AVASM
                             struct.context
                     )
             );
@@ -823,13 +830,14 @@ public class AtAjAttributes {
                 }
                 setIgnoreUnboundBindingNames(pc, bindings);
 
+                ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber());
                 struct.ajAttributes.add(
                         new AjAttribute.AdviceAttribute(
                                 AdviceKind.Around,
                                 pc,
                                 extraArgument,
-                                -1,
-                                -1,
+                                sl.getOffset(),
+                                sl.getOffset()+1,//FIXME AVASM
                                 struct.context
                         )
                 );
@@ -885,7 +893,7 @@ public class AtAjAttributes {
                 Pointcut pc = parsePointcut(pointcutExpr.getValue().stringifyValue(), struct, true);
                 if (pc == null) return;//parse error
                 // do not resolve binding now but lazily
-                pc.setLocation(struct.context, -1, -1);
+                pc.setLocation(struct.context, -1, -1);//FIXME AVASM !! bMethod is null here..
                 struct.ajAttributes.add(
                         new AjAttribute.PointcutDeclarationAttribute(
                                 new LazyResolvedPointcutDefinition(
@@ -1342,21 +1350,21 @@ public class AtAjAttributes {
      * Parse the given pointcut, return null on failure and issue an error
      *
      * @param pointcutString
-     * @param location
+     * @param struct
      * @param allowIf
      * @return
      */
-    private static Pointcut parsePointcut(String pointcutString, AjAttributeStruct location, boolean allowIf) {
+    private static Pointcut parsePointcut(String pointcutString, AjAttributeStruct struct, boolean allowIf) {
         try {
-            Pointcut pointcut = new PatternParser(pointcutString, location.context).parsePointcut();
+            Pointcut pointcut = new PatternParser(pointcutString, struct.context).parsePointcut();
             if (!allowIf && pointcutString.indexOf("if()") >= 0 && hasIf(pointcut)) {
-                reportError("if() pointcut is not allowed at this pointcut location '" + pointcutString +"'", location);
+                reportError("if() pointcut is not allowed at this pointcut location '" + pointcutString +"'", struct);
                 return null;
             }
-            pointcut.setLocation(location.context, -1, -1);//FIXME -1,-1 is not good enough
+            pointcut.setLocation(struct.context, -1, -1);//FIXME -1,-1 is not good enough
             return pointcut;
         } catch (ParserException e) {
-            reportError("Invalid pointcut '" + pointcutString + "': " + e.toString(), location);
+            reportError("Invalid pointcut '" + pointcutString + "': " + e.toString(), struct);
             return null;
         }
     }
index ca4dfaaa41ae0f0f08ab478b2a0a80fba35f0d7a..e4dff0586118fe2129a098f67b43eae941b04f3b 100644 (file)
@@ -100,7 +100,7 @@ final class BcelMethod extends ResolvedMember {
                associatedShadowMunger = null;
         List as = BcelAttributes.readAjAttributes(getDeclaringType().getClassName(),method.getAttributes(), getSourceContext(world),world.getMessageHandler());
                processAttributes(world, as);
-               as = AtAjAttributes.readAj5MethodAttributes(method, world.resolve(getDeclaringType()), preResolvedPointcut,getSourceContext(world), world.getMessageHandler());
+               as = AtAjAttributes.readAj5MethodAttributes(method, this, world.resolve(getDeclaringType()), preResolvedPointcut,getSourceContext(world), world.getMessageHandler());
                processAttributes(world,as);
        }
 
index ea748b953fb37db48ec703c38587bc3880c43dde..2bd26e0668a1bc5e643e38dbe69ba8851a0a9876 100644 (file)
@@ -87,7 +87,17 @@ public class BcelSourceContext implements ISourceContext {
        }
        
        public ISourceLocation makeSourceLocation(int line) {
-               return new SourceLocation(getSourceFile(), line);
+        if (line < 0) line = 0;
+               SourceLocation sl = new SourceLocation(getSourceFile(), line);
+        if (lineBreaks != null) {
+            int likelyOffset = 0;
+            if (line > 0 && line < lineBreaks.length) {
+                //1st char of given line is next char after previous end of line
+                likelyOffset = lineBreaks[line-1] + 1;
+            }
+            sl.setOffset(likelyOffset);
+        }
+        return sl;
        }
 
        public void addAttributeInfo(SourceContextAttribute sourceContextAttribute) {
index 6b963df1a81099753e2cd273c9586dbd0374798f..40e992814b4f68c983822f6a0050f04c18139296 100644 (file)
@@ -68,14 +68,16 @@ public class PerFromSuper extends PerClause {
                        inAspect.getWorld().getMessageHandler().handleMessage(
                          MessageUtil.error(WeaverMessages.format(WeaverMessages.MISSING_PER_CLAUSE,inAspect.getSuperclass()), getSourceLocation())
                        );
-               }
-               if (p.getKind() != kind) {
-                       inAspect.getWorld().getMessageHandler().handleMessage(
-                         MessageUtil.error(WeaverMessages.format(WeaverMessages.WRONG_PER_CLAUSE,kind,p.getKind()),
-                                                               getSourceLocation())
-                       );
-               }
-               return p.concretize(inAspect);
+            return new PerSingleton().concretize(inAspect);// AV: fallback on something else NPE in AJDT
+               } else {
+            if (p.getKind() != kind) {
+                inAspect.getWorld().getMessageHandler().handleMessage(
+                  MessageUtil.error(WeaverMessages.format(WeaverMessages.WRONG_PER_CLAUSE,kind,p.getKind()),
+                                    getSourceLocation())
+                );
+            }
+            return p.concretize(inAspect);
+        }
        }
        
        
index 9bedb142fdd11ed43b62e21caaa5e72d6d68d7f3..660bc2ed1d2c3860f8f42476e32c55b1dee0e12d 100644 (file)
@@ -200,7 +200,8 @@ public class WeavingAdaptor {
                 ||*/ name.startsWith("org.aspectj.")
                 || name.startsWith("java.")
                 || name.startsWith("javax."))
-                || name.startsWith("$Proxy"));//JDK proxies
+                || name.startsWith("$Proxy")//JDK proxies
+                || name.startsWith("sun.reflect."));//JDK reflect
        }
 
     /**