Nice TWiki > Dev > TypeErasureLimitations ( vs. r1.1) TWiki webs:
Dev | Doc | Main | TWiki | Sandbox
Dev . { Changes | Index | Search | Go }
 <<O>>  Difference Topic TypeErasureLimitations (r1.1 - 30 Apr 2005 - TWikiGuest)
Added:
>
>

%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


Topic TypeErasureLimitations . { View | Diffs | r1.1 | More }
Revision -
Revision r1.1 - 30 Apr 2005 - 12:14 GMT - TWikiGuest
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback.