| Summary: | compilation ordering issue for parameter annotation matching | ||
|---|---|---|---|
| Product: | [Tools] AspectJ | Reporter: | Andrew Clement <aclement> |
| Component: | Compiler | Assignee: | aspectj inbox <aspectj-inbox> |
| Status: | NEW --- | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | DEVELOPMENT | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | |||
fixed unsetting the target field which is currently set for something already released |
From the mailing list: I found a workaround and wrote a unit test that runs on developer machines but not on the build server ! The problem occurs with parameter annotations on an local interface : The parameter annotation : package com.example; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Inherited @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PARAMETER) public @interface MyParameterAnnotation { } The local interface : package com.example; import javax.ejb.Local; @Local interface A { public String a(@MyParameterAnnotation String s); } The implementation bean : package com.example; import javax.ejb.Stateless; @Stateless class ABean implements A { public String a(String s) { return s; } } The aspect : package com.example; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; @Aspect public class MyAspect { @Pointcut("execution(* *(..,@MyParameterAnnotation (String),..))") public void anyMethodCallWithMyParameterAnnotation() { } @Around("anyMethodCallWithMyParameterAnnotation()") public Object aroundMethodWithMyParameterAnnotation(ProceedingJoinPoint pjp) throws Throwable { throw new RuntimeException("OK"); } } The unit test : package com.example; import org.junit.Assert; import org.junit.Test; public class MyAspectTest { @Test public void testIt() { A a = new ABean(); try { Assert.assertEquals("aha", a.a("aha")); Assert.fail("Failed due to a weaving problem."); } catch (Exception e) { Assert.assertEquals("OK", e.getMessage()); } } } This test can be "fixed" when you add the @MyParameterAnnotation annotation on the parameter of the implementation bean too. Regards, Diether