ClassCastException while using varargs and generics
I'm using java generics and varargs. If I use the following code, I'll get a ClassCastException , even though I'm not using casts at all. Stranger yet, if I run this on Android (dalvik) no stack trace is included with the exception, and if I change the interface to abstract class, the exception variable e is empty. The code: public class GenericsTest { public class Task<T> { public void doStuff(T param, Callback<T> callback) { // This gets called, param is String "importantStuff" // Working workaround: //T[] arr = (T[]) Array.newInstance(param.getClass(), 1); //arr[0] = param; //callback