Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Identifying join points with generics with @AspectJ style

Hi guys,

I’m getting the message “no match for this type name: ArrayList
[Xlint:invalidAbsoluteTypeName]” at @Before declaration.

My aspect:

@Aspect
public class Model {
	@Pointcut("get(ArrayList<String> Component.a)")
	public void getList() {}
	@Before("getList()")
	public void starting(JoinPoint pjp) throws Throwable {
		System.out.println(pjp);
	}
}

My sample code

import java.util.ArrayList;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
class Component {
	private ArrayList<String> a = new ArrayList<String>();
	public void m() {
		a.add("hellow");
		System.out.println(a);
	}
	public static void main(String[] a) {
		new Component().m();
	}
}

Applying withincode to m() method, AspectJ gives the following join points:

get(ArrayList Component.a)
call(boolean java.util.ArrayList.add(Object))
get(PrintStream java.lang.System.out)
get(ArrayList Component.a)
call(void java.io.PrintStream.println(Object))
[hellow]

Note that the join point for ArrayList is identified without generics. But,
if I write

@Pointcut("get(ArrayList Component.a)")

AspectJ shows the same message. How can I intercept the ArrayList?

Best regards




--
View this message in context: http://aspectj.2085585.n4.nabble.com/Identifying-join-points-with-generics-with-AspectJ-style-tp4651074.html
Sent from the AspectJ - users mailing list archive at Nabble.com.


Back to the top