This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 49968 - When implementing methods from AbstractList<String>, toArray offered as abstract
Summary: When implementing methods from AbstractList<String>, toArray offered as abstract
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 4.x
Hardware: PC Linux
: P3 blocker (vote)
Assignee: Daniel Prusa
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-05 19:35 UTC by Jesse Glick
Modified: 2007-09-26 09:14 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2004-10-05 19:35:20 UTC
041004 custom. I have a j2seproject using JDK 1.5.
Make a class

public class MyList extends AbstractList<String> {}

and press Ctrl-I and click Abstract Methods only.
Offers

- String get(int)
- Object[] toArray(Object[])
- int size()

get and size are in fact abstract. But toArray is
not - AbstractCollection defines

public <T> T[] toArray(T[] a) {...}

and in fact if I comment out the generated toArray
method, leaving only impls of get and size, the
class still compiles.

Also note that the generated toArray method is
marked with an override annotation, not an
implements annotation as for get and size.

So I guess it should not have been listed as an
"abstract" method to begin with?
Comment 1 Jesse Glick 2004-10-05 19:36:40 UTC
Similarly for

public class MyList<E> extends AbstractList<E> {...}
Comment 2 Jesse Glick 2004-10-05 19:39:28 UTC
...except in that case the generated toArray has signature

public Object[] toArray(Object[] a) {...}

whereas I suppose it should be

public <E> E[] toArray(E[] a) {...}

(right?)

and furthermore using either of the two above signatures, I get no
annotation at all next to the toArray method, unlike in the original
case when I was extending AbstractList<String>.
Comment 3 Jesse Glick 2004-10-05 19:42:29 UTC
...and after implementing

public <E> E[] toArray(E[] a) {...}

Ctrl-I still offers

toArray(java.lang.Object[]) : java.lang.Object[]

as a possible method to override/implement ("Show Abstract Methods
Only" either checked or unchecked).
Comment 4 ehucka 2005-01-11 13:26:03 UTC
old target milestone, please re-evaluate
Comment 5 Martin Matula 2005-03-17 09:01:11 UTC
jglick wrote:

>Similarly for
>
>public class MyList<E> extends AbstractList<E> {...}
>
>...except in that case the generated toArray has signature
>
>public Object[] toArray(Object[] a) {...}
>
>whereas I suppose it should be
>
>public <E> E[] toArray(E[] a) {...}
>
>(right?)

The method has its own parameter unrelated to the type parameter defined in the
class. So:
public <T> T[] toArray(T[] a) {...}
is equivalent to :
public <E> E[] toArray(E[] a) {...}
no matter what the name of the type parameter in the parent class is.
Comment 6 Daniel Prusa 2005-03-17 15:53:10 UTC
/cvs/java/javacore/src/org/netbeans/modules/javacore/jmiimpl/javamodel/ClassDefinitionImpl.java,v
 <--  ClassDefinitionImpl.java
new revision: 1.19; previous revision: 1.18

/cvs/java/src/org/netbeans/modules/java/tools/JMIInheritanceSupport.java,v  <--
 JMIInheritanceSupport.java
new revision: 1.14; previous revision: 1.13
Comment 7 Quality Engineering 2007-09-20 12:46:26 UTC
Reorganization of java component