From: acolyer Date: Thu, 19 Aug 2004 12:29:04 +0000 (+0000) Subject: fix for Bugzilla Bug 37020 X-Git-Tag: V1_2_1~114 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=65c67a4e848311efb7402f5d06bd1a833720b94b;p=aspectj.git fix for Bugzilla Bug 37020 wrong line for method execution join point --- diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java index 9d10f6381..31a10f412 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java @@ -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 index 000000000..30b8040d0 --- /dev/null +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjConstructorDeclaration.java @@ -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 index 000000000..a086269ea --- /dev/null +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjMethodDeclaration.java @@ -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))); + } +} diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java index b1a57c116..76bfc05a4 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java @@ -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; /** diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IfMethodDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IfMethodDeclaration.java index 5103a8a78..e69767ff5 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IfMethodDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IfMethodDeclaration.java @@ -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) { diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java index 6efe2dd75..26007511b 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java @@ -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); } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java index b0595257e..e1c6673b7 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java @@ -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; diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java index 4c79c9a5a..9879e5a55 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java @@ -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>Preferences>Java>Code Generation>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) */ diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar b/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar index 37151cc0f..d8aba690e 100644 Binary files a/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar and b/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar differ diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar b/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar index df45a1dd6..7f06e1b09 100644 Binary files a/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar and b/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar differ diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar b/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar index eba9b328a..66a5e9ee9 100644 Binary files a/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar and b/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar differ diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java index cd0ec9ddd..a1a0e4c83 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java @@ -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() { diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/PerformanceTestCase.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/PerformanceTestCase.java index 527fe9304..433478de8 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/PerformanceTestCase.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/PerformanceTestCase.java @@ -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"); } } diff --git a/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip b/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip index f5642bb4c..bfd62984c 100644 Binary files a/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip and b/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip differ diff --git a/org.eclipse.jdt.core/jdtcore-for-aspectj.jar b/org.eclipse.jdt.core/jdtcore-for-aspectj.jar index f19ce9148..02f5419ec 100644 Binary files a/org.eclipse.jdt.core/jdtcore-for-aspectj.jar and b/org.eclipse.jdt.core/jdtcore-for-aspectj.jar differ diff --git a/testing-drivers/testdata/incremental/harness/expClasses/exp/Main.class b/testing-drivers/testdata/incremental/harness/expClasses/exp/Main.class index fba840b69..fd25eb1dc 100644 Binary files a/testing-drivers/testdata/incremental/harness/expClasses/exp/Main.class and b/testing-drivers/testdata/incremental/harness/expClasses/exp/Main.class differ diff --git a/testing-drivers/testdata/incremental/harness/suite.xml b/testing-drivers/testdata/incremental/harness/suite.xml index 3a19813e5..129865499 100644 --- a/testing-drivers/testdata/incremental/harness/suite.xml +++ b/testing-drivers/testdata/incremental/harness/suite.xml @@ -89,12 +89,15 @@ + diff --git a/testing-drivers/testsrc/org/aspectj/testing/drivers/HarnessSelectionTest.java b/testing-drivers/testsrc/org/aspectj/testing/drivers/HarnessSelectionTest.java index 94cc99985..489723f8e 100644 --- a/testing-drivers/testsrc/org/aspectj/testing/drivers/HarnessSelectionTest.java +++ b/testing-drivers/testsrc/org/aspectj/testing/drivers/HarnessSelectionTest.java @@ -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); } diff --git a/tests/bugs/StringToString/helloworld.jar b/tests/bugs/StringToString/helloworld.jar index 185b8eb2b..447374ddc 100644 Binary files a/tests/bugs/StringToString/helloworld.jar and b/tests/bugs/StringToString/helloworld.jar differ diff --git a/tests/bugs/serialVersionUID/injar.jar b/tests/bugs/serialVersionUID/injar.jar index 7a8996bb2..a5dbf9798 100644 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 index 000000000..8a97048e8 --- /dev/null +++ b/tests/design/sourceLines/TestSourceLines.java @@ -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 diff --git a/tests/new/DeclareWarningMain.java b/tests/new/DeclareWarningMain.java index 243a4668b..add8ff01e 100644 --- a/tests/new/DeclareWarningMain.java +++ b/tests/new/DeclareWarningMain.java @@ -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[])) { diff --git a/tests/new/declare/DeclareWarning.java b/tests/new/declare/DeclareWarning.java index 1ea56b2b8..9f7efccf5 100644 --- a/tests/new/declare/DeclareWarning.java +++ b/tests/new/declare/DeclareWarning.java @@ -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"); diff --git a/tests/new/options11/aspectlib1.jar b/tests/new/options11/aspectlib1.jar index fbe0d3610..722c97ff3 100644 Binary files a/tests/new/options11/aspectlib1.jar and b/tests/new/options11/aspectlib1.jar differ diff --git a/tests/new/options11/aspectlib2.jar b/tests/new/options11/aspectlib2.jar index 05e82c363..22647696d 100644 Binary files a/tests/new/options11/aspectlib2.jar and b/tests/new/options11/aspectlib2.jar differ diff --git a/tests/new/options11/injar.jar b/tests/new/options11/injar.jar index d4ac54e79..7acf3a083 100644 Binary files a/tests/new/options11/injar.jar and b/tests/new/options11/injar.jar differ diff --git a/tests/src/org/aspectj/systemtest/ajc10x/ajc10x-tests.xml b/tests/src/org/aspectj/systemtest/ajc10x/ajc10x-tests.xml index 9e04c610e..0c085c7f0 100644 --- a/tests/src/org/aspectj/systemtest/ajc10x/ajc10x-tests.xml +++ b/tests/src/org/aspectj/systemtest/ajc10x/ajc10x-tests.xml @@ -1860,7 +1860,7 @@ - + diff --git a/tests/src/org/aspectj/systemtest/ajc11/ajc11-tests.xml b/tests/src/org/aspectj/systemtest/ajc11/ajc11-tests.xml index 95fe34a0b..37bab3371 100644 --- a/tests/src/org/aspectj/systemtest/ajc11/ajc11-tests.xml +++ b/tests/src/org/aspectj/systemtest/ajc11/ajc11-tests.xml @@ -237,7 +237,7 @@ - + @@ -406,7 +406,7 @@ - + diff --git a/tests/src/org/aspectj/systemtest/incremental/IncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/IncrementalTests.java index 0cd0d6db3..aa34783b9 100644 --- a/tests/src/org/aspectj/systemtest/incremental/IncrementalTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/IncrementalTests.java @@ -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"); } diff --git a/tests/src/org/aspectj/systemtest/incremental/incremental-junit-tests.xml b/tests/src/org/aspectj/systemtest/incremental/incremental-junit-tests.xml index d24c5428b..b3fb62d8b 100644 --- a/tests/src/org/aspectj/systemtest/incremental/incremental-junit-tests.xml +++ b/tests/src/org/aspectj/systemtest/incremental/incremental-junit-tests.xml @@ -189,7 +189,7 @@ diff --git a/tests/src/org/aspectj/systemtest/incremental/incremental-tests.xml b/tests/src/org/aspectj/systemtest/incremental/incremental-tests.xml index 24b7a234a..532b22398 100644 --- a/tests/src/org/aspectj/systemtest/incremental/incremental-tests.xml +++ b/tests/src/org/aspectj/systemtest/incremental/incremental-tests.xml @@ -176,7 +176,7 @@ - + diff --git a/tests/src/org/aspectj/systemtest/pre10x/pre10x-tests.xml b/tests/src/org/aspectj/systemtest/pre10x/pre10x-tests.xml index 90a1de463..d96bc3e4b 100644 --- a/tests/src/org/aspectj/systemtest/pre10x/pre10x-tests.xml +++ b/tests/src/org/aspectj/systemtest/pre10x/pre10x-tests.xml @@ -128,7 +128,8 @@ title="decent errors for around return type not matching target point" keywords="from-errors"> - + + diff --git a/weaver/src/org/aspectj/weaver/AjAttribute.java b/weaver/src/org/aspectj/weaver/AjAttribute.java index 417fa7ce5..b194e19af 100644 --- a/weaver/src/org/aspectj/weaver/AjAttribute.java +++ b/weaver/src/org/aspectj/weaver/AjAttribute.java @@ -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"; diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java b/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java index b55184285..202982d76 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java @@ -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; diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java index 9e6fd0c29..d521ed52d 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java @@ -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()); diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java index f90fe103b..47076f351 100644 --- a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java +++ b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java @@ -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; diff --git a/weaver/testdata/dummyAspect.jar b/weaver/testdata/dummyAspect.jar index baf5a2a25..b61752c66 100644 Binary files a/weaver/testdata/dummyAspect.jar and b/weaver/testdata/dummyAspect.jar differ diff --git a/weaver/testdata/ltw-acaspects.jar b/weaver/testdata/ltw-acaspects.jar index 3fe72d9d7..0ef9dc1ab 100644 Binary files a/weaver/testdata/ltw-acaspects.jar and b/weaver/testdata/ltw-acaspects.jar differ diff --git a/weaver/testdata/ltw-aspects.jar b/weaver/testdata/ltw-aspects.jar index 2f232c71f..ae188557a 100644 Binary files a/weaver/testdata/ltw-aspects.jar and b/weaver/testdata/ltw-aspects.jar differ diff --git a/weaver/testdata/ltw-classes.jar b/weaver/testdata/ltw-classes.jar index 64aa2aee4..ec7b131b8 100644 Binary files a/weaver/testdata/ltw-classes.jar and b/weaver/testdata/ltw-classes.jar differ diff --git a/weaver/testdata/ltw-deaspects.jar b/weaver/testdata/ltw-deaspects.jar index 982c609ad..261df4f6b 100644 Binary files a/weaver/testdata/ltw-deaspects.jar and b/weaver/testdata/ltw-deaspects.jar differ diff --git a/weaver/testdata/ltw-dwaspects.jar b/weaver/testdata/ltw-dwaspects.jar index d3cbc6728..e32be29da 100644 Binary files a/weaver/testdata/ltw-dwaspects.jar and b/weaver/testdata/ltw-dwaspects.jar differ diff --git a/weaver/testdata/ltw-itdaspects.jar b/weaver/testdata/ltw-itdaspects.jar index 868c3b917..6081aac7b 100644 Binary files a/weaver/testdata/ltw-itdaspects.jar and b/weaver/testdata/ltw-itdaspects.jar differ diff --git a/weaver/testdata/ltw-peraspects.jar b/weaver/testdata/ltw-peraspects.jar index 0a903503e..3985ca928 100644 Binary files a/weaver/testdata/ltw-peraspects.jar and b/weaver/testdata/ltw-peraspects.jar differ diff --git a/weaver/testdata/ltw-woven.jar b/weaver/testdata/ltw-woven.jar index c83beb557..1988c2de9 100644 Binary files a/weaver/testdata/ltw-woven.jar and b/weaver/testdata/ltw-woven.jar differ diff --git a/weaver/testdata/megatrace.jar b/weaver/testdata/megatrace.jar index 7b82aa215..c644fa735 100644 Binary files a/weaver/testdata/megatrace.jar and b/weaver/testdata/megatrace.jar differ diff --git a/weaver/testdata/megatrace0easy.jar b/weaver/testdata/megatrace0easy.jar index 24ec93afb..828380339 100644 Binary files a/weaver/testdata/megatrace0easy.jar and b/weaver/testdata/megatrace0easy.jar differ diff --git a/weaver/testdata/megatrace0hard.jar b/weaver/testdata/megatrace0hard.jar index 3fb566030..0a9e8fae8 100644 Binary files a/weaver/testdata/megatrace0hard.jar and b/weaver/testdata/megatrace0hard.jar differ diff --git a/weaver/testdata/megatraceNoweave.jar b/weaver/testdata/megatraceNoweave.jar index 577944439..ca94b541a 100644 Binary files a/weaver/testdata/megatraceNoweave.jar and b/weaver/testdata/megatraceNoweave.jar differ diff --git a/weaver/testdata/tracing.jar b/weaver/testdata/tracing.jar index 3a6749657..264fada03 100644 Binary files a/weaver/testdata/tracing.jar and b/weaver/testdata/tracing.jar differ