chaitanyak (1) [Avatar] Offline
#1
Ramnivas Thanks for ur wonderful book .. Its a pleasure reading ur book ..

My Question is :

I have a class A which has a Method "M"

and i have classes B , C which are subclasses of A and both of them

override the method "M"

Here is a sample client code which uses the above classes

class client {

public void someMethod(A aref)
{
// This is a polymorphic call
aref.m();

A ref = new A();
ref.m();


}

public static void main(String args[])
{

client cl = new client();
cl.someMethod(new B() );

}

}



My question is :


Is there any way to find out through aspects that the call to method "M" of class B is made through A class ref as in the method

someMethod unlike the second one A ref = new A(); ref.m() ;
ramnivas (171) [Avatar] Offline
#2
Re: Differentiate between Polymorphic and NonPolymorphic calls through Aspe
Thanks for your positive comments.

How about the following pointcut:
call(* A.M()) && target(B)

Can you describe the use case (by specifying domain class names)? If so, I may have
a more precise solution.

-Ramnivas