For interop I write interfaces in Java. This way I can provide type- specific signatures, constants, javadocs and generics; then implement them all in Clojure. I also write exception classes in Java for use in Clojure since I find it simpler and cleaner than gen-class. You don't have to give up anyting for the sake of interop, but perhaps you won't write 100% Clojure.
On Mar 24, 4:58 am, Jules <jules.gosn...@gmail.com> wrote: > Guys, > > I have a hybrid Java/Clojure project. > > The Java side contains a number of interfaces/classes that make use of > generics. > > Implementing the interfaces Clojure-side is no problem - I just forget about > type and get on with it :-) > > I am slowly migrating more and more code into Clojure and there will come a > point when I'd like to take some of these interfaces over... > > So now to my confusion: > > My understanding is that generics are a compile-time, NOT a run-time > abstraction. > > This implies that metadata about generics would not be present at runtime > and therefore [probably] not in bytecode ? > > So, I would expect to be able to replace my interfaces with defprotocols - > however, I would expect this to confuse Java implementations of these > interfaces, since they somehow have access to their interfaces > generics-oriented metadata... > > So maybe I have answered my question - I guess that there must actually be > some generics metadata present in the bytecode to allow inter-jar generics > compilation to work, but then at runtime this would be ignored [probably]. > > So this leads me to conclude that I would > > 1. have to port my classes that implement generic interfaces to Clojure > before the interfaces themselves. > 2. give up the ability to write further generic implementations of these > interfaces in Java > > :-( > > can anyone who really knows what the situation is confirm my suspicions ? > > thanks for your time, > > 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