@@ -67,19 +67,19 @@ public aspect BasicAdvice { | |||
} | |||
private static void checkBefore(Method method) { | |||
assertTrue("expecting 2 annotations",method.getAnnotations().length == 2); | |||
assertTrue("expecting 2 annotations on before",method.getAnnotations().length == 2); | |||
Before beforeAnnotation = method.getAnnotation(Before.class); | |||
assertTrue("expecting execution(* *.*(..))",beforeAnnotation.value().equals("execution(* *.*(..))")); | |||
} | |||
private static void checkAfter(Method method) { | |||
assertTrue("expecting 2 annotations",method.getAnnotations().length == 2); | |||
assertTrue("expecting 2 annotations on after",method.getAnnotations().length == 2); | |||
After afterAnnotation = method.getAnnotation(After.class); | |||
assertTrue("expecting call(* Integer.*(..))",afterAnnotation.value().equals("call(* Integer.*(..))")); | |||
} | |||
private static void checkAfterReturning(Method method) { | |||
assertTrue("expecting 2 annotations",method.getAnnotations().length == 2); | |||
assertTrue("expecting 2 annotations on after returning",method.getAnnotations().length == 2); | |||
AfterReturning afterAnnotation = method.getAnnotation(AfterReturning.class); | |||
if (method.getParameterTypes().length == 1) { | |||
// form with returning arg | |||
@@ -95,7 +95,7 @@ public aspect BasicAdvice { | |||
} | |||
private static void checkAfterThrowing(Method method) { | |||
assertTrue("expecting 2 annotations",method.getAnnotations().length == 2); | |||
assertTrue("expecting 2 annotations on after throwing",method.getAnnotations().length == 2); | |||
AfterThrowing afterAnnotation = method.getAnnotation(AfterThrowing.class); | |||
if (method.getParameterTypes().length == 1) { | |||
// form with returning arg | |||
@@ -111,7 +111,7 @@ public aspect BasicAdvice { | |||
} | |||
private static void checkAround(Method method) { | |||
assertTrue("expecting 2 annotations",method.getAnnotations().length == 2); | |||
assertTrue("expecting 2 annotations on around",method.getAnnotations().length == 2); | |||
Around aroundAnnotation = method.getAnnotation(Around.class); | |||
assertTrue("expecting set(* foo)",aroundAnnotation.value().equals("set(* foo)")); | |||
} |
@@ -0,0 +1,19 @@ | |||
import org.aspectj.lang.reflect.*; | |||
public aspect Deow { | |||
declare warning : call(* System.*(..)) : "dont call system methods"; | |||
declare error : call(* System.*(..)) : "dont call system methods"; | |||
public static void main(String[] args) { | |||
AjType myType = AjTypeSystem.getAjType(Deow.class); | |||
DeclareErrorOrWarning[] deows = myType.getDeclareErrorOrWarnings(); | |||
if (deows.length != 2) throw new RuntimeException("Excepting 2 deows, got: " + deows.length); | |||
if (deows[0].isError()) throw new RuntimeException("Expecting a warning"); | |||
if (!deows[1].isError()) throw new RuntimeException("Expecting an error"); | |||
if (!deows[0].getMessage().equals("dont call system methods")) throw new RuntimeException("Bad message"); | |||
if (!deows[1].getMessage().equals("dont call system methods")) throw new RuntimeException("Bad message"); | |||
if (!deows[0].getPointcutExpression().equals("call(* java.lang.System.*(..))")) throw new RuntimeException("Bad pc: " + deows[0].getPointcutExpression()); | |||
if (!deows[1].getPointcutExpression().equals("call(* java.lang.System.*(..))")) throw new RuntimeException("Bad pc: " + deows[0].getPointcutExpression()); | |||
} | |||
} |
@@ -122,5 +122,9 @@ public class AtAjAnnotationGenTests extends XMLBasedAjcTestCase { | |||
public void testAdviceDeclaredInClass() { | |||
runTest("advice in a class"); | |||
} | |||
public void testDeows() { | |||
runTest("ann gen for deows"); | |||
} | |||
} | |||
@@ -137,4 +137,10 @@ | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/ataspectj/annotationGen" title="ann gen for deows"> | |||
<compile files="Deow.aj" options="-1.5"> | |||
</compile> | |||
<run class="Deow"/> | |||
</ajc-test> | |||
</suite> |
@@ -205,4 +205,4 @@ | |||
<message kind="error" line="6" text="Advice must be declared inside an aspect type"/> | |||
</compile> | |||
</ajc-test> | |||
@@ -22,7 +22,7 @@ public class NameMangler { | |||
} | |||
public static final String PREFIX = "ajc$"; | |||
public static final String ITD_PREFIX = PREFIX + "interType$"; | |||
public static final String CFLOW_STACK_TYPE = "org.aspectj.runtime.internal.CFlowStack"; | |||
public static final String CFLOW_COUNTER_TYPE="org.aspectj.runtime.internal.CFlowCounter"; |
@@ -63,7 +63,5 @@ public abstract class Declare extends PatternNode { | |||
* this 'getNameSuffix()' method - depending on whether, at weave time, we | |||
* want to easily differentiate between the declare methods. | |||
*/ | |||
public String getNameSuffix() { | |||
return ""; | |||
} | |||
public abstract String getNameSuffix(); | |||
} |
@@ -98,4 +98,7 @@ public class DeclareErrorOrWarning extends Declare { | |||
return true; | |||
} | |||
public String getNameSuffix() { | |||
return "eow"; | |||
} | |||
} |
@@ -245,4 +245,7 @@ public class DeclareParents extends Declare { | |||
return ret; | |||
} | |||
public String getNameSuffix() { | |||
return "parents"; | |||
} | |||
} |
@@ -148,4 +148,7 @@ public class DeclarePrecedence extends Declare { | |||
return false; | |||
} | |||
public String getNameSuffix() { | |||
return "precedence"; | |||
} | |||
} |
@@ -109,4 +109,8 @@ public class DeclareSoft extends Declare { | |||
public boolean isAdviceLike() { | |||
return true; | |||
} | |||
public String getNameSuffix() { | |||
return "soft"; | |||
} | |||
} |