I figured generics would create less work for me and more extensible architectures.
This is what it comes down to:
public Keys[] getKeys()
{
Keys[] keys = new Keys[this.keys.size()];
System.arraycopy(this.keys.toArray(), 0, keys, 0, this.keys.size());
return keys;
}
Everytime I use “collection.toArray()” and cast it to “(Type[])collection.toArray()” I get a ClassCastException.
I managed to do some reading on it and found out that it was the fault of generics.
What I want to know is if are Sun going to fix this issue? I have found absolutely no indication that they are.
However if they are going to fix the issue, are they going to replace type erasure in generics or will they opt for a walkaround?