Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] type matching & weaving

Hi Andy,

As it turns out, I have just managed to get it to work.
I wanted the weaver to point at a package, and i got it to work whenever i pointed the following at the weaver:

<include within="com.morty.test..*" />

It was the double '.' that threw me.  No idea why it didnt work with the classes/interfaces explicity stated...im putting it down to human error! Many thanks for all your help!

Regards,
Andy

----- Original Message ----
From: Andy Clement <andrew.clement@xxxxxxxxx>
To: aspectj-users@xxxxxxxxxxx
Sent: Friday, 26 September, 2008 6:04:14 PM
Subject: Re: [aspectj-users] type matching & weaving

Hi Andy,

Possibly I need to know a bit more about specifics (the pointcut at least).  if the weaveinfo message comes out then the bytecode has been changed and that changed form is what will run.  However, if the weaveinfo indicates weaving has happened 'with a runtime test' it means something about your pointcut could not be purely statically evaluated and so a small test will occur at runtime to determine if the advice should actually run - in this situation you can see the weaveinfo but your advice not apparently executing.  Are the files and pointcuts something like this?

-- A.java --
interface I {
  int foo();
}

class A implements I {
  public int foo() { return 42; }
}

class Extender extends A {
  public int foo() { return 67; }
}
-- End of A.java --

-- X.java --
aspect X {
  before(): execution(* I+.*(..)) {}
}
-- End of X.java --

-- aop.xml --
<aspectj>
<aspects>
<aspect name="X"/>
</aspects>
<weaver options="-showWeaveInfo -verbose">
  <include within="A"/>
  <include within="I"/>
  <include within="X"/>
  <include within="Extender"/>
</weaver>
</aspectj>
-- End of aop.xml --

java -javaagent:aspectjweaver.jar A
[AppClassLoader@1f12c4e] info AspectJ Weaver Version DEVELOPMENT built on Wednesday Sep 24, 2008 at 20:57:28 GMT
[AppClassLoader@1f12c4e] info register classloader sun.misc.Launcher$AppClassLoader@1f12c4e
[AppClassLoader@1f12c4e] info using configuration /C:/asc/ws/aspects/META-INF/aop.xml
[AppClassLoader@1f12c4e] info register aspect X
[AppClassLoader@1f12c4e] weaveinfo Join point 'method-execution(int A.foo())' in Type 'A' (A.java:6) advised by before advice from 'X' (X.java:2)
[AppClassLoader@1f12c4e] weaveinfo Join point 'method-execution(int Extender.foo())' in Type 'Extender' (A.java:14) advised by before advice from 'X' (X.java:2)
[AppClassLoader@1f12c4e] info processing reweavable type X: \X.java
Advice running

I can remove the inclusion of A, I and X from the aop.xml and the same output occurs....

Andy.

2008/9/26 <andymorton@xxxxxxxxxxxxxx>
Hi.
I have 3 classes:
1) Interface: myInterface
2) Class myClass (implements myInterface)
3) Extended myExtendedClass (extends myClass, and overrides a method)

I have a pointcut defined on a method on myInterface, which at runtime, is executed via the extended class. The advice will be run ok whenever I dont add any includes to the weaver options.
If however I add the names of the classes via an include  eg <include within="com.morty.test.myInterface" />, then the advice is never executed.

The files however are weaved, and the weaveInfo shows the advice being linked, with or without the <include>
Obviously, there is a performance hit with having every class go through the weaver, and so i want to limit it.

Any idea why this would happen?

Many thanks in advance

Andy

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top