Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#12 ClassCastException in view properties

open
nobody
None
5
2002-02-20
2002-02-20
dylan mcreynolds
No

I'm running in jdk1.3. I get a ClassCastException in
DAVFile.getLinks() when attempting to view the
properties page.

The line of code is:

return (Link[]) links.toArray();

I believe that that this is a problem because the
ArrayList.toArray() method always returns an Object[],
which doesn't successfully cast to Link[].

On my own machine, I've gotten around it by creating a
new Link[] and using the ArrayList.toArray(Object[])
method instead. This method uses the parameter to
determine the variable type that it's creating.

Link[] returnLinks = new Link[links.size()];
links.toArray(returnLinks);
return returnLinks;

Discussion