Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] LTW and pointcut not matched with @target and inheritance

Valerio

The aop.xml must appear
- wether directly with a -Daj5.def=pathToTheFile jvm argument. This
might be deprecated but can be handy for testing. When doing so, the
aop.xml will be registered as if it was in the system classpath
- wether indirectly in the classpath thru a META-INF/ entry. For
simple cases that means system classpath and you will thus need -cp
......;myfolder
where myfolder/META-INF/aop.xml points to the aop.xml file
(we also support more complex deployment where you can package this
file in a specific webapp, in an EAR file etc).

In your test app you thus need to fix that. I could do it and here is what I see
    [junit] ------------- Standard Output ---------------
    [junit] **in MyAspect**
    [junit] in Clazz: hello
    [junit] ------------- ---------------- ---------------
Plus a bunch of other verbose message and this most important one:
    [junit] info using (-Daj5.def) META-INF/aop.xml

The "advice did not matched" warning that you have from iajc is
expected in your case as you do "javac the app", "iajc the aspects in
.aj files", "run with load time weaving"
(thus indeed, the aspect' advice  is just compiled but does not weave
any of your app classes since you will use LTW).

The test Adrian did is not using LTW



On 8/17/05, Adrian Colyer <adrian.colyer@xxxxxxxxx> wrote:
> As soon as you've seen the "adviceDidNotMatch" message you know that
> the test will fail.
> In my previous post I showed some source code for a test I added to
> the suite to cover this case (and that is passing). You can find the
> this code at
> 
> http://dev.eclipse.org/viewcvs/index.cgi/org.aspectj/modules/tests/bugs150/AnnotationPlusPatternMatchingError.aj?cvsroot=Technology_Project
> 
> If you download that file and then run ajc -1.5
> AnnotationPlusPatternMatchingError.aj
> 
> do you see the expected "matched" warning, and then when you run
> 
> java AnnotationPlusPatternMatchingError
> 
> do you see "In advice" printed out?
> 
> This should verify that your basic setup is working as expected.
> 
> On 17/08/05, Valerio Schiavoni <ervalerio@xxxxxxxxxx> wrote:
> > Hello Adrian,
> > i tried with latest release (dev build:
> > aspectj-DEVELOPMENT-20050816144948.jar),
> > and no good results yet.
> >
> > do you see anything strange in the output of a full clean/build/launch
> > of the project:
> > ant clean compile test
> > Buildfile: build.xml
> >
> > clean:
> >    [delete] Deleting directory /home/valerio/workspace/ltwtest/output/build
> >
> > compile:
> >     [mkdir] Created dir: /home/valerio/workspace/ltwtest/output/build
> >     [javac] Compiling 5 source files to
> > /home/valerio/workspace/ltwtest/output/build
> >      [iajc] /home/valerio/workspace/ltwtest/src/test/MyAspect.aj:12
> > [warning] advice defined in test.MyAspect has not been applied
> > [Xlint:adviceDidNotMatch]
> >      [iajc] before(): foo(){
> >      [iajc] ^^^^^^^^^^
> >
> > test:
> >     [junit] Running test.LtwTest
> >     [junit] info using classpath: [/usr/java/jdk1.5.0/jre/lib/rt.jar,
> > /usr/java/jdk1.5.0/jre/lib/i18n.jar,
> > /usr/java/jdk1.5.0/jre/lib/sunrsasign.jar,
> > /usr/java/jdk1.5.0/jre/lib/jsse.jar, /usr/java/jdk1.5.0/jre/lib/jce.jar,
> > /usr/java/jdk1.5.0/jre/lib/charsets.jar, /usr/java/jdk1.5.0/jre/classes]
> >     [junit] info using aspectpath: []
> >     [junit] info zipfile classpath entry does not exist:
> > /usr/java/jdk1.5.0/jre/lib/i18n.jar
> >     [junit] info zipfile classpath entry does not exist:
> > /usr/java/jdk1.5.0/jre/lib/sunrsasign.jar
> >     [junit] info directory classpath entry does not exist:
> > /usr/java/jdk1.5.0/jre/classes
> >     [junit] info register classloader
> > sun.misc.Launcher$AppClassLoader@26099296
> >     [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0,041 sec
> >     [junit] Testsuite: test.LtwTest
> >     [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0,041 sec
> >     [junit] ------------- Standard Output ---------------
> >     [junit] in Clazz: hello
> >     [junit] ------------- ---------------- ---------------
> >
> >     [junit] Testcase: testLtw took 0,035 sec
> >
> > BUILD SUCCESSFUL
> > Total time: 7 seconds
> >
> >
> > where i renamed my pointcut to foo() to be compliant to the signature
> > you used in your tests.
> > despite the fact that i set aj.weaving.verbose=true and in aop.xml  "
> > -verbose", i can't see any weaving info.
> >
> > I got those results from command-line. I got same results launching the
> > ant tasks within eclipse and ajdt.
> >
> > I'm pretty sure this is not related to the configuration of my machine,
> > but tell me if i should look for something special, more than then the
> > sources i uploaded there.
> >
> > Some info :
> >
> > java -version
> > java version "1.5.0_04"
> > Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
> > Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)
> >
> > ajc -version
> > AspectJ Compiler DEVELOPMENT built on Tuesday Aug 16, 2005 at 14:16:39 GMT
> >
> > Adrian Colyer ha scritto:
> >
> > >I just tried out your latest code with the current dev build of
> > >AspectJ 5. I made only the following change:
> > >
> > >public class LtwTest // extends TestCase
> > >{
> > >
> > >  // added main to drive direct from command line...
> > >  public static void main(String[] args) {
> > >     new LtwTest().testLtw();
> > >  }
> > >
> > >  // rest as before
> > >
> > >}
> > >
> > >and the program output:
> > >
> > >**in MyAspect**
> > >in Clazz: hello
> > >
> > >which is the expected output.
> > >
> > >This test case:
> > >
> > >    <ajc-test title="intermediate annotation matching" dir="bugs150">
> > >        <compile files="AnnotationPlusPatternMatchingError.aj" options="-1.5">
> > >            <message kind="warning" line="28" text="matched"/>
> > >        </compile>
> > >        <run class="AnnotationPlusPatternMatchingError">
> > >            <stdout>
> > >                <line text="In advice"/>
> > >            </stdout>
> > >        </run>
> > >    </ajc-test>
> > >
> > >with source code as shown below also passes. Is it possible there is
> > >something else going on in your environment?
> > >
> > >interface A {
> > >public void a(String s);
> > >}
> > >
> > >@Annotation
> > >interface B extends A{}
> > >
> > >class C implements B {
> > >   public void a(final String s) {}
> > >}
> > >
> > >aspect Aspect{
> > >   pointcut foo(): call(* (@Annotation *)+.*(..));
> > >   declare warning : foo() : "matched";
> > >   before() : foo() {
> > >          System.out.println("In advice");
> > >   }
> > >}
> > >
> > >public class AnnotationPlusPatternMatchingError {
> > >
> > >       public static void main(String[] args) {
> > >               new AnnotationPlusPatternMatchingError().testLtw();
> > >       }
> > >
> > >       public void testLtw() {
> > >                B anA = new C();
> > >                anA.a("hi");
> > >       }
> > >
> > >}
> > >
> > >@interface Annotation {}
> > >
> > >On 16/08/05, Valerio Schiavoni <ervalerio@xxxxxxxxxx> wrote:
> > >
> > >
> > >>a project test case can be downloaded from:
> > >>
> > >>http://sardes.inrialpes.fr/~valerio/ltwtest.tgz
> > >>
> > >>
> > >>
> >
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> 
> 
> --
> -- Adrian
> adrian.colyer@xxxxxxxxx
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top