K
kelvSYC
Now, one of the big criticisms of type-erasure generic programming is
that - well, it's type erasure generic programming: suppose you have
public static <T> List<T> doStuff(){
...
}
Within the body of doStuff(), T.class is an error, and the only way to
get what T stands for is to use that big backhoe that's reflection and
somehow get a Class<T> object - which you would do by passing in a
Class<T>, resulting in...
public static <T> List<T> doStuff(Class<T> tClass) {
...
}
Now IMO T.class should really return a Class<T>, just like
Integer.class gives you Class<Integer>, but I guess that other peoples
opinions differed (I am not sure about the argument against it, so
please explain to me what it is).
Why do I mention this? It seems like annotations and annotation
processing might be a means to an address this. (If I am wrong about
annotations or annotation processing, please correct me). It seems
like there should be an annotation processor that would take code of
the former form and convert it to code of the latter form (the needed
Class arguments would be the first arguments passed in).
Am I ill-informed on this, and if not, is there such an annotation
processor?
that - well, it's type erasure generic programming: suppose you have
public static <T> List<T> doStuff(){
...
}
Within the body of doStuff(), T.class is an error, and the only way to
get what T stands for is to use that big backhoe that's reflection and
somehow get a Class<T> object - which you would do by passing in a
Class<T>, resulting in...
public static <T> List<T> doStuff(Class<T> tClass) {
...
}
Now IMO T.class should really return a Class<T>, just like
Integer.class gives you Class<Integer>, but I guess that other peoples
opinions differed (I am not sure about the argument against it, so
please explain to me what it is).
Why do I mention this? It seems like annotations and annotation
processing might be a means to an address this. (If I am wrong about
annotations or annotation processing, please correct me). It seems
like there should be an annotation processor that would take code of
the former form and convert it to code of the latter form (the needed
Class arguments would be the first arguments passed in).
Am I ill-informed on this, and if not, is there such an annotation
processor?