"Martin Strand" <[EMAIL PROTECTED]> wrote on 30/10/2006 17:33:32:
> On Mon, 30 Oct 2006 18:24:27 +0100, Stephanos Piperoglou <stephanos. > [EMAIL PROTECTED]> wrote: > > > I was kind of expecting to be able to use a generic type (T > > above) as an instance of java.lang.Class. Unsurprisingly, I can't. > > Surprisingly, I can't find a way to work around it! > > Afaik, the type info isn't available at runtime for generic classes > so it can't be done. You're absolutely right; I was forgetting that generics in 1.5 are nothing but glorified syntactic sugar; the compiler does the type checking and then throws it all away. You need the class in the constructor for runtime availability. On the other hand, I'm still miffed that I have to use java.lang.Class.getEnumConstants() (which I had to dig through the API to find, and seems a bit inelegant even though the generic definition for the class guarantees type safety) when all the tutorials mention the <EnumType>.values() static method, which is defined for every subtype of java.lang.Enum but not Enum itself! Of course it's because you can't have abstract static methods in Java anyway... it just looks a bit ugly Still, why am I complaining? It's a hell of a lot better than public static final int CITY_NYC = 1... :) Thanks for the timely response to the initial query and humoring my aside guys! --- This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.