[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Load time weaving problem
|
I fix that problem, but I still can not run load-time weaving. There is no error, it only produces result as there is no weaving at all.
The step to run the example is
1.) javac -classpath ./ character/Person.java
2.) ajc observer/Inspector.aj
3.) ajc -outjar ./lib/inspect.jar observer/Inspector.aj
warning at this step:
Inspector.aj:4 [warning] no match for this type name: character.Person [Xlint:invalidAbsoluteTypeName]
pointcut observer(): execution(* character.Person.speak(..)); // && this(Person);
^^^^^^^^^^^^^^^^^^^^
[Xlint:invalidAbsoluteTypeName]
4.) export ASPECTPATH=./lib/inspect.jar:$ASPECTJ_HOME/lib/aspectjrt.jar
5.) aj -javaagent:/home/neo/app/aspectj1.6/lib/aspectjweaver.jar -cp ./ character.Person
what might go wrong?
Thanks in advice,
The source now is as below:
package character;
public class Person{
private String name;
public Person(String name){
this.name = name;
}
public String getName(){
return this.name;
}
public void setName(String name){
this.name = name;
}
public void speak(String sentence){
System.out.println(this.name+" say : '"+sentence+"'");
}
public static void main(String args[]){
new Person("Jason").speak("This is a book!");
}
}
package observer;
public aspect Inspector{
pointcut observer(): execution(* character.Person.speak(..)); // && this(Person);
before(): observer(){
System.out.println("before speaking something, thinking ...");
}
}
--- On Sat, 6/9/08, Andrew Eisenberg <andrew@xxxxxxxxxxxx> wrote:
> From: Andrew Eisenberg <andrew@xxxxxxxxxxxx>
> Subject: Re: [aspectj-users] Load time weaving problem
> To: javadeveloper999@xxxxxxxxxxx, aspectj-users@xxxxxxxxxxx
> Date: Saturday, 6 September, 2008, 4:48 PM
> When using LTW, the first step is to ensure that your
> pointcuts are
> applying to the correct joinpoints. Unfortunately, AJDT
> doesn't help
> much with this.
>
> My suggestion to you is to turn off LTW and try to get the
> program
> working using standard compile time weaving. You'll
> find that your
> pointcut isn't correct.
>
> If you can't figure it ask again and I'll tell you
> how to fix your pointcut.
>
> On Sat, Sep 6, 2008 at 7:41 AM, Neo Anderson
> <javadeveloper999@xxxxxxxxxxx> wrote:
> > I am learning to use load-time weaving features
> provided by aspectj, but I can not get my example worked
> whilst running it. The problem is that the load-time
> weaving seems not work.
> >
> > There are two classes named character/Person.java and
> observer/Inspector.aj (source is as listed ) .
> >
> > The way how I compile it is
> > 1.) compile Person.java
> > javac -classpath ./ character/Person.java
> > 2.) compile aspectj source
> > ajc -1.6 observer/Inspector.aj (This step issues
> warning which oreilly's aspectj cookbook says it is ok)
> >
> > [warning] no match for this type name: Person
> [Xlint:invalidAbsoluteTypeName]
> > pointcut observer(): execution(* speak(..)) &&
> this(Person);
> >
> ^^^^
> > [Xlint:invalidAbsoluteTypeName]
> >
> /home/neo/workspace/coding/aspectj/load-time-weaving/observer/Inspector.aj:6
> [warning] advice defined in observer.Inspector has not been
> applied [Xlint:adviceDidNotMatch]
> >
> > 3.) produce outjar and export it in ASPECTPATH
> > ajc -outjar lib/inspector.jar observer/Inspector.aj
> > export ASPECTPATH=./lib/inspect.jar
> >
> > 4.) run example
> > aj -javaagent:$ASPECTJ_HOME/lib/aspectjweaver.jar -cp
> ./ character.Person
> >
> > The result only shows "Jason speak : This is a
> book!" without weaving.
> >
> > What I expect is
> > stage before speaking something!
> > Jason speak : This is a book!
> >
> > Where did I do it wrong?
> >
> > My env: aspectj1.6/ open suse 11.0 64bit/kernel
> 2.6.25-1.1-default/ jdk1.6.x
> >
> > I appreciate any advice,
> >
> > Thank you very much
> >
> > The source is as below:
> >
> > package character;
> >
> > public class Person{
> > private String name;
> >
> > public Person(String name){
> > this.name = name;
> > }
> >
> > public String getName(){
> > return this.name;
> > }
> > public void setName(String name){
> > this.name = name;
> > }
> >
> > public void speak(String sentence){
> > System.out.println(this.name+"
> speak : "+sentence);
> > }
> >
> > public static void main(String args[]){
> > new
> Person("Jason").speak("This is a
> book!");
> > }
> > }
> >
> > package observer;
> >
> > public aspect Inspector{
> > pointcut observer(): execution(* speak(..))
> && this(Person);
> >
> > before(): observer(){
> > System.out.println("stage before
> speaking something!");
> > }
> > }
> >
> >
> >
> >
> >
> >
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >