Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [ajdt-dev] Need help in running a simple aspect

 
It works with these changes. Thanks a lot for the immediate response.

Thanks again,
arvind
------------------------------------------------------------------------
------------------------------------------------------------------------
-------------
This e-mail communication and any attachments are privileged and
confidential and intended only for the use of the recipients named
above. If you are not the intended recipient, please do not review,
disclose, disseminate, distribute or copy this e-mail and attachments.
If you have received this communication in error, please notify the
sender immediately by email or telephone at +91-20-2290-6885 or
+91-9823063006
------------------------------------------------------------------------
------------------------------------------------------------------------
--------------

-----Original Message-----
From: ajdt-dev-bounces@xxxxxxxxxxx [mailto:ajdt-dev-bounces@xxxxxxxxxxx]
On Behalf Of Simone Gianni
Sent: Friday, July 25, 2008 3:31 PM
To: ajdt-dev@xxxxxxxxxxx
Subject: Re: [ajdt-dev] Need help in running a simple aspect

Hi Patil Arvind,
I haven't tested your code, but it seems like your pointcut also matched
the System.out.println call inside your own aspect. This leads to
infinite loop, cause when the printMessage is called, your advice kicks
in, and calls System.out.println, which again is adviced, and so on
forever. If you let yor program run long enought, it will consume all
the memory and end with a StackOverflowException.

In your pointcut, you should be more specific about which methods you
need to advice, explicitly avoiding to advice methods that you use in
your own advice and that could cause recursion. For example :
pointcut printouts(): call(* HelloWord.print*(..));  // Only advice
print* methods inside HelloWord
pointcut printouts(): call(* print*(..)) && !call(* System.*(..)); //
Any print* method except those in System

I hope this is the problem and this indications are useful :D

Simone

PATIL Arvind wrote:
>
> I have following in the folder: *C:\aspectj1.5\doc\examples*
>
> *test1\TestAspect.java*
>
> *test2\HelloWorld.java*
>
>  
>
> */Source:/*
>
> package test2;
>
> class HelloWorld {
>
>   public static void main(String[] args) {
>
>                   System.out.println("in here");
>
>      new HelloWorld().printMessage();
>
>   }
>
>  
>
>   void printMessage() {
>
>     System.out.println("Hello world in java !");
>
>   }
>
> }
>
>  
>
>  
>
> package test1;
>
> public aspect TestAspect {
>
>  
>
> pointcut printouts(): call(* print*(..));
>
>   before(): printouts() {
>
>     System.out.println("*** Entering printMessage ***");
>
>   }
>
>   after():  printouts() {
>
>     System.out.println("*** Exiting printMessage ***");
>
>   }
>
> }
>
>  
>
>  
>
> I run the following from command line:
>
>  
>
> *C:\aspectj1.5\doc\examples>*ajc -target 1.5 -verbose 
> test1/TestAspect.java test2/
>
> HelloWorld.java
>
> directory classpath entry does not exist:
> C:\Java\jdk1.5.0_05\jre\lib\i18n.jar
>
> directory classpath entry does not exist:
> C:\Java\jdk1.5.0_05\jre\lib\sunrsasign
>
> .jar
>
> zipfile classpath entry does not exist: 
> C:\Java\jdk1.5.0_05\jre\classes
>
> Pipelining compilation
>
> compiling C:\aspectj1.5\doc\examples\test1\TestAspect.java
>
> weaver operating in reweavable mode.  Need to verify any required 
> types exist.
>
> woven aspect test1.TestAspect (from
> C:\aspectj1.5\doc\examples\test1\TestAspect.
>
> java)
>
> compiling C:\aspectj1.5\doc\examples\test2\HelloWorld.java
>
> woven class test2.HelloWorld (from
> C:\aspectj1.5\doc\examples\test2\HelloWorld.j
>
> ava)
>
>  
>
> Compiler took 1547ms
>
>  
>
> C*:\aspectj1.5\doc\examples>*java test2.HelloWorld
>
>  
>
> This command does NOT return anything; it just keeps running without 
> completing.
>
> I had to kill it to return to command prompt.
>
>  
>
> Please help in solving this. Is there anything wrong with the code?
>
>  
>
> Thanks
>
> arvind
>
>  
>
> ----------------------------------------------------------------------
> --
>
> _______________________________________________
> ajdt-dev mailing list
> ajdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/ajdt-dev
>   


--
Simone Gianni
http://www.simonegianni.it/
CEO Semeru s.r.l.
Apache Committer

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


Back to the top