What I cannot do with generics ?

My first brush with Java generics was around 3 years back when I found a prototype compiler from Gilad Bracha ( I think ). Though I never delved too deep into that, I recently realised that one way to learn generics is to check what java generics can’t do that C++ templates can.

I came across a “abstract subclass” that we can’t write using java. AFAIK this is not our regular
java subclass that is abstract. The “Curiously Recurring Template Pattern (CRTP)” is one such instance.

There is no point in trying this C++ template trick using generics because the type is erased. So the controversial type erasure can teach you a lot of things that you can do with Java generics.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: