Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Understanding generic types in args(..) construction

Hi Andy,

I did a bunch of tests using args(..) + generics..
Please, take a look on the attached file and let me know your thoughts.
I've labeled each test doing something not expected with ERROR.

Note that those are my understanding of how args(..) and after(..) returning(..) should work. Please, let me know if you disagree about the expected result of any test I did.

Thanks in advance,
Fernando Rubbo

P.S.: Note that you need to uncomment the method line and all the respective around advices you wanna verify.

On Sun, Nov 9, 2008 at 11:29 PM, Fernando Rubbo <fernando.rubbo@xxxxxxxxx> wrote:
Tomorrow night I'll do some more complex tests on it.
Thanks for your help


On Sun, Nov 9, 2008 at 11:28 PM, Fernando Rubbo <fernando.rubbo@xxxxxxxxx> wrote:
I'm so sorry.. That was MY mistake..
I took a look on my tests and I saw I forgot to import java.util.ArrayList. That is why I got the incorrect result.
I just import the java.util.ArrayList and got the same result you just post here.. Again, I apologize.

Tomorrow night I




On Fri, Nov 7, 2008 at 1:31 PM, Andy Clement <andrew.clement@xxxxxxxxx> wrote:
Which dev build did you use?  I downloaded the currently available one (aspectj-DEVELOPMENT-20081103213827.jar) and get different results to you.  My results are on the line before each piece of advice below - the only problem where it does not do as expected is marked ERROR below.

aspect AC{
    // matches

    void around(): execution(* C.m1(..))  && args(List<Integer>){} //: Should match (it does)   

    // matches with runtime check

    void around(): execution(* C.m1(..))  && args(ArrayList<Integer>){}//: Should runtime check (it does not match!)

    // does not match

    void around(): execution(* C.m1(..))  && args(List<Number>){}//: Should not match (it does not!)   

    // does not match
    void around(): execution(* C.m1(..))  && args(ArrayList<Number>){}//: Should not match (it does not)

    // matches

    void around(): execution(* C.m1(..))  && args(List<? extends Number>){}//: Should match (it does)

    // matches with runtime test

    void around(): execution(* C.m1(..))  && args(ArrayList<? extends Number>){}//: Should runtime check (it does not match!)

    // matches

    void around(): execution(* C.m1(..))  && args(List){}//: Should match (it does)   

    // ERROR: currently does not match and should (with runtime test)

    void around(): execution(* C.m1(..))  && args(ArrayList){}//: Should runtime check (it does not match!)   

    // matches

    void around(): execution(* C.m1(..))  && args(List<?>){}//: Should match (it does)   

    // matches with runtime test

    void around(): execution(* C.m1(..))  && args(ArrayList<?>){}//: Should runtime check (it does not match!)   

    // does not match

    void around(): execution(* C.m1(..))  && args(ArrayList<String>){}//: Should not match (it does not match!)
}

And your around advice case return value testcase doesn't match with that current dev build either.

cheers,
Andy.


2008/11/4 Fernando Rubbo <fernando.rubbo@xxxxxxxxx>

Hi Andy,,

I did a simple test on this new aspectj development build and it is not working for runtime check.

public class C {
    void m1(List<Integer> e){}   
}

aspect AC{
    void around(): execution(* C.m1(..))  && args(List<Integer>){} //: Should match (it does)   
    void around(): execution(* C.m1(..))  && args(ArrayList<Integer>){}//: Should runtime check (it does not match!)
    void around(): execution(* C.m1(..))  && args(List<Number>){}//: Should not match (it does not!)   
    void around(): execution(* C.m1(..))  && args(ArrayList<Number>){}//: Should not match (it does not)
    void around(): execution(* C.m1(..))  && args(List<? extends Number>){}//: Should match (it does)
    void around(): execution(* C.m1(..))  && args(ArrayList<? extends Number>){}//: Should runtime check (it does not match!)
    void around(): execution(* C.m1(..))  && args(List){}//: Should match (it does)   
    void around(): execution(* C.m1(..))  && args(ArrayList){}//: Should runtime check (it does not match!)   
    void around(): execution(* C.m1(..))  && args(List<?>){}//: Should match (it does)   
    void around(): execution(* C.m1(..))  && args(ArrayList<?>){}//: Should runtime check (it does not match!)   
    void around(): execution(* C.m1(..))  && args(ArrayList<String>){}//: Should not match (it does not match!)
}

Thanks,
Fernando


On Tue, Nov 4, 2008 at 2:29 PM, Andy Clement <andrew.clement@xxxxxxxxx> wrote:
Try it with the dev build from yesterday that includes the latest set of 253109 fixes

2008/11/3 Fernando Rubbo <fernando.rubbo@xxxxxxxxx>
I think we have a similar issue with the around's return. Look it out.

public class B {
    List<Number> m(){ return null;}
}

aspect AB{
    List<Integer> around() : execution(List<*> B.*(..)) {
        return proceed();
    }
}

List<Integer> is not subtype of List<Number>.

Fernando Rubbo



On Mon, Nov 3, 2008 at 9:08 PM, Fernando Rubbo <fernando.rubbo@xxxxxxxxx> wrote:

On 2-nov-08, at 02:27, Fernando Rubbo wrote:
There exists a formal description saying how args(..) and after(..) returning (..) must works?

The best description is probably:
http://www.eclipse.org/aspectj/doc/released/adk15notebook/generics-inAspectJ5.html#d0e2512

That is quite old, but is currently the best we have written down.  Anyone wishing to help us update the doc, please let me know.

If it will gonna respect Java subtyping it is simple to document. We just need to put a note informing that and a reference for Java spec  (The Java Language Specification Third Edition) chapter 4.10 - Subtyping.

Fernando Rubbo


_______________________________________________
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



_______________________________________________
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




import java.util.List;
import java.util.ArrayList;


public class C<E extends Number> {
//	void m1(List<Integer> e){}	
//	void m2(List<? extends Number> e){}
//	void m3(List<Number> e){}	
//	void m4(List<?> e){}
//	void m5(List<E> e){}
//	void m6(List<? extends E> e){}
//	void m7(List<? extends List<? extends E>> e){}
//	void m8(List e){}
//	void m9(E e){}
}

class A1{}
class B1 extends A1{}
class C1 extends B1{}
class D1 extends C1{}

class D2<E2 extends C1>{
	void m5(List<E2> e){}
}

aspect AC{
//void around(): execution(* C.m1(..))  && args(List<Integer>){} //: Should match (it does)	
//void around(): execution(* C.m1(..))  && args(ArrayList<Integer>){}//: Should runtime check (it does!)
//void around(): execution(* C.m1(..))  && args(List<Number>){}//: Should not match (it does not!)	
//void around(): execution(* C.m1(..))  && args(ArrayList<Number>){}//: Should not match (it does not)
//void around(): execution(* C.m1(..))  && args(List<? extends Number>){}//: Should match (it does)
//void around(): execution(* C.m1(..))  && args(ArrayList<? extends Number>){}//: Should runtime check (it does!)
//void around(): execution(* C.m1(..))  && args(List){}//: Should match (it does)	
//void around(): execution(* C.m1(..))  && args(ArrayList){}//: Should runtime check (it does not match!)ERROR	
//void around(): execution(* C.m1(..))  && args(List<?>){}//: Should match (it does)	
//void around(): execution(* C.m1(..))  && args(ArrayList<?>){}//: Should runtime check (it does not match!)	
//void around(): execution(* C.m1(..))  && args(ArrayList<String>){}//: Should not match (it does not match!)

//void around(): execution(* C.m2(..))  && args(List<Integer>){} //: Should not match (but it does) ERROR 
//void around(): execution(* C.m2(..))  && args(ArrayList<Integer>){}//: Should not match (but it does!) ERROR
//void around(): execution(* C.m2(..))  && args(List<Number>){} //: Should not match (but it does) ERROR
//void around(): execution(* C.m2(..))  && args(ArrayList<Number>){}//: Should not runtime check (but it does!) ERROR
//void around(): execution(* C.m2(..))  && args(List<? extends Number>){}//: Should match (it does)
//void around(): execution(* C.m2(..))  && args(ArrayList<? extends Number>){}//: Should runtime check (it does!)
//void around(): execution(* C.m2(..))  && args(List){}//: Should match (it does)	
//void around(): execution(* C.m2(..))  && args(ArrayList){}//: Should runtime check (it does not match!) ERROR	
//void around(): execution(* C.m2(..))  && args(List<?>){}//: Should match (it does)	
//void around(): execution(* C.m2(..))  && args(ArrayList<?>){}//: Should runtime check (it does!)	
//void around(): execution(* C.m2(..))  && args(ArrayList<String>){}//: Should not match (it does not match!)

//	void around(): execution(* C.m3(..))  && args(List<Integer>){} //: Should not match (it does not) 
//	void around(): execution(* C.m3(..))  && args(ArrayList<Integer>){}//: Should not match (it does not)
//	void around(): execution(* C.m3(..))  && args(List<Number>){}//: Should match (it does)	
//	void around(): execution(* C.m3(..))  && args(ArrayList<Number>){}//: Should runtime match (it does)
//	void around(): execution(* C.m3(..))  && args(List<? extends Number>){}//: Should match (it does)
//	void around(): execution(* C.m3(..))  && args(ArrayList<? extends Number>){}//: Should runtime check (it does!)
//	void around(): execution(* C.m3(..))  && args(List){}//: Should match (it does)	
//	void around(): execution(* C.m3(..))  && args(ArrayList){}//: Should runtime check (it does not match!) ERROR	
//	void around(): execution(* C.m3(..))  && args(List<?>){}//: Should match (it does)	
//	void around(): execution(* C.m3(..))  && args(ArrayList<?>){}//: Should runtime check (it does!)	
//	void around(): execution(* C.m3(..))  && args(ArrayList<String>){}//: Should not match (it does not match!)	

//	void around(): execution(* C.m4(..))  && args(List<Integer>){} //: Should not match (but it does) ERROR
//	void around(): execution(* C.m4(..))  && args(ArrayList<Integer>){}//: Should not match (but it does) ERROR
//	void around(): execution(* C.m4(..))  && args(List<Number>){}//: Should not match (but it does)	ERROR
//	void around(): execution(* C.m4(..))  && args(ArrayList<Number>){}//: Should not match (but it does) ERROR
//	void around(): execution(* C.m4(..))  && args(List<? extends Number>){}//: Should not match (but it does) ERROR
//	void around(): execution(* C.m4(..))  && args(ArrayList<? extends Number>){}//: Should not match (but it does!) ERROR
//	void around(): execution(* C.m4(..))  && args(List){}//: Should match (it does)	
//	void around(): execution(* C.m4(..))  && args(ArrayList){}//: Should runtime check (it does!)	
//	void around(): execution(* C.m4(..))  && args(List<?>){}//: Should match (it does)	
//	void around(): execution(* C.m4(..))  && args(ArrayList<?>){}//: Should runtime check (it does!)	
//	void around(): execution(* C.m4(..))  && args(ArrayList<String>){}//: Should not match (it does not match!)	

//	void around(): execution(* C.m5(..))  && args(List<Integer>){} //: Should not match (but it does) ERROR 
//	void around(): execution(* C.m5(..))  && args(ArrayList<Integer>){}//: Should not match (but it does!) ERROR
//	void around(): execution(* C.m5(..))  && args(List<Number>){}//: Should not match (but it does!) ERROR
//	void around(): execution(* C.m5(..))  && args(ArrayList<Number>){}//: Should not match (it does) ERROR
//	void around(): execution(* C.m5(..))  && args(List<? extends Number>){}//: Should match (it does)
//	void around(): execution(* C.m5(..))  && args(ArrayList<? extends Number>){}//: Should runtime check (it does!)
//	void around(): execution(* C.m5(..))  && args(List){}//: Should match (it does)	
//	void around(): execution(* C.m5(..))  && args(ArrayList){}//: Should runtime check (it does not match!) ERROR	
//	void around(): execution(* C.m5(..))  && args(List<?>){}//: Should match (it does)	
//	void around(): execution(* C.m5(..))  && args(ArrayList<?>){}//: Should runtime check (it does not match!)	
//	void around(): execution(* C.m5(..))  && args(ArrayList<String>){}//: Should not match (it does not match!) 

//	void around(): execution(* D2.m5(..))  && args(List<D1>){} //: Should not match (but it does) ERROR 
//	void around(): execution(* D2.m5(..))  && args(ArrayList<D1>){}//: Should not match (but it does!) ERROR
//	void around(): execution(* D2.m5(..))  && args(List<C1>){}//: Should not match (but it does!) ERROR
//	void around(): execution(* D2.m5(..))  && args(ArrayList<C1>){}//: Should not match (it does) ERROR
//	void around(): execution(* D2.m5(..))  && args(List<? extends B1>){}//: Should match (it does)
//	void around(): execution(* D2.m5(..))  && args(ArrayList<? extends B1>){}//: Should runtime check (it does!)
//	void around(): execution(* D2.m5(..))  && args(List<? extends C1>){}//: Should match (it does)
//	void around(): execution(* D2.m5(..))  && args(ArrayList<? extends C1>){}//: Should runtime check (it does!)
//	void around(): execution(* D2.m5(..))  && args(List){}//: Should match (it does)	
//	void around(): execution(* D2.m5(..))  && args(ArrayList){}//: Should runtime check (it does not match!) ERROR	
//	void around(): execution(* D2.m5(..))  && args(List<?>){}//: Should match (it does)	
//	void around(): execution(* D2.m5(..))  && args(ArrayList<?>){}//: Should runtime check (it does not match!)	
//	void around(): execution(* D2.m5(..))  && args(ArrayList<String>){}//: Should not match (it does not match!)	

//	void around(): execution(* C.m6(..))  && args(List<Integer>){} //: Should not match (but it does) ERROR 
//	void around(): execution(* C.m6(..))  && args(ArrayList<Integer>){}//: Should not match (but it does!) ERROR
//	void around(): execution(* C.m6(..))  && args(List<Number>){}//: Should not match (but it does!) ERROR
//	void around(): execution(* C.m6(..))  && args(ArrayList<Number>){}//: Should not match (it does) ERROR
//	void around(): execution(* C.m6(..))  && args(List<? extends Number>){}//: Should match (it does)
//	void around(): execution(* C.m6(..))  && args(ArrayList<? extends Number>){}//: Should runtime check (it does!)
//	void around(): execution(* C.m6(..))  && args(List){}//: Should match (it does)	
//	void around(): execution(* C.m6(..))  && args(ArrayList){}//: Should runtime check (it does not match!)	
//	void around(): execution(* C.m6(..))  && args(List<?>){}//: Should match (it does)	
//	void around(): execution(* C.m6(..))  && args(ArrayList<?>){}//: Should runtime check (it does not match!)	
//	void around(): execution(* C.m6(..))  && args(ArrayList<String>){}//: Should not match (it does not match!)		

//	void around(): execution(* C.m7(..))  && args(List<List<Integer>>){} //: Should not match (but it does) ERROR 
//	void around(): execution(* C.m7(..))  && args(ArrayList<List<Integer>>){}//: Should not match (but it does!) ERROR
//	void around(): execution(* C.m7(..))  && args(List<List<Number>>){}//: Should not match (but it does!) ERROR
//	void around(): execution(* C.m7(..))  && args(ArrayList<List<Number>>){}//: Should not match (but it does) ERROR
//	void around(): execution(* C.m7(..))  && args(List<? extends List<Number>>){}//: Should not match (but it does) ERROR
//	void around(): execution(* C.m7(..))  && args(ArrayList< ? extends List<Number>>){}//: Should not match (but it does!) ERROR
//	void around(): execution(* C.m7(..))  && args(List< ? extends List<? extends Number>>){}//: Should match (it does!)	
//	void around(): execution(* C.m7(..))  && args(ArrayList< ? extends List<? extends Number>>){}//: Should match (it does!)
//	void around(): execution(* C.m7(..))  && args(List){}//: Should match (it does)	
//	void around(): execution(* C.m7(..))  && args(ArrayList){}//: Should runtime check (it does not match!)	
//	void around(): execution(* C.m7(..))  && args(List<?>){}//: Should match (it does)	
//	void around(): execution(* C.m7(..))  && args(ArrayList<?>){}//: Should runtime check (it does!)	
//	void around(): execution(* C.m7(..))  && args(ArrayList<List<String>>){}//: Should not match (it does not match!)	

//	void around(): execution(* C.m8(..))  && args(List<Integer>){} //: Should match with unchecked conversion (it does) 
//	void around(): execution(* C.m8(..))  && args(ArrayList<Integer>){}//: Should runtime check with unchecked conversion (it does!)
//	void around(): execution(* C.m8(..))  && args(List<Number>){}//: Should match with unchecked conversion (it does!)	
//	void around(): execution(* C.m8(..))  && args(ArrayList<Number>){}//: Should runtime check with unchecked conversion (it does)
//	void around(): execution(* C.m8(..))  && args(List<? extends Number>){}//: Should match with unchecked conversion (it does!)	
//	void around(): execution(* C.m8(..))  && args(ArrayList<? extends Number>){}//: Should runtime check with unchecked conversion (it does)
//	void around(): execution(* C.m8(..))  && args(List){}//: Should match (it does)	
//	void around(): execution(* C.m8(..))  && args(ArrayList){}//: Should runtime check (it does!)	
//	void around(): execution(* C.m8(..))  && args(List<?>){}//: Should match (it does)	
//	void around(): execution(* C.m8(..))  && args(ArrayList<?>){}//: Should runtime check (it does!)	
//	void around(): execution(* C.m8(..))  && args(ArrayList<String>){}//: Should not match (it does not match!)	

//	void around(): execution(* C.m9(..))  && args(List<Integer>){} //: Should not match (but it does) ERROR 
//	void around(): execution(* C.m9(..))  && args(ArrayList<Integer>){}//: Should not match (it does not match!)
//	void around(): execution(* C.m9(..))  && args(Number){}//: Should match (it does!)	
//	void around(): execution(* C.m9(..))  && args(Integer){}//: Should runtime check (it does)
//	void around(): execution(* C.m9(..))  && args(List<? extends Number>){}//: Should not match (but it does) ERROR
//	void around(): execution(* C.m9(..))  && args(ArrayList<? extends Number>){}//: Should not match (it does not match!)
//	void around(): execution(* C.m9(..))  && args(List){}//: Should not match (but it does) ERROR	
//	void around(): execution(* C.m9(..))  && args(ArrayList){}//: Should not match (it does not match!)	
//	void around(): execution(* C.m9(..))  && args(List<?>){}//: Should not match (but it does) ERROR	
//	void around(): execution(* C.m9(..))  && args(ArrayList<?>){}//: Should not match (it does not match!)	
//	void around(): execution(* C.m9(..))  && args(String){}//: Should not match (it does not match!)	
}

Back to the top