Another possible disadvantage has to do with reflection.
I ran into this when developing a compiler for .NET and also looked at JVM. .NET guys decided to support generics both in the compiler and the VM. Java took the other route and made it a compiler-only implementation. So at runtime, when you reflect on a type, the signature will not show what type the parameter was, and there are not individual classes created. I don't care for this approach, but they made their decisions probably for backwards compatibility at some point. Ironic, though, because when you read the docs on generics, you are warned about deploying on pre-Java 5 VMs.
From the docs: "Generics do not generate a new class for each specialization, nor do they permit template metaprogramming.
An interesting article on the subject here: http://tutorials.jenkov.co
Main Topics
Browse All Topics





by: a_bPosted on 2009-07-29 at 18:54:53ID: 24976149
"The main disadvantages are that parameter type information is not available at run time, and that automatically generated casts may fail when interoperating with ill-behaved legacy code."
.5.0/docs/ guide/lang uage/ gener ics.html
Ref - http://java.sun.com/j2se/1