This is only half-true. The data exists somewhere, as Jules says, so
that javac can enforce proper use of generics when calling compiled
library code. Eg, rt.jar contains only classes, yet j.u.List still
manages to have generics, which are treated correctly by the compiler.
The *use* of generic code is compiled into just a bunch of Objects and
casting, but the .class file does contain some annotations to declare
the generics. It's just rather hard to find.

On Mar 24, 8:19 am, Andy Fingerhut <andy.finger...@gmail.com> wrote:
> I'm not an expert on this, but I believe that whenever you have generics in 
> Java, they have no effect on the bytecode, e.g. a HashMap<String,String> has 
> the same type in the bytecode as any other HashMap.  The <String,String> part 
> is only used in some checks made by the Java compiler when compiling Java 
> source code, and in helping avoid some casting.  As evidence I have used 
> reflection to examine the fields and method signatures of some Java classes 
> that have generics, and there was nothing in the types except that which was 
> specified outside the < ... >.
>
> Andy
>
> On Mar 24, 2011, at 8:04 AM, Jules wrote:
>
>
>
>
>
>
>
> > Thanks for the reply Armando,
>
> > This is pretty much where i was until I was asked to write a dot.net client 
> > library for my server.
>
> > I then looked at all my Java code and figured I could write a second copy 
> > in C# and then keep the two in sync for ever after, or port it all to 
> > Clojure and let ClojureCLR do the work...
>
> > I guess I can't have my cake and eat it.
>
> > In a perfect world, I would be able to sprinkle some extra metadata around 
> > my defprotocol to give Java classes implementing it whatever generics 
> > goodness they require - but I can understand this being low on Clojure's 
> > TODO list :-)
>
> > Jules
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with 
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to