> > |
%META:TOPICINFO{author="TWikiGuest" date="1114863265" format="1.0" version="1.1"}%
%META:TOPICPARENT{name="NiceCompiler"}%
Generics are implemented in Nice using a technique called `type erasure' - just like in Java 5.
The technique and some of its repercussions are quite nicely described at: http://gafter.blogspot.com/2004/09/puzzling-through-erasure-answer.html
Basically, choosing for type erasure means the knowledge which type parameter was used is known at compile-time, but not anymore at runtime. That is why you can do `foo instanceof NiceVector?', but not `foo instanceof NiceVector?<String>'.
Also, casting a NiceVector?<Integer> to NiceVector?<String> will not give a ClassCastException?. This means you can add strings to a (casted) NiceVector?<Integer>, and you'll find out only when you try to remove that element from the NiceVector?<Integer> as an Integer. In other words, you'll get a ClassCastException? in another place then where the bug is, and in fact in a piece of the code where there is no cast.
-- Main.Raboof - 30 Apr 2005 |