Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Weaving anonymous inner class

But, can we weave the anonymous inner class only?
For example, I only want to match the println in the run method.

--
Dehua (Andy) Zhang
Sable Research Group, McGill University
Montréal, Québec, Canada
http://www.cs.mcgill.ca/~dzhang25





-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx on behalf of Andy Clement
Sent: Fri 10/26/2007 03:28
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] Weaving anonymous inner class
 
AspectJ will always weave the anonymous inner classes.  You would have
to actively specify something in your pointcuts to stop it doing it.

public aspect X {
  before(): call(* println(..)) {}
}

class C {
	public static void main(String[] args) {
		new Runnable() {
			public void run() {
				System.out.println("hello");
			}};
	}
}

$ ajc -showWeaveInfo C.java X.aj
Join point 'method-call(void
java.io.PrintStream.println(java.lang.String))' in Type 'C$1'
(C.java:5) advised by before advice from 'X' (X.aj:3)

Andy.


On 26/10/2007, Hendrik Gani <s2116865@xxxxxxxxxxxxxxxxxxx> wrote:
> Hi,
>
> Does anyone know how we can weave an anonymous inner class in aspectj
> (if it is possible at all)?
>
> Is it possible to tell aspectj to weave all the methods of a class
> including those that belong to its inner classes?
>
> Thanks heaps,
>
> Hendrik
>
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top