Browse Source

test and fix for Bugzilla Bug 42539

	  	throw derivative pointcuts not advised
tags/V1_1_1
jhugunin 21 years ago
parent
commit
8660cc12bf

+ 10
- 0
tests/ajcTests.xml View File

@@ -6720,4 +6720,14 @@
aspectpath="lib.jar"/>
<run class="PerCFlowCompileFromJarTest"/>
</ajc-test>
<ajc-test dir="bugs/throwsSignature"
pr="42539"
title="throw derivative pointcuts not advised">
<compile files="ExceptionBugTest.java,ExceptionAspect.java">
<message line="5" kind="warning" text="throws both"/>
<message line="5" kind="error" text="throws Exception"/>
<message line="7" kind="warning" text="throws both"/>
</compile>
</ajc-test>
</suite>

+ 10
- 0
tests/bugs/throwsSignature/ExceptionAspect.java View File

@@ -0,0 +1,10 @@
public aspect ExceptionAspect
{
pointcut exceptionThrower() :
execution(public * ExceptionBugTest.*(..) throws Exception+);

declare warning : exceptionThrower() : "throws both";
declare error : execution(public * ExceptionBugTest.*(..) throws Exception) :
"throws Exception";
}

+ 8
- 0
tests/bugs/throwsSignature/ExceptionBugTest.java View File

@@ -0,0 +1,8 @@
public class ExceptionBugTest {
int x;
class MyException extends Exception {}

public void method1() throws Exception { x = 1; } // warning here

public void method2() throws MyException { x = 2; } // warning here
}

+ 1
- 1
weaver/src/org/aspectj/weaver/patterns/ThrowsPattern.java View File

@@ -91,7 +91,7 @@ public class ThrowsPattern extends PatternNode {
ResolvedTypeX[] types)
{
for (int i = types.length - 1; i >= 0; i--) {
if (typePattern.matchesExactly(types[i])) return true;
if (typePattern.matchesStatically(types[i])) return true;
}
return false;
}

Loading…
Cancel
Save