Re: Annotations and generic programming



kelvSYC wrote:

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).

Existing code would not work if it made use of classes that had been generified. There could have been some system where T.class may or may not give you the Class, but that would make Java an even bigger language.

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).

No. No part of the code you quoted actually specifies the class of T. There is no way an annotation processor could get that information.

Tom Hawtin
.