Bug 150095 - [generics] compile error with declare parents and generics
Summary: [generics] compile error with declare parents and generics
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.5.3   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-09 09:51 EDT by Christophe Delhorbe CLA
Modified: 2006-07-19 09:48 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christophe Delhorbe CLA 2006-07-09 09:51:04 EDT
Using aspectJ 1.5 and JDK 6b2, this code :

 public class MyClass
 {}

 public aspect BCSAspect
 {
   declare parents : MyClass extends java.beans.context.BeanContextSupport;
 }

gives a compile error saying that the method toArray([[T) must be implemented in MyClass, whereas toArray(Object) is implemented in BeanContextSupport.
Comment 1 Andrew Clement CLA 2006-07-10 09:53:23 EDT
Recreated on Java5 - it is related to the signature of that toArray() method and the inheritance hierarchy that exists in BeanContextSupport.  Here is the failing pure java case (no java beans):

import java.util.*;

interface I extends Collection { }

class B implements I {

  public Object[] toArray(Object[] os) { return os; }

  public boolean add(Object o) { return false; }
  public boolean addAll(Collection c) { return false; }
  public void clear() { }
  public boolean contains(Object o) { return false; }
  public boolean containsAll(Collection c) { return false; }
  public boolean isEmpty() { return false; }
  public Iterator iterator() { return null; }
  public boolean remove(Object o) { return false; }
  public boolean removeAll(Collection c) { return false; }
  public boolean retainAll(Collection c) { return false; }
  public int size() { return 0; }
  public Object[] toArray() { return null; }
}

class C { }

aspect X {
  declare parents: C extends B;
}

ajc -1.5 Foo.java
Foo.java:23 [error] The type C must implement the inherited abstract 
method java.util.Collection.toArray([TT;)
class C { }
        see also: java\util\Collection.java::0
        see also: Foo.java:26::0

the problem appears to be that interface I uses Collection in its raw form, so through interface I we should see 'Object[] I.toArray(Object[])' - and that is implemented correctly by the class.  But the original generic method from Collection is leaking through, it doesn't get converted to a raw form, and it comes through as 'T[] toArray([TT;)'.
Comment 2 Andrew Clement CLA 2006-07-10 10:51:50 EDT
testcase and fix committed.  On collecting generic members and translating them to their raw form, we overlooked the form 'array of type variable'.
Comment 3 Andrew Clement CLA 2006-07-19 09:48:55 EDT
fix available in latest AJ dev build.