Nice TWiki > Dev > NiceCompiler > TypeErasureLimitations TWiki webs:
Dev | Doc | Main | TWiki | Sandbox
Dev . { Changes | Index | Search | Go }
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 . { Edit | Attach | Ref-By | Printable | Diffs | r1.1 | More }
Revision r1.1 - 30 Apr 2005 - 12:14 GMT - TWikiGuest
Parents: WebHome > NiceCompiler
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.