Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Pointcut for main method

Reply
Thread Tools

Pointcut for main method

 
 
Guybrush Threepwood
Guest
Posts: n/a
 
      11-08-2006
I'm making some exercises to learn AspectJ and I'm not able to define a
pointcut that captures the main method.

public aspect Test {

pointcut callStatic() : call(public static void *(..));

before() : callStatic() {
System.out.println("ok");
}
}

Why does the pointcut capture all public static methods with void return
type except for the main method?
 
Reply With Quote
 
 
 
 
Piotr Kobzda
Guest
Posts: n/a
 
      11-08-2006
Guybrush Threepwood wrote:

> I'm making some exercises to learn AspectJ and I'm not able to define a
> pointcut that captures the main method.
>
> public aspect Test {
>
> pointcut callStatic() : call(public static void *(..));
>
> before() : callStatic() {
> System.out.println("ok");
> }
> }
>
> Why does the pointcut capture all public static methods with void return
> type except for the main method?


The call join point picked out by your pointcut happens outside the
target method. In order to implement that for main() method, AspectJ
should be able to modify the code of the JVM which invoked your main().
Use the execution join point instead.

See also:
http://www.eclipse.org/aspectj/doc/r...llandexecution


piotr
 
Reply With Quote
 
 
 
 
Chris Uppal
Guest
Posts: n/a
 
      11-09-2006
Piotr Kobzda wrote:

> The call join point picked out by your pointcut happens outside the
> target method. In order to implement that for main() method, AspectJ
> should be able to modify the code of the JVM which invoked your main().
> Use the execution join point instead.
>
> See also:
> http://www.eclipse.org/aspectj/doc/r...llandexecution


Interesting. I hadn't realised that AspectJ distinguished between the inside
and outside of a method call (as it were). It's a good idea. (Still doesn't
make me less sceptical about the AspectJ vision of AOP, though).

In this case the main() entry point is invoked directly from JNI[*] -- which
does make it difficult for bytecode manipulation to replace

([*] That's to say, it's not -- strictly speaking -- built into the JVM).

-- chris




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What will happen if main called in side main function? Ravi C Programming 17 04-01-2006 10:08 PM
int main() or int main(void)? Frederick Ding C Programming 10 12-04-2005 12:44 AM
adding main.aspx.vb & main.aspx.resx under aspx John M ASP .Net 1 05-29-2005 09:27 PM
int main(int argc, char *argv[] ) vs int main(int argc, char **argv ) Hal Styli C Programming 14 01-20-2004 10:00 PM



Advertisments