]> source.dussan.org Git - aspectj.git/commitdiff
fix for Bugzilla Bug 37020
authoracolyer <acolyer>
Thu, 19 Aug 2004 12:29:04 +0000 (12:29 +0000)
committeracolyer <acolyer>
Thu, 19 Aug 2004 12:29:04 +0000 (12:29 +0000)
  wrong line for method execution join point

50 files changed:
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjConstructorDeclaration.java [new file with mode: 0644]
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjMethodDeclaration.java [new file with mode: 0644]
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IfMethodDeclaration.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java
org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar
org.aspectj.ajdt.core/testdata/OutjarTest/child.jar
org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/PerformanceTestCase.java
org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip
org.eclipse.jdt.core/jdtcore-for-aspectj.jar
testing-drivers/testdata/incremental/harness/expClasses/exp/Main.class
testing-drivers/testdata/incremental/harness/suite.xml
testing-drivers/testsrc/org/aspectj/testing/drivers/HarnessSelectionTest.java
tests/bugs/StringToString/helloworld.jar
tests/bugs/serialVersionUID/injar.jar
tests/design/sourceLines/TestSourceLines.java [new file with mode: 0644]
tests/new/DeclareWarningMain.java
tests/new/declare/DeclareWarning.java
tests/new/options11/aspectlib1.jar
tests/new/options11/aspectlib2.jar
tests/new/options11/injar.jar
tests/src/org/aspectj/systemtest/ajc10x/ajc10x-tests.xml
tests/src/org/aspectj/systemtest/ajc11/ajc11-tests.xml
tests/src/org/aspectj/systemtest/incremental/IncrementalTests.java
tests/src/org/aspectj/systemtest/incremental/incremental-junit-tests.xml
tests/src/org/aspectj/systemtest/incremental/incremental-tests.xml
tests/src/org/aspectj/systemtest/pre10x/pre10x-tests.xml
weaver/src/org/aspectj/weaver/AjAttribute.java
weaver/src/org/aspectj/weaver/bcel/BcelMethod.java
weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
weaver/testdata/dummyAspect.jar
weaver/testdata/ltw-acaspects.jar
weaver/testdata/ltw-aspects.jar
weaver/testdata/ltw-classes.jar
weaver/testdata/ltw-deaspects.jar
weaver/testdata/ltw-dwaspects.jar
weaver/testdata/ltw-itdaspects.jar
weaver/testdata/ltw-peraspects.jar
weaver/testdata/ltw-woven.jar
weaver/testdata/megatrace.jar
weaver/testdata/megatrace0easy.jar
weaver/testdata/megatrace0hard.jar
weaver/testdata/megatraceNoweave.jar
weaver/testdata/tracing.jar

index 9d10f63815f057892f951a23d89019d1863216fe..31a10f41214bbc705a7e2f16c3772a04115ffea1 100644 (file)
@@ -29,7 +29,6 @@ import org.aspectj.weaver.TypeX;
 import org.eclipse.jdt.internal.compiler.ClassFile;
 import org.eclipse.jdt.internal.compiler.CompilationResult;
 import org.eclipse.jdt.internal.compiler.ast.Argument;
-import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
 import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
 import org.eclipse.jdt.internal.compiler.ast.TypeReference;
 import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
@@ -47,7 +46,7 @@ import org.eclipse.jdt.core.compiler.CharOperation;
  * 
  * @author Jim Hugunin
  */
-public class AdviceDeclaration extends MethodDeclaration {
+public class AdviceDeclaration extends AjMethodDeclaration {
        public PointcutDesignator pointcutDesignator;
        int baseArgumentCount;
        
@@ -76,6 +75,7 @@ public class AdviceDeclaration extends MethodDeclaration {
        protected int generateInfoAttributes(ClassFile classFile) {
                List l = new ArrayList(1);
                l.add(new EclipseAttributeAdapter(makeAttribute()));
+               addDeclarationStartLineAttribute(l,classFile);
 
                return classFile.generateMethodInfoAttribute(binding, l);
        }
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjConstructorDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjConstructorDeclaration.java
new file mode 100644 (file)
index 0000000..30b8040
--- /dev/null
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * 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:
+ *     IBM Corporation 
+ *******************************************************************************/
+package org.aspectj.ajdt.internal.compiler.ast;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.aspectj.weaver.AjAttribute;
+import org.eclipse.jdt.internal.compiler.ClassFile;
+import org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
+
+/**
+ * Root class for all ConstructorDeclaration objects created by the parser.
+ * Enables us to generate extra attributes in the method_info attribute
+ * to support aspectj.
+ */
+public class AjConstructorDeclaration extends ConstructorDeclaration {
+
+       /**
+        * @param compilationResult
+        */
+       public AjConstructorDeclaration(CompilationResult compilationResult) {
+               super(compilationResult);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration#generateInfoAttributes(org.eclipse.jdt.internal.compiler.ClassFile)
+        */
+       protected int generateInfoAttributes(ClassFile classFile) {
+               // add extra attributes into list then call 2-arg version of generateInfoAttributes...
+               List extras = new ArrayList();
+               addDeclarationStartLineAttribute(extras,classFile);
+               return classFile.generateMethodInfoAttribute(binding,extras);
+       }
+       
+       protected void addDeclarationStartLineAttribute(List extraAttributeList, ClassFile classFile) {
+               if (!classFile.codeStream.generateLineNumberAttributes) return;
+               
+               int[] separators = compilationResult().lineSeparatorPositions;
+               int declarationStartLine = 1;
+               for (int i = 0; i < separators.length; i++) {
+                       if (sourceStart < separators[i]) break;
+                       declarationStartLine++;
+               }
+               
+               extraAttributeList.add(
+                               new EclipseAttributeAdapter(new AjAttribute.MethodDeclarationLineNumberAttribute(declarationStartLine)));
+       }
+}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjMethodDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjMethodDeclaration.java
new file mode 100644 (file)
index 0000000..a086269
--- /dev/null
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * 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:
+ *     IBM Corporation 
+ *******************************************************************************/
+package org.aspectj.ajdt.internal.compiler.ast;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.aspectj.weaver.AjAttribute;
+import org.eclipse.jdt.internal.compiler.ClassFile;
+import org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
+
+/**
+ * Root class for all MethodDeclaration objects created by the parser.
+ * Enables us to generate extra attributes in the method_info attribute
+ * to support aspectj.
+ */
+public class AjMethodDeclaration extends MethodDeclaration {
+
+       /**
+        * @param compilationResult
+        */
+       public AjMethodDeclaration(CompilationResult compilationResult) {
+               super(compilationResult);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration#generateInfoAttributes(org.eclipse.jdt.internal.compiler.ClassFile)
+        */
+       protected int generateInfoAttributes(ClassFile classFile) {
+               // add extra attributes into list then call 2-arg version of generateInfoAttributes...
+               List extras = new ArrayList();
+               addDeclarationStartLineAttribute(extras,classFile);
+               return classFile.generateMethodInfoAttribute(binding,extras);
+       }
+       
+       protected void addDeclarationStartLineAttribute(List extraAttributeList, ClassFile classFile) {
+               if (!classFile.codeStream.generateLineNumberAttributes) return;
+               
+               int[] separators = compilationResult().lineSeparatorPositions;
+               int declarationStartLine = 1;
+               for (int i = 0; i < separators.length; i++) {
+                       if (sourceStart < separators[i]) break;
+                       declarationStartLine++;
+               }
+               
+               extraAttributeList.add(
+                               new EclipseAttributeAdapter(new AjAttribute.MethodDeclarationLineNumberAttribute(declarationStartLine)));
+       }
+}
index b1a57c116afaaae3453bc026183539548cc6239c..76bfc05a4bb2f07f2dbb60ff4a4c94c2f3dd81a1 100644 (file)
@@ -25,7 +25,7 @@ import org.eclipse.jdt.internal.compiler.ast.*;
 import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
 import org.eclipse.jdt.internal.compiler.parser.Parser;
 
-public class DeclareDeclaration extends MethodDeclaration {
+public class DeclareDeclaration extends AjMethodDeclaration {
        public Declare declareDecl;
 
        /**
index 5103a8a7820360341463d23feee1d0304315afee..e69767ff59fa43d8741d2be94f5751de8f2ce7e0 100644 (file)
@@ -21,11 +21,10 @@ import org.aspectj.weaver.patterns.IfPointcut;
 import org.eclipse.jdt.internal.compiler.ClassFile;
 import org.eclipse.jdt.internal.compiler.CompilationResult;
 import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
 //import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
 import org.eclipse.jdt.internal.compiler.parser.Parser;
 
-public class IfMethodDeclaration extends MethodDeclaration {
+public class IfMethodDeclaration extends AjMethodDeclaration {
        IfPointcut ifPointcut;
 
        public IfMethodDeclaration(CompilationResult compilationResult, IfPointcut ifPointcut) {
index 6efe2dd755743717d1ef0b87925b2d624d2619e5..26007511bcb508761408f5f52f485aebe4a6a14e 100644 (file)
@@ -24,7 +24,6 @@ import org.aspectj.ajdt.internal.core.builder.EclipseSourceContext;
 import org.aspectj.weaver.*;
 import org.eclipse.jdt.internal.compiler.ClassFile;
 import org.eclipse.jdt.internal.compiler.CompilationResult;
-import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
 import org.eclipse.jdt.internal.compiler.ast.TypeReference;
 import org.eclipse.jdt.internal.compiler.lookup.*;
 import org.eclipse.jdt.core.compiler.CharOperation;
@@ -34,7 +33,7 @@ import org.eclipse.jdt.core.compiler.CharOperation;
  *
  * @author Jim Hugunin
  */
-public abstract class InterTypeDeclaration extends MethodDeclaration {
+public abstract class InterTypeDeclaration extends AjMethodDeclaration {
        public TypeReference onType;
        protected ReferenceBinding onTypeBinding;
 
@@ -134,6 +133,7 @@ public abstract class InterTypeDeclaration extends MethodDeclaration {
                } else {
                        l = new ArrayList(0);
                }
+               addDeclarationStartLineAttribute(l,classFile);
 
                return classFile.generateMethodInfoAttribute(binding, l);
        }
index b0595257e0600c5a2d09ad88b77e5d5cd6c1ae21..e1c6673b76330dfc736f218f8aedf5d8fe7f158f 100644 (file)
@@ -26,7 +26,6 @@ import org.eclipse.jdt.internal.compiler.ClassFile;
 import org.eclipse.jdt.internal.compiler.CompilationResult;
 import org.eclipse.jdt.internal.compiler.ast.Argument;
 import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
 import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
 import org.eclipse.jdt.internal.compiler.ast.TypeReference;
 import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
@@ -41,7 +40,7 @@ import org.eclipse.jdt.core.compiler.CharOperation;
  * 
  * @author Jim Hugunin
  */
-public class PointcutDeclaration extends MethodDeclaration {
+public class PointcutDeclaration extends AjMethodDeclaration {
        public static final char[] mangledPrefix = "ajc$pointcut$".toCharArray();
        
        public PointcutDesignator pointcutDesignator;
index 4c79c9a5a9b19b703c83e48bf5ba4c3d83c60e57..9879e5a55d304209804c4dec67d20de559dfc8e2 100644 (file)
@@ -13,6 +13,8 @@
 package org.aspectj.ajdt.internal.compiler.parser;
 
 import org.aspectj.ajdt.internal.compiler.ast.AdviceDeclaration;
+import org.aspectj.ajdt.internal.compiler.ast.AjConstructorDeclaration;
+import org.aspectj.ajdt.internal.compiler.ast.AjMethodDeclaration;
 import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration;
 import org.aspectj.ajdt.internal.compiler.ast.DeclareDeclaration;
 import org.aspectj.ajdt.internal.compiler.ast.IfPseudoToken;
@@ -31,6 +33,7 @@ import org.aspectj.weaver.patterns.Declare;
 import org.eclipse.jdt.internal.compiler.CompilationResult;
 import org.eclipse.jdt.internal.compiler.ast.ASTNode;
 import org.eclipse.jdt.internal.compiler.ast.Argument;
+import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
 import org.eclipse.jdt.internal.compiler.ast.Expression;
 import org.eclipse.jdt.internal.compiler.ast.MessageSend;
 import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
@@ -46,7 +49,21 @@ import org.eclipse.jdt.internal.compiler.parser.Parser.IDeclarationFactory;
  * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
  */
 public class DeclarationFactory implements IDeclarationFactory {
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jdt.internal.compiler.parser.Parser.IDeclarationFactory#createMethodDeclaration(org.eclipse.jdt.internal.compiler.CompilationResult)
+        */
+       public MethodDeclaration createMethodDeclaration(CompilationResult result) {
+               return new AjMethodDeclaration(result);
+       }
+               
+       /* (non-Javadoc)
+        * @see org.eclipse.jdt.internal.compiler.parser.Parser.IDeclarationFactory#createConstructorDeclaration(org.eclipse.jdt.internal.compiler.CompilationResult)
+        */
+       public ConstructorDeclaration createConstructorDeclaration(CompilationResult result) {
+               return new AjConstructorDeclaration(result);
+       }
+               
        /* (non-Javadoc)
         * @see org.eclipse.jdt.internal.compiler.parser.Parser.IDeclarationFactory#createProceed(org.eclipse.jdt.internal.compiler.ast.MessageSend)
         */
index 37151cc0fafb42faa6ad95b70ffdcedb938a64be..d8aba690e534169d87fff44caa1712dee9da701c 100644 (file)
Binary files a/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar and b/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar differ
index df45a1dd69a3f7f3b58ba435f025ad40db2f9ce5..7f06e1b09af050e20885d64670ba58c17d605760 100644 (file)
Binary files a/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar and b/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar differ
index eba9b328af823d66d8cdcb3d30d7587762f3ce14..66a5e9ee9dfcd7dc5eee9f92968a3ffa9613c5c9 100644 (file)
Binary files a/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar and b/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar differ
index cd0ec9ddd46f9923968cfaa86f40f10ef6182cb6..a1a0e4c831804958f2ca551a5f6bf84190e3fe88 100644 (file)
@@ -72,7 +72,7 @@ public class BasicCommandTestCase extends CommandTestCase {
                checkCompile("src1/ThisAndModifiers.java", NO_ERRORS);
        }
        public void testDeclares() {
-               checkCompile("src1/Declares.java", new int[] {3});
+               checkCompile("src1/Declares.java", new int[] {2});
        }       
        
        public void testDeclareWarning() {
index 527fe93049ece0e873e480d12616d4522214988f..433478de8a84fdae9a4fe6f47e61daaf49a73dec 100644 (file)
@@ -36,7 +36,7 @@ public class PerformanceTestCase extends CommandTestCase {
        }
        
        public void testLazyTjp() throws IOException {
-               checkCompile("src1/LazyTjp.aj", new String[] {"-XlazyTjp","-Xlint:error"}, new int[] {97});
+               checkCompile("src1/LazyTjp.aj", new String[] {"-XlazyTjp","-Xlint:error"}, new int[] {96});
                TestUtil.runMain("out", "LazyTjp");
        }
 }
index f5642bb4cad1c54a13e055b1550aca9a687f7c2e..bfd62984c7ff15dce32a53bb7685fd3561a71e7e 100644 (file)
Binary files a/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip and b/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip differ
index f19ce9148e423915ac8abfb5ae2ce5d437b4fd10..02f5419eca8b24228ca941f15d191071ab505b55 100644 (file)
Binary files a/org.eclipse.jdt.core/jdtcore-for-aspectj.jar and b/org.eclipse.jdt.core/jdtcore-for-aspectj.jar differ
index fba840b699b3c91879ad0a1ea60d5bbf66ce4d6d..fd25eb1dca47803a7dab21f05a62564aa54d3904 100644 (file)
Binary files a/testing-drivers/testdata/incremental/harness/expClasses/exp/Main.class and b/testing-drivers/testdata/incremental/harness/expClasses/exp/Main.class differ
index 3a19813e5832b4ed484c3cd820f771ff74d8e4dd..1298654991e77cc475c9344225de14632edb0fd1 100644 (file)
         <run class="main.Main"/>
     </ajc-test>
 
+       <!-- this test cannot work with new AjAttribute.MethodDeclarationLineNumberAttribute attribute
+            since the attribute will be generated for the main method, and has a different reference
+            on each serialization
     <ajc-test dir="expClasses" title="expected class tree" keywords="incremental-test" >
         <compile files="Main.java">
             <dir-changes expDir="exp"/>
         </compile>
         <run class="Main"/>
     </ajc-test>
-
+    -->
 
 </suite>
index 94cc999853c8f22fdc8bb3fa6b67f65c60f20fe8..489723f8e9594b0894848a1c215dd22ab9f736de 100644 (file)
@@ -99,7 +99,7 @@ public class HarnessSelectionTest extends TestCase {
         String[] options = new String[] 
             { "!verbose", "!eclipse",
             };
-        Exp exp = new Exp(7, 7, 0, 7, 0, 0, 0);
+        Exp exp = new Exp(6, 6, 0, 6, 0, 0, 0);
         checkSelection(INCREMENTAL, options, "INFIX IGNORED", exp);
     }
     
index 185b8eb2b26bdf74dfc3065aed357c3583f51d4b..447374ddc9ac152195611d97372f483a7dd717b0 100644 (file)
Binary files a/tests/bugs/StringToString/helloworld.jar and b/tests/bugs/StringToString/helloworld.jar differ
index 7a8996bb2c1475b369cec3c613f4dc06076d4cc3..a5dbf9798facc7ab04dc86c281125bdffcdf1455 100644 (file)
Binary files a/tests/bugs/serialVersionUID/injar.jar and b/tests/bugs/serialVersionUID/injar.jar differ
diff --git a/tests/design/sourceLines/TestSourceLines.java b/tests/design/sourceLines/TestSourceLines.java
new file mode 100644 (file)
index 0000000..8a97048
--- /dev/null
@@ -0,0 +1,52 @@
+public class TestSourceLines {  // L1
+       
+       private int i = 0;          // L3
+       
+       private static int J = 1;   // L5
+       private static int K;       // L6
+       
+       static {                    // L8
+               System.out.println("K = 2");
+       }
+       
+       public TestSourceLines() {  // L12
+               i = 3;
+       }
+       
+       public TestSourceLines(int i) { // L16
+               this.i = i;
+       }
+       
+       public void foo() {         // L20
+               System.out.println(i);
+       }
+       
+       private void bar() { System.out.println(i); }  // L24
+       
+       protected               // L26
+       void
+       goo()           // L28
+       {
+               System.out.println(i);
+       }
+       
+}
+
+class NoStaticInitBlock {  // L35
+       
+}
+
+aspect CheckLineNumbers {  // L39
+       
+       declare warning : execution(* TestSourceLines.*(..)) : "method execution";
+       declare warning : execution(TestSourceLines.new(..)) : "cons execution";
+       declare warning : staticinitialization(*) : "static init";
+       declare warning : initialization(*.new(..)) : "init";
+       declare warning : preinitialization(*.new(..)) : "pre-init";
+       
+       before() : execution(* TestSourceLines.*(..)) {  // L47
+               System.out.println("boo");
+       }
+       
+       declare warning : adviceexecution() : "advice";
+}
\ No newline at end of file
index 243a4668b055d0677d38decb3ec8f2e51be334df..add8ff01e36dc303e10cb9816e8678a54fbc0812 100644 (file)
@@ -1,7 +1,7 @@
 import org.aspectj.testing.*;
 
 public class DeclareWarningMain {
-    public static void main (String[] args) {  // DW 5 main
+    public static void main (String[] args) {  // DW 4 main
         Tester.checkAllEvents();
     } 
     static {
@@ -10,7 +10,7 @@ public class DeclareWarningMain {
 }
 
 aspect Warnings {
-    declare warning : execution(static void main(String[])) : "main"; // for DW 5 main
+    declare warning : execution(static void main(String[])) : "main"; // for DW 4 main
 
     // just to show that pointcut is valid - works if warning removed
     before() : execution(static void main(String[])) {
index 1ea56b2b842d9492a6b8c569f75fb426bf4fe9cc..9f7efccf53469304fafa19f4c3de33c89a8e613c 100644 (file)
@@ -69,8 +69,8 @@ aspect A {
     declare warning: adviceexecution() && within(A)
             : "adviceExecution() && within(A)";
 
-    before() : initialization(DeclareWarning.new(..)) {
-        // CW 74
+    before() : initialization(DeclareWarning.new(..)) { // CW 72
+       
         long l = System.currentTimeMillis();
         if (0l == l) {
             throw new Error("never thrown");
index fbe0d3610cf6202c7067e78a2b9e9613fbed5c62..722c97ff3246854f40bdf62c4a891e20e73a519e 100644 (file)
Binary files a/tests/new/options11/aspectlib1.jar and b/tests/new/options11/aspectlib1.jar differ
index 05e82c363e15a5131d19d4817d158a0d7831bcff..22647696db2146b2bfd82c5d425f54ec7414fcc9 100644 (file)
Binary files a/tests/new/options11/aspectlib2.jar and b/tests/new/options11/aspectlib2.jar differ
index d4ac54e79d46d3488495a1273e120cba6c883b44..7acf3a083769d63a161c55926067c61baea1f653 100644 (file)
Binary files a/tests/new/options11/injar.jar and b/tests/new/options11/injar.jar differ
index 9e04c610e003d4a083d174cee56b000affc5316c..0c085c7f0be88e912ebd4715aa9fd6f3be6e8d21 100644 (file)
     <ajc-test dir="new" title="simple declare warning (NPE)"
       keywords="from-resolved_105">
         <compile files="DeclareWarningMain.java">
-            <message kind="warning" line="5"/>
+            <message kind="warning" line="4"/>
         </compile>
         <run class="DeclareWarningMain"/>
     </ajc-test>
index 95fe34a0b32fa7ca6bfce7445be636b1578d37ee..37bab33718035e7749330cf46261a5f3bc75589a 100644 (file)
     <ajc-test dir="new" pr="838"
       title="checking around join point for advice return type - numeric">
         <compile files="AroundNumericCastCE.java">
-            <message kind="error" line="12"/>
+            <message kind="error" line="11"/>
             <message kind="error" line="17"/>
         </compile>
     </ajc-test>
             <message kind="warning" line="33" text="handler(OutOfMemoryError) &amp;&amp; within(DeclareWarning)"/>
             <message kind="warning" line="36" text="handler(Error)"/>
             <message kind="warning" line="39" text="handler(RuntimeException) &amp;&amp; withincode(DeclareWarning.new())"/>
-            <message kind="warning" line="74" text="adviceExecution() &amp;&amp; within(A)"/>
+            <message kind="warning" line="72" text="adviceExecution() &amp;&amp; within(A)"/>
         </compile>
     </ajc-test>
     
index 0cd0d6db375f29a3aba546fe11a74055035634e5..aa34783b92f8a7ce24874a85610792950dd59ab0 100644 (file)
@@ -132,7 +132,7 @@ public class IncrementalTests extends org.aspectj.testing.XMLBasedAjcTestCase {
   public void test012() throws Exception {
     runTest("incremental with aspect-driven full rebuild");
     nextIncrement(false);
-    MessageSpec messageSpec = new MessageSpec(newMessageList(new Message(4,"Main.java",null,null)),null);
+    MessageSpec messageSpec = new MessageSpec(newMessageList(new Message(3,"Main.java",null,null)),null);
     copyFileAndDoIncrementalBuild("changes/Aspect.20.java","src/Aspect.java",messageSpec);
     run("Main");
   }
index d24c5428bb4273ba32ff8f0b4bbf3719dce879b4..b3fb62d8b083f33d0b5d250542487b5381fa3f9b 100644 (file)
                </compile>
         <!--
         <inc-compile tag="20">
-               <message kind="warning" line="4" file="Main.java"/>
+               <message kind="warning" line="3" file="Main.java"/>
         </inc-compile>
         <run class="Main"/>
         -->
index 24b7a234a0c9ce260de167c9d255348f16cc7085..532b22398b7931d3781550d69e30a75b1112281d 100644 (file)
                <message kind="error" line="3" file="Aspect.java"/>
                </compile>
         <inc-compile tag="20">
-               <message kind="warning" line="4" file="Main.java"/>
+               <message kind="warning" line="3" file="Main.java"/>
                </inc-compile>
         <run class="Main"/>
     </ajc-test>
index 90a1de463dca4cd5fd8dde77e9d8ad8fe80864db..d96bc3e4b59539fc1f83df6718070606b27e7507 100644 (file)
       title="decent errors for around return type not matching target point"
       keywords="from-errors">
         <compile files="AroundReturnType.java">
-            <message kind="error" line="3"/>
+            <message kind="error" line="2"/>
+            <message kind="error" line="6"/>
             <message kind="error" line="7"/>
             <message kind="error" line="16"/>
             <message kind="error" line="21"/>
index 417fa7ce56a6300ae5965ab0e135183fb0002a13..b194e19aff33747041c2ea9d804d80dfae22937d 100644 (file)
@@ -87,6 +87,8 @@ public abstract class AjAttribute {
                        DataInputStream s = new DataInputStream(new ByteArrayInputStream(bytes));
                        if (name.equals(Aspect.AttributeName)) {
                                return new Aspect(PerClause.readPerClause(s, context));
+                       } else if (name.equals(MethodDeclarationLineNumberAttribute.AttributeName)) {
+                          return MethodDeclarationLineNumberAttribute.read(s);
                        } else if (name.equals(WeaverState.AttributeName)) {
                                return new WeaverState(WeaverStateInfo.read(s, context));
                        } else if (name.equals(AdviceAttribute.AttributeName)) {
@@ -206,6 +208,32 @@ public abstract class AjAttribute {
                }
        }
 
+       public static class MethodDeclarationLineNumberAttribute extends AjAttribute {
+
+               public static final String AttributeName = "org.aspectj.weaver.MethodDeclarationLineNumber";
+               
+               public String getNameString() {
+                       return AttributeName;
+               }
+               
+               private int lineNumber;
+               
+               public MethodDeclarationLineNumberAttribute(int line) {
+                       this.lineNumber = line;
+               }
+               
+               public int getLineNumber() { return lineNumber; }
+               
+               public void write(DataOutputStream s) throws IOException {
+                       s.writeInt(lineNumber);
+               }
+               
+               public static MethodDeclarationLineNumberAttribute read(DataInputStream s) throws IOException {
+                       return new MethodDeclarationLineNumberAttribute(s.readInt());
+               }
+
+       }
+       
        public static class PointcutDeclarationAttribute extends AjAttribute {
                public static final String AttributeName = "org.aspectj.weaver.PointcutDeclaration";
                
index b55184285906254198ea47a04c80cd3aec80d9b1..202982d769ba921beddfbb16094525f3ba483e15 100644 (file)
@@ -34,6 +34,7 @@ final class BcelMethod extends ResolvedMember {
        private boolean isAjSynthetic;
        private ShadowMunger associatedShadowMunger;
        private AjAttribute.EffectiveSignatureAttribute effectiveSignature;
+       private AjAttribute.MethodDeclarationLineNumberAttribute declarationLineNumber;
 
        BcelMethod(BcelObjectType declaringType, Method method) {
                super(
@@ -84,7 +85,9 @@ final class BcelMethod extends ResolvedMember {
                //System.out.println("unpack: " + this + ", " + as);
                for (Iterator iter = as.iterator(); iter.hasNext();) {
                        AjAttribute a = (AjAttribute) iter.next();
-                       if (a instanceof AjAttribute.AdviceAttribute) {
+                       if (a instanceof AjAttribute.MethodDeclarationLineNumberAttribute) {
+                               declarationLineNumber = (AjAttribute.MethodDeclarationLineNumberAttribute)a;
+                       } else if (a instanceof AjAttribute.AdviceAttribute) {
                                associatedShadowMunger = ((AjAttribute.AdviceAttribute)a).reify(this, world);
                                return;
                        } else if (a instanceof AjAttribute.AjSynthetic) {
@@ -113,6 +116,18 @@ final class BcelMethod extends ResolvedMember {
                return effectiveSignature;
        }
        
+       public boolean hasDeclarationLineNumberInfo() {
+               return declarationLineNumber != null;
+       }
+       
+       public int getDeclarationLineNumber() {
+               if (declarationLineNumber != null) {
+                       return declarationLineNumber.getLineNumber();
+               } else {
+                       return -1;
+               }
+       }
+       
        public Kind getKind() {
                if (associatedShadowMunger != null) {
                        return ADVICE;
index 9e6fd0c29d73d09b83ba92c10bfa91b66e4e7b94..d521ed52d85bc552c69eb79bf498d164639bfa42 100644 (file)
@@ -303,6 +303,21 @@ public class BcelShadow extends Shadow {
        }
        
     public int getSourceLine() {
+       // if the kind of join point for which we are a shadow represents
+       // a method or constructor execution, then the best source line is
+       // the one from the enclosingMethod declarationLineNumber if available.
+       Kind kind = getKind();
+       if ( (kind == MethodExecution)  ||
+                (kind == ConstructorExecution) ||
+                        (kind == AdviceExecution) || 
+                        (kind == StaticInitialization) ||
+                        (kind == PreInitialization) ||
+                        (kind == Initialization)) {
+               if (getEnclosingMethod().hasDeclaredLineNumberInfo()) {
+                       return getEnclosingMethod().getDeclarationLineNumber();
+               }
+       }
+       
        if (range == null) {
                if (getEnclosingMethod().hasBody()) {
                        return Utility.getSourceLine(getEnclosingMethod().getBody().getStart());
index f90fe103b50f10ecb7f0ebabcacd13acd7a8940f..47076f35100ee7ab8ce55f8d4addb139994dd87c 100644 (file)
@@ -161,6 +161,18 @@ public final class LazyMethodGen {
                this.name = m.getName();
     }
     
+    public boolean hasDeclaredLineNumberInfo() {
+       return (memberView != null && memberView.hasDeclarationLineNumberInfo());
+    }
+    
+    public int getDeclarationLineNumber() {
+       if (hasDeclaredLineNumberInfo()) {
+               return memberView.getDeclarationLineNumber();
+       } else {
+               return -1;
+       }
+    }
+    
     private void initialize() {
        if (returnType != null) return;
        
index baf5a2a253985e2fb6f3a1769f44a41584c29359..b61752c660ed6af5c93a3cedd480c8b6cd21cc96 100644 (file)
Binary files a/weaver/testdata/dummyAspect.jar and b/weaver/testdata/dummyAspect.jar differ
index 3fe72d9d7bcb1d7dcae8662821a6d6aa3229dc33..0ef9dc1ab7c79729077d64947b2466746a406b7c 100644 (file)
Binary files a/weaver/testdata/ltw-acaspects.jar and b/weaver/testdata/ltw-acaspects.jar differ
index 2f232c71ff3eb86f552e260330fb8e9747527e12..ae188557a550339d54954d350d245ade2a642564 100644 (file)
Binary files a/weaver/testdata/ltw-aspects.jar and b/weaver/testdata/ltw-aspects.jar differ
index 64aa2aee4f4c0a83ea06599b888037840392b9ef..ec7b131b8540497ba65603544613c8ef5238f162 100644 (file)
Binary files a/weaver/testdata/ltw-classes.jar and b/weaver/testdata/ltw-classes.jar differ
index 982c609ad5c3220ceaa013661d3c39e2433fa354..261df4f6be7264ef5721c99c7820a198d26e8e5c 100644 (file)
Binary files a/weaver/testdata/ltw-deaspects.jar and b/weaver/testdata/ltw-deaspects.jar differ
index d3cbc6728d2964a495630b3de9a73e874ed1b222..e32be29dafb63026cb4c5498a2a66cbfbd2a495a 100644 (file)
Binary files a/weaver/testdata/ltw-dwaspects.jar and b/weaver/testdata/ltw-dwaspects.jar differ
index 868c3b91739fdab89bf61002a8c451cb595f577b..6081aac7bab483c115d6d858e85b557994c3a557 100644 (file)
Binary files a/weaver/testdata/ltw-itdaspects.jar and b/weaver/testdata/ltw-itdaspects.jar differ
index 0a903503ea2fcfc9834ff635b71d19e0f03f98f6..3985ca92851bcaf83335137e4e6aa130169c61f9 100644 (file)
Binary files a/weaver/testdata/ltw-peraspects.jar and b/weaver/testdata/ltw-peraspects.jar differ
index c83beb5576c18f37299b746a9a924fa4c7a02edf..1988c2de95f996fd7d3029722d108a1689547763 100644 (file)
Binary files a/weaver/testdata/ltw-woven.jar and b/weaver/testdata/ltw-woven.jar differ
index 7b82aa2154a585a951e8d18ff98dd8bf4d653160..c644fa73530dac1b031e38b09a69ab76037a87c2 100644 (file)
Binary files a/weaver/testdata/megatrace.jar and b/weaver/testdata/megatrace.jar differ
index 24ec93afb74317983abf4e571b27d2a2451645a0..828380339e8f1deb9f0ccc069c7645620e4a0b44 100644 (file)
Binary files a/weaver/testdata/megatrace0easy.jar and b/weaver/testdata/megatrace0easy.jar differ
index 3fb566030c6a2c6893ed1031bd6b83d0c343aa03..0a9e8fae8868bef160a8666fdebde06084250fd7 100644 (file)
Binary files a/weaver/testdata/megatrace0hard.jar and b/weaver/testdata/megatrace0hard.jar differ
index 577944439afe03e4bb8a157e02acf0d7b72ddfb1..ca94b541aedc0d27a0bcffb73ce41587e000cf85 100644 (file)
Binary files a/weaver/testdata/megatraceNoweave.jar and b/weaver/testdata/megatraceNoweave.jar differ
index 3a6749657b174a01c43049a48098c0af9e163b12..264fada0356b8d29cfeed4dbb9623f7dbdb18dd3 100644 (file)
Binary files a/weaver/testdata/tracing.jar and b/weaver/testdata/tracing.jar differ