Browse Source

fix for Bugzilla Bug 37020

 	wrong line for method execution join point
tags/V1_2_1
acolyer 19 years ago
parent
commit
65c67a4e84
50 changed files with 283 additions and 26 deletions
  1. 2
    2
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java
  2. 58
    0
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjConstructorDeclaration.java
  3. 58
    0
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjMethodDeclaration.java
  4. 1
    1
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java
  5. 1
    2
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IfMethodDeclaration.java
  6. 2
    2
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java
  7. 1
    2
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java
  8. 18
    1
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java
  9. BIN
      org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar
  10. BIN
      org.aspectj.ajdt.core/testdata/OutjarTest/child.jar
  11. BIN
      org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar
  12. 1
    1
      org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java
  13. 1
    1
      org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/PerformanceTestCase.java
  14. BIN
      org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip
  15. BIN
      org.eclipse.jdt.core/jdtcore-for-aspectj.jar
  16. BIN
      testing-drivers/testdata/incremental/harness/expClasses/exp/Main.class
  17. 4
    1
      testing-drivers/testdata/incremental/harness/suite.xml
  18. 1
    1
      testing-drivers/testsrc/org/aspectj/testing/drivers/HarnessSelectionTest.java
  19. BIN
      tests/bugs/StringToString/helloworld.jar
  20. BIN
      tests/bugs/serialVersionUID/injar.jar
  21. 52
    0
      tests/design/sourceLines/TestSourceLines.java
  22. 2
    2
      tests/new/DeclareWarningMain.java
  23. 2
    2
      tests/new/declare/DeclareWarning.java
  24. BIN
      tests/new/options11/aspectlib1.jar
  25. BIN
      tests/new/options11/aspectlib2.jar
  26. BIN
      tests/new/options11/injar.jar
  27. 1
    1
      tests/src/org/aspectj/systemtest/ajc10x/ajc10x-tests.xml
  28. 2
    2
      tests/src/org/aspectj/systemtest/ajc11/ajc11-tests.xml
  29. 1
    1
      tests/src/org/aspectj/systemtest/incremental/IncrementalTests.java
  30. 1
    1
      tests/src/org/aspectj/systemtest/incremental/incremental-junit-tests.xml
  31. 1
    1
      tests/src/org/aspectj/systemtest/incremental/incremental-tests.xml
  32. 2
    1
      tests/src/org/aspectj/systemtest/pre10x/pre10x-tests.xml
  33. 28
    0
      weaver/src/org/aspectj/weaver/AjAttribute.java
  34. 16
    1
      weaver/src/org/aspectj/weaver/bcel/BcelMethod.java
  35. 15
    0
      weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
  36. 12
    0
      weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
  37. BIN
      weaver/testdata/dummyAspect.jar
  38. BIN
      weaver/testdata/ltw-acaspects.jar
  39. BIN
      weaver/testdata/ltw-aspects.jar
  40. BIN
      weaver/testdata/ltw-classes.jar
  41. BIN
      weaver/testdata/ltw-deaspects.jar
  42. BIN
      weaver/testdata/ltw-dwaspects.jar
  43. BIN
      weaver/testdata/ltw-itdaspects.jar
  44. BIN
      weaver/testdata/ltw-peraspects.jar
  45. BIN
      weaver/testdata/ltw-woven.jar
  46. BIN
      weaver/testdata/megatrace.jar
  47. BIN
      weaver/testdata/megatrace0easy.jar
  48. BIN
      weaver/testdata/megatrace0hard.jar
  49. BIN
      weaver/testdata/megatraceNoweave.jar
  50. BIN
      weaver/testdata/tracing.jar

+ 2
- 2
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java View 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);
}

+ 58
- 0
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjConstructorDeclaration.java View File

@@ -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)));
}
}

+ 58
- 0
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjMethodDeclaration.java View File

@@ -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)));
}
}

+ 1
- 1
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java View 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;

/**

+ 1
- 2
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IfMethodDeclaration.java View 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) {

+ 2
- 2
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java View 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);
}

+ 1
- 2
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java View 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;

+ 18
- 1
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java View 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)
*/

BIN
org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar View File


BIN
org.aspectj.ajdt.core/testdata/OutjarTest/child.jar View File


BIN
org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar View File


+ 1
- 1
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java View 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() {

+ 1
- 1
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/PerformanceTestCase.java View 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");
}
}

BIN
org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip View File


BIN
org.eclipse.jdt.core/jdtcore-for-aspectj.jar View File


BIN
testing-drivers/testdata/incremental/harness/expClasses/exp/Main.class View File


+ 4
- 1
testing-drivers/testdata/incremental/harness/suite.xml View File

@@ -89,12 +89,15 @@
<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>

+ 1
- 1
testing-drivers/testsrc/org/aspectj/testing/drivers/HarnessSelectionTest.java View 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);
}

BIN
tests/bugs/StringToString/helloworld.jar View File


BIN
tests/bugs/serialVersionUID/injar.jar View File


+ 52
- 0
tests/design/sourceLines/TestSourceLines.java View File

@@ -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";
}

+ 2
- 2
tests/new/DeclareWarningMain.java View 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[])) {

+ 2
- 2
tests/new/declare/DeclareWarning.java View 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");

BIN
tests/new/options11/aspectlib1.jar View File


BIN
tests/new/options11/aspectlib2.jar View File


BIN
tests/new/options11/injar.jar View File


+ 1
- 1
tests/src/org/aspectj/systemtest/ajc10x/ajc10x-tests.xml View File

@@ -1860,7 +1860,7 @@
<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>

+ 2
- 2
tests/src/org/aspectj/systemtest/ajc11/ajc11-tests.xml View File

@@ -237,7 +237,7 @@
<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>
@@ -406,7 +406,7 @@
<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>

+ 1
- 1
tests/src/org/aspectj/systemtest/incremental/IncrementalTests.java View 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");
}

+ 1
- 1
tests/src/org/aspectj/systemtest/incremental/incremental-junit-tests.xml View File

@@ -189,7 +189,7 @@
</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"/>
-->

+ 1
- 1
tests/src/org/aspectj/systemtest/incremental/incremental-tests.xml View File

@@ -176,7 +176,7 @@
<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>

+ 2
- 1
tests/src/org/aspectj/systemtest/pre10x/pre10x-tests.xml View File

@@ -128,7 +128,8 @@
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"/>

+ 28
- 0
weaver/src/org/aspectj/weaver/AjAttribute.java View 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";

+ 16
- 1
weaver/src/org/aspectj/weaver/bcel/BcelMethod.java View 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;

+ 15
- 0
weaver/src/org/aspectj/weaver/bcel/BcelShadow.java View 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());

+ 12
- 0
weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java View 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;

BIN
weaver/testdata/dummyAspect.jar View File


BIN
weaver/testdata/ltw-acaspects.jar View File


BIN
weaver/testdata/ltw-aspects.jar View File


BIN
weaver/testdata/ltw-classes.jar View File


BIN
weaver/testdata/ltw-deaspects.jar View File


BIN
weaver/testdata/ltw-dwaspects.jar View File


BIN
weaver/testdata/ltw-itdaspects.jar View File


BIN
weaver/testdata/ltw-peraspects.jar View File


BIN
weaver/testdata/ltw-woven.jar View File


BIN
weaver/testdata/megatrace.jar View File


BIN
weaver/testdata/megatrace0easy.jar View File


BIN
weaver/testdata/megatrace0hard.jar View File


BIN
weaver/testdata/megatraceNoweave.jar View File


BIN
weaver/testdata/tracing.jar View File


Loading…
Cancel
Save