Summary: | [generics] Call generic method from within inter-type method: NoSuchMethodError | ||
---|---|---|---|
Product: | [Tools] AspectJ | Reporter: | Michael Herrmann <hamster2k> |
Component: | Compiler | Assignee: | aspectj inbox <aspectj-inbox> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | aclement, vb |
Version: | 1.5.0 | ||
Target Milestone: | 1.6.2 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Michael Herrmann
2006-06-05 13:37:55 EDT
thanks for the clear bug report and test program. the erasure of the method invoked by the ITD is being lost during (de)serialization. Leaving us with a 'V extends Object' return value which is incorrect. this related case is also a problem: (typevar as parameter rather than return type) public class GenericType2<V extends Integer> { public GenericType2(V value) {} public void foo() {} protected void getValue(V aV) { } public static void main(String[] args) { new GenericType2<Integer>(null).foo(); } } aspect SomeAspect { before(GenericType2 t): call(* GenericType2.foo()) && target(t) { t.callGenericMethod(); } private void GenericType2.callGenericMethod() { getValue(new Integer(45)); } } these two testcases are committed - commented out in Ajc152Tests investigate for 1.5.4, but might fall back to 1.6.0 if it is a bit tricky to get solved! I have fixed the first case of this: private void GenericType.callGenericMethod() { getValue(); } will now work. Yet more code that wasn't generics aware needed changing. Case 2 i am not fixing. If you write this Java code: public class GenericType2<V extends Integer> { public void getValue(V v) {} public void foo() { getValue(new Integer(45)); } } Then it doesn't compile with javac: "The method getValue(V) in the type GenericType2<V> is not applicable for the arguments (Integer)" (which I perhaps found a little surprising giving that the parameter meets the specified bound). AspectJ gives the same error if the getValue() call is moved out into the ITD |