Swing in a better world: Generics and arrays
Generics doesn't work well with arrays. Everybody knows that you can't create a generified array,
but not many people really know what it was done this way.
A nice article from Brian Goetz helped me to understand the problem
when I studied the new features of JDK 5.
If a generfied program is compiled without a warning you can safely add an Object to your ArrayList of Objects.
String stringArray = new String;
// compiles ok
Object objectArray = stringArray;
// throws ArrayStoreException
objectArray = new Object();
stringList = new ArrayList ();
// doesn't compile - incompatible types
However when there is an array of Objects passed to your method as a parameter, there is no way to understand an object of what type you can put there
(I am not sure if you can find it out via reflection).
So it is known that arrays and generics don't do well together. It means that it is not recommended to use two features of JDK 5 together,
I am talking about generics and varargs. This reminds me one old bug found by R